forgejo-mcp-broker/internal
Ole-Morten Duesund 8369ec2cc7 sec(oauth): phase-2 attack-path review (forgejo-mcp-broker-wgo)
Structured review of every OAuth/auth handler against the standard
attack catalog. Findings table added to design.md §8.2.

Two real issues found and fixed:

  - Refresh-token replay race: tokenRefreshGrant read the row, validated
    it, then minted a new pair before unconditionally revoking the old
    refresh. Two concurrent /token requests with the same refresh would
    both pass validation and both mint a fresh pair — token-quota
    duplication and a hint to a stolen-refresh attacker. Fixed with the
    same atomic UPDATE rows-affected pattern already used for auth-code
    single-use. New TestToken_Refresh_ConcurrentReplay_OnlyOneSucceeds
    races two goroutines and verifies exactly one wins.

  - Permissive redirect_uri schemes: validateRedirectURI accepted any
    non-empty scheme, including javascript: and data:. Tightened to
    require https, http for loopback only, or a reverse-DNS private-use
    scheme per RFC 8252 §7.1. TestValidateRedirectURI updated to cover
    each variant including the rejected javascript:/data: cases.

Items deferred to backlog (already filed):
  - Rate limits on /oauth/register and /oauth/token (-ttl)
  - --token-fd to close the /proc/<pid>/environ window (-1n2)
  - AES-GCM at-rest encryption of Forgejo tokens (-sd4)

Closes forgejo-mcp-broker-wgo. Phase 2 complete.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 17:37:00 +02:00
..
bridge test(bridge): integration test against real forgejo-mcp (forgejo-mcp-broker-xot) 2026-04-27 16:28:32 +02:00
buildinfo feat: bootstrap Go project layout (forgejo-mcp-broker-n84) 2026-04-24 16:54:27 +02:00
config feat(config): flag + env parsing with validation (forgejo-mcp-broker-9nq) 2026-04-24 17:10:18 +02:00
forgejo feat(forgejo): upstream OAuth client (forgejo-mcp-broker-b9i) 2026-04-27 13:31:19 +02:00
httpserver feat(httpserver,log): /healthz, graceful shutdown, slog constructor 2026-04-24 17:26:32 +02:00
log feat(httpserver,log): /healthz, graceful shutdown, slog constructor 2026-04-24 17:26:32 +02:00
oauth sec(oauth): phase-2 attack-path review (forgejo-mcp-broker-wgo) 2026-04-27 17:37:00 +02:00
session feat(session): idle reaper + Forgejo token rotation (forgejo-mcp-broker-q4x) 2026-04-27 17:32:36 +02:00
store feat(store): OAuth tables migration (forgejo-mcp-broker-cpb) 2026-04-27 13:28:12 +02:00
supervisor test(supervisor): stress tests for FD/goroutine/zombie leaks (forgejo-mcp-broker-31t) 2026-04-27 16:04:34 +02:00