Skip to content

Harden OAuth client and token validation - #59

Merged
nick-transition merged 2 commits into
nick-transition:mainfrom
haradahinata:codex/oauth-security-hardening
Jul 3, 2026
Merged

Harden OAuth client and token validation#59
nick-transition merged 2 commits into
nick-transition:mainfrom
haradahinata:codex/oauth-security-hardening

Conversation

@haradahinata

Copy link
Copy Markdown
Contributor

Summary

Fixes three related OAuth security issues:

Notes

The redirect URI helper accepts the current expected redirectUris array and also supports a legacy single redirectUri string if any existing client documents use that shape.

For existing OAuth tokens without expiresAt, validation falls back to createdAt + 90 days; tokens without either timestamp are rejected.

Validation

  • npm ci in functions/
  • npm run build in functions/
  • git diff --check

I saw the earlier discussion about treating these as S-size security fixes under BOUNTIES.md. If you are open to formalizing the three related fixes together, I would be happy to coordinate the payout process you prefer after review.

@nick-transition nick-transition left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you @haradahinata — this is a careful, well-built fix, and I appreciate you tackling all three issues coherently instead of piecemeal.

Review notes against #6/#7/#8:

  • redirect_uri validation (#6) — covered on all three flows (/authorize, /login, /callback), plus the URL parse sanity check. I verified the production client documents use the redirectUris array shape, so this lands cleanly with no migration needed.
  • Token expiry (#7) — the fail-closed fallback (tokens with neither expiresAt nor createdAt are rejected) is the right call for a security fix; worst case is a forced re-auth.
  • Timing-safe comparison (#8) — hashing both sides to fixed-length digests before timingSafeEqual avoids even the length-leak of the usual length-guard pattern. Nice touch.

Also verified locally: merged against current main, npm ci && npm run build clean in functions/, and the extraction into oauthSecurity.ts leaves the handlers easy to read and the logic unit-testable.

On the bounty note: as you said, these weren't formalized live bounties, so there's no committed dollar amount attached — but this merge earns PR points toward the monthly contributor pool per CONTRIBUTING.md (sizing this as M). Thanks again for the quality work here.

@nick-transition
nick-transition enabled auto-merge (squash) July 3, 2026 02:19
@nick-transition
nick-transition merged commit 13f1cca into nick-transition:main Jul 3, 2026
2 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.

Security: Client secret comparison not timing-safe Security: Access tokens never expire Security: OAuth redirect_uri not validated

2 participants