Skip to content

fix: trust only own entries in the session token store - #448

Merged
santoshyadavdev merged 1 commit into
mainfrom
santoshyadavdev-fix-devframe-token-prototype-auth
Nov 4, 2026
Merged

santoshyadavdev merged 1 commit into
mainfrom
santoshyadavdev-fix-devframe-token-prototype-auth

Conversation

@santoshyadavdev

Copy link
Copy Markdown
Collaborator

What and why

devframe's verifyAuthToken trusts a client when trusted[token] is truthy. The token store is an ordinary object, so a token such as constructor, __proto__ or toString matches an inherited property. Any client could become trusted, through the anonymous:devframe:auth handshake or the devframe_auth_token connection parameter, without the one-time code (CWE-287). devframe 1.3.2, the latest release, has the same check, so upgrading doesn't fix it, and a pnpm patch wouldn't reach apps that install our package.

The fix is in the published package. A new hardenTokenStore() in auth-store.ts runs when the server starts, from expireAuthTokens(), which the devframe's setup already calls for the hub, the Vite plugin and the CLI. It rebuilds trusted as an object with no prototype. It keeps only the entries stored on the object itself that are token records: an object with a numeric timestamp, and an authToken that matches the key when the record has one. devframe's storage (immer) keeps the null prototype on later copies, so code exchanges, revokes and pruning leave the store prototype-free.

How it was verified

  • pnpm commit:check (commit messages follow the guidelines): passed
  • pnpm format:check: not run in full. prettier --check on the changed files passed
  • pnpm typecheck (includes the ngc template checks): passed
  • pnpm test, pnpm test:devtools and pnpm test:panel: only pnpm test:devtools was run, and it passed (3648 passed, 4 skipped). pnpm test and pnpm test:panel were not run; this change doesn't touch app/
  • pnpm skills:check (when .claude/ changed): N/A
  • Docs in apps/docs updated and pnpm docs:build passes (when behavior, options, UI labels or agent tools changed), or the no-docs label added with the reason below: security.md updated; pnpm docs:build not run
  • pnpm extension:build and extension/ui committed (when app/ changed): N/A
  • Checked in the browser with axe (when the UI changed): N/A

New tests in auth-guard.test.ts:

  • A unit test for hardenTokenStore.
  • A hub test: the tokens constructor, __proto__, toString and hasOwnProperty are not trusted, and a token issued through the one-time code still reconnects. Without the fix this test fails.

Screenshots

N/A

Notes for reviewers

  • At startup the server now removes entries from auth.json that have no numeric timestamp, or whose authToken doesn't match their key. Records without an authToken field are kept.
  • The devframe client keeps its last connection on globalThis. The hub tests now clear it after each test so they don't affect each other.
  • The bug should also be reported to devframe so it's fixed there.

devframe's verifyAuthToken trusts a token when `trusted[token]` is
truthy. The store is an ordinary object, so inherited keys such as
`constructor` or `toString` pass as tokens, and any client could become
trusted through the auth handshake or the `devframe_auth_token`
connection parameter without the one-time code. devframe 1.3.2 has the
same check.

At startup the devframe's setup now rebuilds `trusted` as a
null-prototype object holding only own entries that are token records.
devframe's storage keeps the prototype on later copies, so exchanges,
revokes and pruning leave it prototype-free. This lives in the
published package, so apps that install it are covered without a
dependency patch.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

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 56 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: 2a0369b9-9393-4acb-8e1f-6401d8b486a2
Commits

Reviewing files that changed from the base of the PR and between e4ff5c8 and aa24b14.

Files selected for processing: 3
  • apps/docs/src/content/security.md
  • packages/devtools/src/__tests__/auth-guard.test.ts
  • packages/devtools/src/auth-store.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

@github-actions github-actions Bot added area: package The ng-devtools package (packages/ng-devtools) area: docs The documentation site labels Nov 4, 2026
@nx-cloud

nx-cloud Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit aa24b14

Command Status Duration Result
nx affected -t test build ✅ Succeeded 2m 31s View ↗
nx build --configuration development ✅ Succeeded 25s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-11-04 05:51:05 UTC

@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Failed ❌

View logs ↗
aa24b14 2026-11-04T05:50:03.580Z View logs ↗

@santoshyadavdev
santoshyadavdev merged commit 8103014 into main Nov 4, 2026
11 of 12 checks passed
@santoshyadavdev
santoshyadavdev deleted the santoshyadavdev-fix-devframe-token-prototype-auth branch November 4, 2026 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs The documentation site area: package The ng-devtools package (packages/ng-devtools)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant