Repository navigation
fix(agents): skip sender-scoped tool policy when sender identity is absent - #109055
SunnyShu0925 wants to merge 7 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 10:24 PM ET / July 18, 2026, 02:24 UTC. Summary PR surface: Source +66, Tests +281. Total +347 across 10 files. Reproducibility: yes. source-reproducible: configure an exact sender override plus restrictive wildcard, then resolve a recognized persisted child session that lacks Review metrics: 1 noteworthy metric.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Copy recommended automerge instructionNext step before merge
Security Review findings
Review detailsBest possible solution: Use the inherited policy only when a recognized child has a valid stored value; otherwise retain the existing sender-policy resolution, add an upgrade-resume regression case, and provide redacted live spawn output before merging. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: configure an exact sender override plus restrictive wildcard, then resolve a recognized persisted child session that lacks Is this the best way to solve the issue? No: persisting the parent policy is the right direction, but using Full review comments:
Overall correctness: patch is incorrect AGENTS.md: unclear because the file could not be read completely. Codex review notes: model internal, reasoning high; reviewed against 1746cea939fe. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +66, Tests +281. Total +347 across 10 files. View PR surface stats
Security concerns:
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (6 earlier review cycles)
|
8914e8c to
4118735
Compare
A spawned subagent has no sender identity, so resolveSenderToolPolicy falls through the exact toolsBySender matchers and returns the wildcard "*" policy, silently stripping filesystem and runtime tools from identity-less subagent sessions. Fix: detect subagent sessions in conversation-capability-profile.ts via isSubagentEnvelopeSession and skip sender-scoped tool policy resolution, similar to how owner WebChat sessions already skip it. The subagent inherits the parent's already-resolved tool policy instead. Related to openclaw#109025 Co-Authored-By: Claude <[email protected]>
4118735 to
cbe2da5
Compare
…subagent sender-policy fix Add four integration tests using the applyFinalPolicy helper to demonstrate the full effective-tool-policy pipeline for the subagent sender-policy fix: 1. Parent with E164 identity -> exact toolsBySender allow (no denies) 2. Anonymous user without sender -> wildcard deny strips fs/runtime tools 3. Spawned subagent skips sender policy -> retains parent tools 4. Subagent restrictions still narrow tools after sender-policy skip
…#109025 subagent sender-policy fix
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Instead of skipping sender-policy resolution entirely for recognized subagent sessions, store the parent's resolved senderPolicy in the child's session store entry during spawn and read it back when resolving the child's capability profile. This preserves both allow AND deny ceilings. Write path (spawn chain): - agent-tools.ts captures senderPolicy from parent's capability profile - Passed through SpawnedToolContext -> createSessionsSpawnTool -> spawnSubagentDirect -> written as inheritedSenderPolicy in child's session store entry via buildDirectChildSessionPatch Read path (child resolution): - resolveConversationCapabilityProfile reads stored inheritedSenderPolicy via resolveStoredSenderPolicy when isSubagentSession is detected - Falls back to undefined when no stored policy (pre-existing sessions) Files changed: - subagent-capabilities.ts: resolveStoredSenderPolicy() + type fields - conversation-capability-profile.ts: use stored policy for subagents - spawned-context.ts: inheritedSenderPolicy in SpawnedToolContext - subagent-spawn.ts: add to context + buildDirectChildSessionPatch - sessions-spawn-tool.ts: forward inheritedSenderPolicy - openclaw-tools.ts: forward inheritedSenderPolicy - agent-tools.ts: capture senderPolicy and pass to spawn context - config/sessions/types.ts: inheritedSenderPolicy in SessionEntry - effective-tool-policy.test.ts: 5 scenarios covering allow, deny, subagent restrictions, and authorization ceiling preservation
…t sessions When a subagent session has no stored inheritedSenderPolicy (pre-upgrade), fall back to resolveSenderToolPolicy instead of returning undefined. This preserves the wildcard deny behavior for legacy sessions, preventing a silent permission escalation on upgrade. Also updated the proof test to use a realistic store-backed scenario instead of passing senderE164 directly to the subagent, and added a dedicated upgrade-compat integration test.
|
Closing in favor of #110345 from @joshavant, which addresses the same issue with a more complete approach (centralized requester-tool-policy resolver covering both sessions_spawn and requester-agent handoff, with real Testbox E2E proof). |
|
Thanks @SunnyShu0925 for submitting this implementation and iterating on the authorization and legacy-session concerns. This PR correctly identified the wildcard fallback root cause, the need to preserve both allow and deny ceilings, and the importance of failing closed for pre-upgrade sessions. The alternative implementation in #110345 has now landed on We selected #110345 because it moved requester-policy handling into one canonical resolver shared by subagent execution, completion fallback, Gateway tool resolution, skills, web search, compaction, and Codex dynamic tools. It also added an explicit version marker for persisted snapshots, verified completion lineage, and live Gateway/Testbox E2E proof. This is not a rejection of the core approach proposed here: the landed fix retains the important idea of carrying a trusted effective policy projection into delegated work, but applies it at the broader requester-policy boundary. Closing out #109055 as superseded by the merged fix. Thank you for the investigation, implementation, and security-focused follow-up. |
What Problem This Solves
A spawned subagent loses tools granted by an exact
toolsBySendersender override because its internal session has no sender identity and falls through to the wildcard"*"policy, silently stripping filesystem and runtime tools.resolveSenderToolPolicyresolves sender-scoped tool policy in subagent sessions that have no sender identity, matching the wildcard"*"entry and stripping toolssenderPolicyinto the child's session store entry during spawn (inheritedSenderPolicy), then read it back when resolving the child's capability profile. This preserves both allow AND deny ceilings, preventing either wildcard stripping OR privilege escalation.src/agents/conversation-capability-profile.ts— read stored senderPolicy for subagent sessionssrc/agents/subagent-capabilities.ts—resolveStoredSenderPolicy()+ type fieldssrc/agents/spawned-context.ts—inheritedSenderPolicyinSpawnedToolContextsrc/agents/subagent-spawn.ts— write to child store entry during spawnsrc/agents/tools/sessions-spawn-tool.ts— forward through spawn chainsrc/agents/openclaw-tools.ts— forward through spawn chainsrc/agents/agent-tools.ts— capture parent's senderPolicy and pass to spawn contextsrc/config/sessions/types.ts—inheritedSenderPolicyinSessionEntrysrc/agents/embedded-agent-runner/effective-tool-policy.test.ts— 5 integration scenariossender-tool-policy.ts, spawn/session lifecycle, config schemaChange Type (select all)
Scope (select all)
Linked Issue/PR
Motivation
When a WhatsApp sender configured with an E164
toolsBySenderoverride spawns a subagent viasessions_spawn, the subagent resolves its own tool policy. Because the spawned session has no sender identity (senderId/senderName/senderUsername/senderE164are all null),resolveSenderToolPolicycallsresolveToolsBySenderwhich falls through all exact sender matchers and returns the wildcard"*"entry. This strips filesystem and runtime tools from the subagent, leaving only generic tools.A naive fix that simply skips sender-policy resolution for subagents would introduce an authorization bypass: a requester with an exact
denyrule could spawn a child that regains the denied tools.The correct fix carries the parent's resolved
senderPolicy(both allow and deny) into the child session store during spawn, preserving the authorization ceiling.Evidence
toolsBySenderwithout sender identity, matching wildcard"*"and losing filesystem/runtime toolsfix/subagent-sender-tool-policy-109025resolveConversationCapabilityProfile→applyFinalEffectiveToolPolicy):senderE164: "+1234567890"→senderPolicy = { allow: ["*"] }(no denies)senderPolicy = { deny: ["exec", "process", "fs_read", "fs_write"] }(wildcard still applies to identity-less direct sessions)inheritedSenderPolicy: { allow: ["*"] }→ wildcard deny not applied, all tools retainedinheritedSenderPolicy: { allow: ["*"] }+ configuredsubagents.tools.deny: ["fs_write"]→ subagent restriction layer still removes intended tools after sender-policy inheritanceinheritedSenderPolicy: { deny: ["exec", "fs_read"] }→ parent's deny ceiling preserved, child cannot regain denied toolstoolsBySenderconfig (requires real channel credentials)resolveConversationCapabilityProfile, the write flows through the spawn chain — all capability resolution callers are coveredundefinedsafelyRoot Cause
resolveSenderToolPolicy→resolveToolsBySender→matchToolsBySenderPolicyfalls through all exact sender matchers and returnscompiled.wildcardwhen no sender field matches. For spawned subagent sessions, all sender fields are null/undefined, so the wildcard"*"entry silently strips tools.introduced bythe sender tool policy system (the wildcard fallback is inherent to thetoolsBySenderdesign, not a recent regression)Regression Test Plan
The fix is validated by two test files running
30 tests total:proof-109025-sender-tool-policy.test.ts— 3 resolver-level scenarios (parent, anonymous, subagent detection)effective-tool-policy.test.ts— 5 integration scenarios through the full pipeline (parent allow, anonymous deny, subagent inherited allow, subagent + restrictions, subagent inherited deny ceiling)conversation-capability-profile.test.ts— 13 tests (unchanged, all pass)The production spawn chain is tested through the store-backed
inheritedSenderPolicypattern used by all 3 subagent integration tests — the same mechanism used at runtime.User-visible / Behavior Changes
Subagent sessions spawned with
sessions_spawnfrom a sender-trusted conversation will now retain filesystem and runtime tools instead of having them stripped by the wildcard sender policy, while still respecting any configured sender-level denies.Security Impact
All checkboxes must be checked or explained
Human Verification
inheritedSenderPolicy— the same persistence mechanism used in the production spawn chainisSubagentEnvelopeSessionvs anonymous session; subagent withspawnedByset; subagent restrictions applied on top of inherited sender policy; exact deny ceiling cannot be escalated by subagent spawntoolsBySenderconfig (requires channel credentials)Compatibility / Migration
undefinedsafelyBest-fix Verdict
senderPolicy = undefinedfor all subagents was rejected because it loses exact sender denies (authorization bypass). Resolving sender policy from sender fields in subagent params was rejected because subagents realistically have no sender fields.AI Assistance 🤖
Risks and Mitigations
Low risk: The stored sender policy is only written during spawn (matching the existing
inheritedToolAllow/inheritedToolDenymechanism), and only read for recognized subagent sessions. Anonymous direct sessions and WebChat users without sender identity continue to get the wildcard deny policy. Pre-existing subagent sessions without a stored policy fall back toundefined, which is safe because the parent already resolved the correct policy during its turn.Fixes #109025