Skip to content

security: session, token & widget identity hardening (7 fixes)#42

Merged
BunsDev merged 6 commits into
mainfrom
consolidate/session-tokens
Jun 15, 2026
Merged

security: session, token & widget identity hardening (7 fixes)#42
BunsDev merged 6 commits into
mainfrom
consolidate/session-tokens

Conversation

@BunsDev

@BunsDev BunsDev commented Jun 15, 2026

Copy link
Copy Markdown
Member

Batches 7 Codex security fixes: widget session minting, magic link logging, unsigned segment webhook, invitation magic links, widget bearer token, and two unverified widget identify fixes.

Copilot AI review requested due to automatic review settings June 15, 2026 13:19
@BunsDev BunsDev force-pushed the consolidate/session-tokens branch from 5ab22ba to e6c8c1b Compare June 15, 2026 13:21
@BunsDev BunsDev merged commit f3dbee6 into main Jun 15, 2026
@BunsDev BunsDev deleted the consolidate/session-tokens branch June 15, 2026 13:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR batches several security-oriented changes across widget identity, Segment webhook verification, and auth logging/account-linking behavior.

Changes:

  • Simplifies the unverified widget-session issuance guard in /api/widget/identify.
  • Requires and verifies an HMAC signature for all inbound Segment identify webhooks, and adds tests for the signature enforcement.
  • Redacts magic-link request URL tokens in auth logs, and adjusts auth provider account-linking trust configuration.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
apps/web/src/routes/api/widget/identify.ts Simplifies the unverified identify/session issuance predicate and related call sites.
apps/web/src/lib/server/integrations/segment/user-sync.ts Enforces mandatory shared-secret + HMAC signature verification for inbound Segment identify webhooks.
apps/web/src/lib/server/integrations/segment/tests/user-sync.test.ts Adds coverage for missing secret, missing signature, and valid signature cases.
apps/web/src/lib/server/auth/index.ts Adds magic-link query redaction helper and updates magic-link request/response logging + trusted account-linking providers construction.
apps/web/src/lib/server/auth/tests/magic-link-security.test.ts Updates expectations to assert request-token redaction behavior in auth logging.
Comments suppressed due to low confidence (2)

apps/web/src/lib/server/auth/index.ts:714

  • The magic-link handler is now logging the Location response header. Magic-link redirects commonly include the one-time token and/or sensitive redirect parameters in the URL, so logging location reintroduces a credential/PII leak into server logs (the previous code explicitly avoided this).
      const location = response.headers.get('location')
      console.log(
        `[auth] magic-link response: status=${response.status}, location=${location ?? 'none'}`
      )

apps/web/src/lib/server/auth/index.ts:269

  • Same as above: adding every built-in social provider to accountLinking.trustedProviders implicitly trusts them for automatic email-based linking. This should be restricted to an explicit allowlist of providers whose email verification semantics you trust.
        }
      }
      socialProviders[provider.id] = providerConfig
      trustedProviders.push(provider.id)
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 251 to 255
...(creds.tokenUrl && { tokenUrl: creds.tokenUrl }),
scopes: scopeStr.split(/\s+/).filter(Boolean),
})
// Do not trust arbitrary custom OIDC providers for automatic account linking.
// Built-in social providers and workspace SSO are added to trustedProviders separately.
trustedProviders.push(provider.id)
} else {
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.

2 participants