fix: Device Token Scope Escalation via Rotate Endpoint#20703
Merged
mbelinky merged 2 commits intoopenclaw:mainfrom Feb 20, 2026
Merged
fix: Device Token Scope Escalation via Rotate Endpoint#20703mbelinky merged 2 commits intoopenclaw:mainfrom
mbelinky merged 2 commits intoopenclaw:mainfrom
Conversation
arosstale
approved these changes
Feb 19, 2026
Contributor
arosstale
left a comment
There was a problem hiding this comment.
Solid security fix. The approvedScopes baseline in the pairing record is the right anchor — it captures what was authorised during the pairing ceremony and can't be escalated past by the device itself. expandScopeImplications is correct for normalising before comparison. One small note: rotateDeviceToken returning null on escalation attempt rather than throwing means callers can silently ignore escalation failures — the server-methods/devices.ts handler catches this with if (!entry) and responds with INVALID_REQUEST, which is fine. LGTM.
93e73eb to
4f2c2ec
Compare
Contributor
6 tasks
hughdidit
pushed a commit
to hughdidit/DAISy-Agency
that referenced
this pull request
Mar 1, 2026
Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 4f2c2ec Co-authored-by: coygeek <65363919+coygeek@users.noreply.github.com> Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com> Reviewed-by: @mbelinky (cherry picked from commit 914a7c5) # Conflicts: # CHANGELOG.md # src/infra/device-pairing.ts
hughdidit
pushed a commit
to hughdidit/DAISy-Agency
that referenced
this pull request
Mar 3, 2026
Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 4f2c2ec Co-authored-by: coygeek <65363919+coygeek@users.noreply.github.com> Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com> Reviewed-by: @mbelinky (cherry picked from commit 914a7c5) # Conflicts: # CHANGELOG.md # src/infra/device-pairing.test.ts # src/infra/device-pairing.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Summary
The
device.token.rotateendpoint allows an authenticated device to escalate its own scopes beyond what was originally approved during pairing, enabling privilege escalation from a limited device role to full admin access.Issue Linkage
Fixes #20702
Security Snapshot
Implementation Details
Files Changed
src/gateway/server-methods/devices.ts(+1/-1)src/infra/device-pairing.test.ts(+23/-2)src/infra/device-pairing.ts(+43/-6)Technical Analysis
The vulnerability is reachable through a production code path where untrusted input can influence security-sensitive behavior without sufficient invariant enforcement. Current evidence indicates impact consistent with the summary: The
device.token.rotateendpoint allows an authenticated device to escalate its own scopes beyond what was originally approved during pairing, enabling privilege escalation from a limited device role to full admin access.Validation Evidence
pnpm build && pnpm check && pnpm testRisk and Compatibility
non-breaking; no known regression impact
AI-Assisted Disclosure
Greptile Summary
Addresses device token scope escalation by introducing an
approvedScopesfield that preserves the originally approved scopes during device pairing and prevents unauthorized privilege escalation during token rotation.Key changes:
approvedScopesfield to track scopes approved at pairing time insrc/infra/device-pairing.ts:58rotateDeviceTokento validate requested scopes againstapprovedScopesusing scope implication logic insrc/infra/device-pairing.ts:542-547expandScopeImplicationsandscopesAllowWithImplicationshelpers to handle hierarchical scope relationships (e.g.,operator.adminimpliesoperator.read) insrc/infra/device-pairing.ts:170-190device.scopesmutation during rotation that previously allowed escalation insrc/infra/device-pairing.ts:555-558(removed lines)approvedScopesfrom modification viaupdatePairedDeviceMetadatainsrc/infra/device-pairing.ts:374andsrc/infra/device-pairing.ts:392approvedScopesfrom API responses to prevent information disclosure insrc/gateway/server-methods/devices.ts:27Confidence Score: 5/5
approvedScopesbaseline that cannot be modified after approval, (2) validating all rotation requests against this baseline with proper scope implication handling, (3) returning null instead of throwing on unauthorized escalation attempts to prevent state mutation, (4) protecting the security-sensitive field from external modification, and (5) comprehensive test coverage that validates both the vulnerability fix and legitimate down-scoping scenarios. The implementation follows security best practices by making the validation logic explicit, adding redaction to prevent information disclosure, and ensuring state remains unchanged when attacks are blocked.Last reviewed commit: 93e73eb