Skip to content

Develop#36

Merged
0xmanhnv merged 8 commits into
mainfrom
develop
Apr 7, 2026
Merged

Develop#36
0xmanhnv merged 8 commits into
mainfrom
develop

Conversation

@0xmanhnv
Copy link
Copy Markdown
Collaborator

@0xmanhnv 0xmanhnv commented Apr 7, 2026

No description provided.

0xmanhnv added 8 commits April 7, 2026 07:30
SSO Handler validation:
- CreateProviderRequest: provider enum (entra_id/okta/google_workspace),
  display_name max=255, client_id max=255, client_secret max=1000,
  issuer_url validated url, scopes max=20, allowed_domains max=50,
  default_role enum (member/viewer only - owner not allowed via SSO)
- UpdateProviderRequest: same bounds on all optional fields

E2E test (28 tests):
- A. Provider CRUD (create, list, get, update, delete)
- B. Input validation (invalid provider, missing fields, role, bounds)
- C. Security (no auth, cross-tenant, SSRF redirect, invalid state)
- D. SSO authorize flow (URL generation, state token, scopes)
- E. Provider lifecycle (activate, deactivate, delete)
When a user exists with auth_provider=local (has password), block SSO
login with the same email from a different provider. This prevents:

1. Attacker controls SSO IdP with victim's email → logs into victim's account
2. Local user accidentally merged with SSO identity

Rules:
- Same provider → allow (normal SSO re-login)
- OIDC provider → allow (generic OIDC is flexible)
- Local user WITHOUT password → allow (invited user, not yet set password)
- Local user WITH password → BLOCK (existing local account, must use password)

Log blocked attempts as warnings for security monitoring.
Same auth provider mismatch bug as SSO fixed earlier:
- Block OAuth login when email exists with local auth (has password)
- Allow if local user has no password (invited, not yet configured)
- Log blocked attempts as warnings

Also: require email from OAuth provider before creating/linking user.
Previously, a provider returning no email could create a user with
empty email, breaking uniqueness constraints.
Google OAuth userinfo can return unverified emails. An attacker could:
1. Create Google account with unverified corporate email
2. Login via OAuth → system accepts unverified email
3. Join corporate tenant if domain matches

Fix: check 'verified_email' field from Google userinfo v2 endpoint.
Reject login if email is not verified.

Note: GitHub already checks verified flag. Microsoft Graph API
inherently returns verified emails (no explicit check needed).
PKCE (RFC 7636) for OAuth:
- Generate code_verifier (32 bytes random, base64url)
- Compute code_challenge = SHA256(verifier), base64url
- Send code_challenge + code_challenge_method=S256 in authorize URL
- Send code_verifier in token exchange request
- Verifier stored in signed state token (HMAC-SHA256)
- Prevents authorization code interception attacks

Nonce for SSO:
- Generate 16-byte random nonce per SSO authorization
- Include nonce in authorize URL params
- Store nonce in signed state token for verification
- Prevents ID token replay attacks

Session revocation:
- Document race window between session and refresh token revocation
- Window is <1ms and mitigated by session check in ExchangeToken
GetAssetStats: 3 queries → 1 CTE (total + by_type + by_status in single scan)
GetFindingStats: 4 queries → 1 CTE (total + by_severity + by_status + avg_cvss)

Dashboard endpoint now uses 2 queries instead of 8 for the summary page.
Both CTEs use a common base CTE to scan the table once.
Added 13 fields that were stored in DB but never returned:
- parent_id, discovery_source, discovery_tool, discovered_at
- compliance_scope, data_classification
- pii_data_exposed, phi_data_exposed, is_internet_accessible
- sync_status, last_synced_at

Verified on live API: all fields present in response.
…role, service_account)

5 asset types existed in Go code and UI but were missing from the
asset_types DB table, causing FK constraint violation (500 error)
when creating assets of these types.

Migration 000100 seeds:
- ip_address (was 'ip' in DB, Go uses 'ip_address')
- serverless (was 'serverless_function', Go uses 'serverless')
- iam_user (new identity type)
- iam_role (new identity type)
- service_account (new identity type)

Verified: all 5 types now create successfully (201).
Status lifecycle (activate/deactivate/archive) also verified working.
@0xmanhnv 0xmanhnv merged commit 71300f4 into main Apr 7, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant