Commit 2dd29e5
The C-1a remediation (commit 256ba06, 2026-04-10) correctly removed the
hardcoded ['generate','read'] grant from completeAuthorization() calls —
before C-1a, any OAuth-authed caller silently inherited full access
regardless of what their token claimed, which was the C-1 privilege
escalation bug. Post-C-1a, grant scopes come from oauthReqInfo.scope.
The gap: MCP clients like Claude Code and Claude.ai don't include scope
in their OAuth initiate. Post-fix, those initiates produced grants with
empty scope at every level (top-level grant.scope AND encryptedProps.scopes),
silently blocking every subsequent tool call with a "(none)" scopes error.
#28/#30 reported the symptom; this commit closes #28's creation-side bug.
Design (Option C from the #28 issue body):
- Add DEFAULT_CONSENT_SCOPES = ['read', 'generate'] as an explicit constant.
- In handleGetAuthorize auto-approve branch: when oauthReqInfo.scope is
empty AND the identity token is valid, DO NOT auto-approve. Render the
existing renderConsentPage (which was previously defined but never
reachable) with DEFAULT_CONSENT_SCOPES, so the user explicitly approves.
- In handlePostAuthorize approve branch: substitute DEFAULT_CONSENT_SCOPES
when the POSTed oauthReqInfo.scope is empty, matching what the consent
page just showed the user. Non-empty scopes are preserved verbatim.
Rejected alternatives (explicit so they don't come back):
- Client allowlist keyed on clientId (Option A from #28): REJECTED.
clientId is attacker-controlled at OAuth client registration. An
attacker registers a client with clientId: "claude-code" and inherits
the allowlist's hardcoded scopes — same class as C-1, reskinned.
- Silent injection of default scopes at auto-approve time: REJECTED.
Loses the "user explicitly consented" property that was the whole
point of C-1a. One extra hop for empty-scope initiates is an
acceptable tradeoff.
What this does NOT fix:
- Legacy grants with stale encryptedProps.scopes from pre-2026-04-10
code paths (where the old hardcoded path wrote correct top-level
grant.scope but no props.scopes). That's #29's read-side fallback
in gateway.ts resolveAuth, which lands in a separate PR.
- Static-bearer (ea_*) API key path — covered by the separate
fix(auth): accept ea_* prefix PR, which is the Phase 0 unblock.
Tests (5 new cases, 125/125 total):
- Renders consent page when oauthReqInfo.scope is empty (no
completeAuthorization call fires)
- Auto-approves when scope is non-empty (regression guard for the
zero-latency path Claude Code depends on)
- handlePostAuthorize injects DEFAULT_CONSENT_SCOPES when approving
an empty-scope grant
- handlePostAuthorize preserves client-requested scopes verbatim
(regression guard)
- Deny action still works for empty-scope initiates (no grant minted)
Related: #28, #29, #30 on this repo; PR for the ea_* patch lands
separately as a Phase 0 unblock.
Co-authored-by: Codebeast <codebeast@stackbilt.dev>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a2c0fc9 commit 2dd29e5
2 files changed
Lines changed: 214 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
11 | 23 | | |
12 | 24 | | |
13 | 25 | | |
| |||
469 | 481 | | |
470 | 482 | | |
471 | 483 | | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
472 | 505 | | |
473 | 506 | | |
474 | 507 | | |
| |||
562 | 595 | | |
563 | 596 | | |
564 | 597 | | |
565 | | - | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
566 | 608 | | |
567 | 609 | | |
568 | 610 | | |
569 | | - | |
| 611 | + | |
570 | 612 | | |
571 | 613 | | |
572 | 614 | | |
| |||
577 | 619 | | |
578 | 620 | | |
579 | 621 | | |
580 | | - | |
| 622 | + | |
581 | 623 | | |
582 | 624 | | |
583 | 625 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
416 | 585 | | |
417 | 586 | | |
418 | 587 | | |
| |||
0 commit comments