Skip to content

docs(security): an OAuth callback with no session trusts only its signed state - #3446

Open
lilyshen0722 wants to merge 2 commits into
mainfrom
launch/oauth-state-doc
Open

lilyshen0722 wants to merge 2 commits into
mainfrom
launch/oauth-state-doc

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

This adds one section to docs/security-patterns.md on what an OAuth callback that arrives with no session may trust. The short answer is its state, and only when the server signed that state with the user and the resource. The pattern comes from #3436, the Discord install, which is live.

The section covers:

  • the threat: an attacker's code paired with the victim's resource id;
  • the rules:
    • mint the state where authority over the resource was already checked;
    • refuse any other state before the code exchange;
    • bind whatever the callback hands back to that same user;
    • still check authority over the resource at the write;
    • give each token its own purpose claim;
  • the reference implementation and its test.

Also in this change:

Tier 0, docs only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MDs9DT6tbhKm6UhsmFhLk9

lilyshen0722 and others added 2 commits November 4, 2026 13:58
The pattern behind #3436: sign the state server-side with the user and
resource, refuse anything else before the code exchange, bind what the
callback hands back to that user, and still check authority over the
resource at the write.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MDs9DT6tbhKm6UhsmFhLk9
…den the header

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MDs9DT6tbhKm6UhsmFhLk9

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Review at dd9b583. One subagent review (Sonnet), tier 0, docs only.

  • Code claims: every one matches the code as merged in #3436:
    • the purpose claims (discord-install-state and discord-install), with no id or user claim in either, so neither reads as a session;
    • install-link mints only after canManagePod;
    • the callback refuses a bad state before the token exchange;
    • the user-bound proof is checked at /channels and at hasDiscordGuildAuthority;
    • the creator-or-admin check on bind runs before the guild check.
  • Anchor: the quick-reference anchor resolves to the new heading.
  • Infra and ids: no infra identifiers and no internal ledger ids.
  • Nits from the review, all fixed in the second commit:
    • the order of the sources list;
    • the summary-exposure line now cites discordCommandService.handleSummaryCommand;
    • the file header now covers authorization shapes.

GATE: PASS

@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords: 1
  • security

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Nov 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 4, 2026
@lilyshen0722
lilyshen0722 added this pull request to the merge queue Nov 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 4, 2026

This branch has not been deployed

No deployments
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