Skip to content

pm-stack: add brokered stack-token exchange - #12914

Merged
dezren39 merged 2 commits into
mainfrom
codex/20439-stack-token
Nov 23, 2026
Merged

dezren39 merged 2 commits into
mainfrom
codex/20439-stack-token

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Refs #9605

Summary

Evidence

  • direct Bun smoke: mint/verify, wrong audience, expiry, tampering, and TTL bound all exercised successfully
  • git diff --check passed
  • full Bun test/typecheck/build could not run in this checkout: bun test stalls before test discovery and bunx tsc lacks the bun type definitions; the server build also lacks the installed web-push dependency

Merge Danger

Medium. This is the aggregator/token contract slice. Kaneo, Pad, and Grist layer verifier sources are not present in this repository and remain the next implementation slice.


Start Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 23, 2026 04:53
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 37 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6e33bb32-3e9c-4f75-88ba-1bede75d4171
Commits

Reviewing files that changed from the base of the PR and between 326ac80 and a3edf32.

Files selected for processing: 6

  • pm-stack/aggregator/README.md
  • pm-stack/aggregator/src/config.ts
  • pm-stack/aggregator/src/server.ts
  • pm-stack/aggregator/src/stack-token.ts
  • pm-stack/aggregator/test/config.test.ts
  • pm-stack/aggregator/test/stack-token.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T06:09:33.619931Z a3edf32 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fb7cb0dc68

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +115 to +118
iat: raw.iat as number,
exp: raw.exp as number,
},
Math.floor(nowMs / 1000),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Require explicit timestamps when verifying stack tokens

For a correctly signed payload that omits iat and exp (or sets both to null), verification calls normalizeClaims, which substitutes the current verification time and a fresh five-minute expiry. Consequently, the same token verifies indefinitely instead of satisfying the bounded-lifetime contract; I confirmed that an unchanged signed token is accepted at verification times years apart. Keep timestamp defaults for minting, but require explicit integer timestamps in the signed payload before normalizing during verification.

Useful? React with 👍 / 👎.

@dezren39
dezren39 removed the request for review from a team November 23, 2026 05:55
Conflict resolution: pm-stack/aggregator/src/config.ts — keep both
additive fields (stackTokenSecret from this branch, breakGlassFile
from main, PR #12941).

Shepherd fixes (no re-implementation):
- stack-token.ts: verification now requires explicit iat/exp claims.
  normalizeClaims substitutes minting defaults for absent timestamps,
  which let a correctly signed timestamp-less token verify
  indefinitely (Codex P2 finding on this PR). Minting unchanged.
  Regression test added to test/stack-token.test.ts.
- server.ts: the stack-token exchange route treated only "" as
  unconfigured; cfg.stackTokenSecret is string | null, so an
  unconfigured secret slipped through to mintStackToken (TS2345,
  tsc --noEmit failed; runtime returned a misleading 400 instead of
  503). Guard is now !secret.

Verification: stack-token + config + break-glass suites 23 pass /
0 fail; tsc --noEmit clean; full aggregator suite 3042 pass / 20
fail with a failure set identical to a pristine-main baseline run
(all 20 pre-existing under load, incl. boot.test.ts).
@dezren39
dezren39 merged commit 3a8b55c into main Nov 23, 2026
1 check passed
@dezren39
dezren39 deleted the codex/20439-stack-token branch November 23, 2026 06:08
@dezren39

Copy link
Copy Markdown
Member Author

🤖 Agent note · Lane FW (archer) — shepherded to merge (queue task 21128).

Merged at 3a8b55c058b5. Main was merged into the branch (config.ts conflict: kept both additive fields), and the Codex P2 finding above is addressed: verifyStackToken now requires explicit iat/exp claims, with a regression test rejecting hand-signed timestamp-less tokens. One further defect found while verifying: the exchange route's unconfigured-secret guard missed the null case (string | null config) — tsc failed on it and the runtime path returned 400 instead of 503; guard is now !secret, tsc clean. Full-suite failure set verified identical to a pristine-main baseline (all pre-existing).

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