Repository navigation
fix(gateway): derive loopback owner context from token - #69796
Conversation
Greptile SummaryThis PR closes a privilege-escalation vulnerability where a non-owner ACP child process could forge Confidence Score: 5/5Safe to merge — the security fix is correctly implemented with no P0/P1 findings. All remaining findings are P2 style/documentation suggestions. The core security change is sound: server-side token derivation replaces header trust, tokens are cryptographically random and constant-time compared, and the mutable owner header is removed from all outbound config and request paths. No files require special attention beyond the two minor P2 style notes in mcp-http.loopback-runtime.ts and prepare.ts. Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/gateway/mcp-http.loopback-runtime.ts
Line: 24-28
Comment:
**`clearActiveMcpLoopbackRuntime` silently accepts either token**
The function now matches on both `ownerToken` and `nonOwnerToken`, but the only call-site always passes `ownerToken`. The `|| activeRuntime?.nonOwnerToken === token` branch is therefore dead code today. More importantly, if a future caller mistakenly passes `nonOwnerToken`, it would still clear the runtime — which is probably intentional, but the function name and signature give no hint that either token is a valid handle. Consider documenting the intent or tightening the parameter type to prevent misuse.
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/agents/cli-runner/prepare.ts
Line: 167-179
Comment:
**Minor indentation inconsistency in ternary**
The `?` operator was moved from 6-space to 8-space indent while the object body and the closing `}: undefined` stayed at 6 spaces, producing a misaligned ternary. Not a correctness issue, but worth a quick autoformat pass to keep the diff clean.
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fix(gateway): derive loopback owner cont..." | Re-trigger Greptile |
0435deb to
1f1a6aa
Compare
* fix(gateway): derive loopback owner context from token * docs(changelog): note loopback owner token hardening * refactor(gateway): clarify loopback runtime cleanup * fix(gateway): compare both loopback bearer classes (cherry picked from commit 3cb1a56)
* fix(gateway): derive loopback owner context from token * docs(changelog): note loopback owner token hardening * refactor(gateway): clarify loopback runtime cleanup * fix(gateway): compare both loopback bearer classes
* fix(gateway): derive loopback owner context from token * docs(changelog): note loopback owner token hardening * refactor(gateway): clarify loopback runtime cleanup * fix(gateway): compare both loopback bearer classes
* fix(gateway): derive loopback owner context from token * docs(changelog): note loopback owner token hardening * refactor(gateway): clarify loopback runtime cleanup * fix(gateway): compare both loopback bearer classes
* fix(gateway): derive loopback owner context from token * docs(changelog): note loopback owner token hardening * refactor(gateway): clarify loopback runtime cleanup * fix(gateway): compare both loopback bearer classes
* fix(gateway): derive loopback owner context from token * docs(changelog): note loopback owner token hardening * refactor(gateway): clarify loopback runtime cleanup * fix(gateway): compare both loopback bearer classes
* fix(gateway): derive loopback owner context from token * docs(changelog): note loopback owner token hardening * refactor(gateway): clarify loopback runtime cleanup * fix(gateway): compare both loopback bearer classes
* fix(gateway): derive loopback owner context from token * docs(changelog): note loopback owner token hardening * refactor(gateway): clarify loopback runtime cleanup * fix(gateway): compare both loopback bearer classes
* fix(gateway): derive loopback owner context from token * docs(changelog): note loopback owner token hardening * refactor(gateway): clarify loopback runtime cleanup * fix(gateway): compare both loopback bearer classes
* fix(gateway): derive loopback owner context from token * docs(changelog): note loopback owner token hardening * refactor(gateway): clarify loopback runtime cleanup * fix(gateway): compare both loopback bearer classes
fix(gateway): derive loopback owner context from token
Summary
Describe the problem and fix in 2–5 bullets:
gateway,cron, andnodescould be exposed to non-owner ACP child processes.senderIsOwnerfrom the authenticated bearer, and stops exporting the mutable owner header.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
NVIDIA-dev/openclaw-tracking)Root Cause (if applicable)
For bug fixes or regressions, explain why this happened, not just what changed. Otherwise write
N/A. If the cause is unclear, writeUnknown.resolveMcpRequestContexttrustedx-openclaw-sender-is-owner, and the CLI runner exported that value into child-process environment state, so authorization depended on attacker-mutable client input instead of server-side auth state.Regression Test Plan (if applicable)
For bug fixes or regressions, name the smallest reliable test coverage that should catch this. Otherwise write
N/A.src/gateway/mcp-http.test.tsandsrc/agents/cli-runner/bundle-mcp.test.tsUser-visible / Behavior Changes
Diagram (if applicable)
Security Impact (required)
No)Yes)No)Yes)No)Yes, explain risk + mitigation: loopback token handling now splits owner and non-owner callers into separate bearer scopes so request headers can no longer elevate tool visibility; the exposed tool surface is reduced for non-owner callers rather than expanded.Repro + Verification
Environment
Linux 6.8.0-110-generic #110-Ubuntu SMP PREEMPT_DYNAMIC Thu Mar 19 15:09:20 UTC 2026 x86_64 GNU/Linux<operator to fill>fix-mcp-owner-authSteps
tools/listrequest with the non-owner bearer while spoofingx-openclaw-sender-is-owner: true.Expected
Actual
senderIsOwnerfrom the bearer token and ignores spoofed owner headers.OPENCLAW_MCP_SENDER_IS_OWNER.Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
Review Conversations
If a bot review conversation is addressed by this PR, resolve that conversation yourself. Do not leave bot review conversation cleanup for maintainers.
Compatibility / Migration
Yes)No)No)Risks and Mitigations
senderIsOwnerinstead of exporting a mutable owner header.