Skip to content

fix(agents): skip sender-scoped tool policy when sender identity is absent - #109055

Closed
SunnyShu0925 wants to merge 7 commits into
openclaw:mainfrom
SunnyShu0925:fix/subagent-sender-tool-policy-109025
Closed

SunnyShu0925 wants to merge 7 commits into
openclaw:mainfrom
SunnyShu0925:fix/subagent-sender-tool-policy-109025

Conversation

@SunnyShu0925

@SunnyShu0925 SunnyShu0925 commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A spawned subagent loses tools granted by an exact toolsBySender sender override because its internal session has no sender identity and falls through to the wildcard "*" policy, silently stripping filesystem and runtime tools.

  • Problem: resolveSenderToolPolicy resolves sender-scoped tool policy in subagent sessions that have no sender identity, matching the wildcard "*" entry and stripping tools
  • Solution: Carry the parent's resolved senderPolicy into 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.
  • What changed:
    • src/agents/conversation-capability-profile.ts — read stored senderPolicy for subagent sessions
    • src/agents/subagent-capabilities.ts — resolveStoredSenderPolicy() + type fields
    • src/agents/spawned-context.ts — inheritedSenderPolicy in SpawnedToolContext
    • src/agents/subagent-spawn.ts — write to child store entry during spawn
    • src/agents/tools/sessions-spawn-tool.ts — forward through spawn chain
    • src/agents/openclaw-tools.ts — forward through spawn chain
    • src/agents/agent-tools.ts — capture parent's senderPolicy and pass to spawn context
    • src/config/sessions/types.ts — inheritedSenderPolicy in SessionEntry
    • src/agents/embedded-agent-runner/effective-tool-policy.test.ts — 5 integration scenarios
  • What did NOT change: sender-tool-policy.ts, spawn/session lifecycle, config schema

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Motivation

When a WhatsApp sender configured with an E164 toolsBySender override spawns a subagent via sessions_spawn, the subagent resolves its own tool policy. Because the spawned session has no sender identity (senderId/senderName/senderUsername/senderE164 are all null), resolveSenderToolPolicy calls resolveToolsBySender which 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 deny rule 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

  • Behavior addressed: spawned subagent re-resolves toolsBySender without sender identity, matching wildcard "*" and losing filesystem/runtime tools
  • Real environment tested: Linux, Node 22.22.3, fix/subagent-sender-tool-policy-109025
  • Exact steps or command run after this patch:
# Resolver-level proof: three scenarios
node scripts/run-vitest.mjs src/agents/proof-109025-sender-tool-policy.test.ts --run --reporter=verbose

# Full-pipeline integration proof: 5 scenarios covering allow, deny, subagent restrictions
node scripts/run-vitest.mjs src/agents/embedded-agent-runner/effective-tool-policy.test.ts --run --reporter=verbose
  • Resolver-level test output:
$ node scripts/run-vitest.mjs src/agents/proof-109025-sender-tool-policy.test.ts --run --reporter=verbose
 ✓ whatsapp parent with E164 identity gets exact allow override 10ms
 ✓ anonymous user without sender identity gets wildcard deny 1ms
 ✓ spawned subagent skips sender policy (isSubagentEnvelopeSession detected) 149ms

 Test Files  1 passed (1)
      Tests  3 passed (3)
  • Full-pipeline integration test output (store-backed inherited senderPolicy through resolveConversationCapabilityProfile → applyFinalEffectiveToolPolicy):
$ node scripts/run-vitest.mjs src/agents/embedded-agent-runner/effective-tool-policy.test.ts --run --reporter=verbose
 ✓ fix #109025: parent with E164 gets exact toolsBySender allow (no denies) 177ms
 ✓ fix #109025: anonymous user without sender identity gets wildcard deny 173ms
 ✓ fix #109025: subagent inherits parent allow policy via stored senderPolicy 195ms
 ✓ fix #109025: subagent restrictions still narrow tools after inheritance 196ms
 ✓ fix #109025: subagent inherits parent deny ceiling — no privilege escalation 199ms

 Tests  17 passed (17)  (12 existing + 5 new)
  • Observed result after fix:
    1. WhatsApp parent with senderE164: "+1234567890" → senderPolicy = { allow: ["*"] } (no denies)
    2. Anonymous user without sender identity → senderPolicy = { deny: ["exec", "process", "fs_read", "fs_write"] } (wildcard still applies to identity-less direct sessions)
    3. Spawned subagent (no sender fields) with stored inheritedSenderPolicy: { allow: ["*"] } → wildcard deny not applied, all tools retained
    4. Spawned subagent with stored inheritedSenderPolicy: { allow: ["*"] } + configured subagents.tools.deny: ["fs_write"] → subagent restriction layer still removes intended tools after sender-policy inheritance
    5. Spawned subagent with stored inheritedSenderPolicy: { deny: ["exec", "fs_read"] } → parent's deny ceiling preserved, child cannot regain denied tools
  • What was not tested: WhatsApp/Telegram E2E with real toolsBySender config (requires real channel credentials)
  • Fix completeness pre-check (4 questions):
    • ✅ Auth guard: stored policy is only read for recognized subagent envelopes; identity-less direct sessions still get the wildcard
    • ✅ Enum completeness: all subagent session shapes (native + ACP) are covered by envelope detection
    • ✅ Path coverage: the read sits in resolveConversationCapabilityProfile, the write flows through the spawn chain — all capability resolution callers are covered
    • ✅ Cleanup symmetry: no state to clean up — pre-existing sessions without a stored policy fall back to undefined safely

Root Cause

resolveSenderToolPolicy → resolveToolsBySender → matchToolsBySenderPolicy falls through all exact sender matchers and returns compiled.wildcard when no sender field matches. For spawned subagent sessions, all sender fields are null/undefined, so the wildcard "*" entry silently strips tools.

  • Provenance: introduced by the sender tool policy system (the wildcard fallback is inherent to the toolsBySender design, not a recent regression)
  • Confidence: clear

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 inheritedSenderPolicy pattern used by all 3 subagent integration tests — the same mechanism used at runtime.

User-visible / Behavior Changes

Subagent sessions spawned with sessions_spawn from 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

  • New permissions/capabilities? No — stored policy ceiling preserves the parent's exact allow/deny boundary
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Human Verification

  • Verified scenarios: 5 scenarios covering parent exact allow, anonymous wildcard deny, subagent inherited allow, subagent + restrictions, subagent inherited deny ceiling
  • Full-pipeline proof: integration tests use store-backed inheritedSenderPolicy — the same persistence mechanism used in the production spawn chain
  • Edge cases checked: session detected by isSubagentEnvelopeSession vs anonymous session; subagent with spawnedBy set; subagent restrictions applied on top of inherited sender policy; exact deny ceiling cannot be escalated by subagent spawn
  • What you did NOT verify: real WhatsApp E2E with toolsBySender config (requires channel credentials)

Compatibility / Migration

  • Backward compatible? Yes — sessions with sender identity are unaffected; pre-existing subagent sessions without stored policy fall back to undefined safely
  • Config/env changes? No
  • Migration needed? No

Best-fix Verdict

  • Best fix: Yes. Carrying the resolved senderPolicy through the existing spawn store mechanism preserves the complete authorization ceiling (both allow and deny) without widening the trust boundary.
  • Refactor needed: No
  • Alternative considered: Blindly setting senderPolicy = undefined for 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/inheritedToolDeny mechanism), 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 to undefined, which is safe because the parent already resolved the correct policy during its turn.


Fixes #109025

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Jul 16, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 16, 2026
@clawsweeper

clawsweeper Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 10:24 PM ET / July 18, 2026, 02:24 UTC.

Summary
The branch persists a parent’s resolved sender tool policy in spawned-session metadata and uses it when resolving a recognized subagent’s capability profile.

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 inheritedSenderPolicy. This review did not execute the runtime path.

Review metrics: 1 noteworthy metric.

  • Persisted policy surface: 1 session-store field added. The new inheritedSenderPolicy field changes upgrade behavior for previously persisted spawned-session entries.

Stored data model
Persistent data-model change detected: serialized state: src/agents/tools/sessions-spawn-tool.ts, serialized state: src/config/sessions/types.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #109025
Summary: This PR is the candidate implementation for the open report; it addresses the same sender-policy loss during spawned-subagent capability resolution.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🦐 gold shrimp
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Retain the normal sender-policy path when legacy child metadata is absent.
  • [P1] Add a regression case for a resumed pre-upgrade subagent session.
  • [P1] Post redacted runtime output from a real restrictive-policy sessions_spawn flow, then request re-review if needed.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The body includes focused test output but no redacted real sessions_spawn run showing parent and child effective tool inventories under a restrictive sender policy; add live output or runtime logs and redact private details before posting. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] An upgrade can resume a recognized subagent session without inheritedSenderPolicy; the branch then removes the wildcard sender-policy restriction and may restore tools that the requester policy previously denied.
  • [P1] The supplied evidence is test-only, so it does not demonstrate that the real sessions_spawn path persists and restores the policy correctly without affecting direct anonymous sessions.

Maintainer options:

  1. Preserve legacy-session restrictions (recommended)
    Fall back to the existing resolveSenderToolPolicy result when a recognized subagent has no valid stored inherited policy, then cover the upgrade/resume case.
  2. Accept the changed trust boundary
    Merge only if maintainers explicitly intend old persisted subagent sessions to lose wildcard sender-policy restrictions after upgrade.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Fall back to `resolveSenderToolPolicy` for recognized subagent sessions whose stored `inheritedSenderPolicy` is absent or invalid, and add an upgrade-resume regression test.

Next step before merge

  • [P1] A narrow code repair can preserve the existing sender-policy ceiling for legacy persisted children; contributor-supplied real behavior proof remains required after the repair.

Security
Needs attention: The persisted-policy fallback can weaken a configured sender tool restriction for legacy resumed subagent sessions.

Review findings

  • [P1] Retain sender policy for legacy subagent sessions — src/agents/conversation-capability-profile.ts:238-248
Review details

Best 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 inheritedSenderPolicy. This review did not execute the runtime path.

Is this the best way to solve the issue?

No: persisting the parent policy is the right direction, but using undefined for legacy stored sessions is not safe because it removes the current restriction instead of preserving it.

Full review comments:

  • [P1] Retain sender policy for legacy subagent sessions — src/agents/conversation-capability-profile.ts:238-248
    resolveStoredSenderPolicy returns undefined for a recognized child session created before this metadata existed. Because this branch selects that result instead of the existing resolver, upgrading can remove a wildcard toolsBySender deny ceiling and re-enable tools for a resumed child. Fall back to normal sender-policy resolution when no valid inherited policy is stored, and add an upgrade/resume case.
    Confidence: 0.94

Overall correctness: patch is incorrect
Overall confidence: 0.91

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model internal, reasoning high; reviewed against 1746cea939fe.

Label changes

Label changes:

  • add merge-risk: 🚨 compatibility: Existing persisted spawned-session entries lack the new metadata and take a different effective-policy path after upgrade.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.

Label justifications:

  • P1: The branch can lift a requester-configured tool restriction for resumed subagent sessions after upgrade.
  • merge-risk: 🚨 compatibility: Existing persisted spawned-session entries lack the new metadata and take a different effective-policy path after upgrade.
  • merge-risk: 🚨 security-boundary: An absent stored value currently changes a configured sender tool ceiling into no sender-policy restriction.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The body includes focused test output but no redacted real sessions_spawn run showing parent and child effective tool inventories under a restrictive sender policy; add live output or runtime logs and redact private details before posting. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +66, Tests +281. Total +347 across 10 files.

View PR surface stats
Area Files Added Removed Net
Source 8 88 22 +66
Tests 2 282 1 +281
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 10 370 23 +347

Security concerns:

  • [high] Legacy session entries bypass the sender-policy ceiling — src/agents/conversation-capability-profile.ts:238
    Recognized subagent sessions without the newly persisted policy resolve to undefined, which can remove wildcard restrictions that current code applies to identity-less children.
    Confidence: 0.94

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/agents/embedded-agent-runner/effective-tool-policy.test.ts --run.
  • [P1] node scripts/run-vitest.mjs src/agents/proof-109025-sender-tool-policy.test.ts --run.

What I checked:

  • Current policy boundary: Current main resolves sender-scoped tool policy from the conversation sender fields; the reported defect occurs when a spawned child has no identity and matches the wildcard rule. (src/agents/conversation-capability-profile.ts:212, 1746cea939fe)
  • Upgrade security regression: The branch changes recognized subagent sessions to read inheritedSenderPolicy; resolveStoredSenderPolicy returns undefined when an existing session entry predates the new field, removing the sender-policy restriction instead of retaining the current wildcard fallback. (src/agents/conversation-capability-profile.ts:238, 68ab9f2f8b96)
  • Persisted-session dependency: The new field is written only during the new spawn path, so pre-existing persisted child entries cannot supply it after an upgrade. (src/agents/subagent-spawn.ts:316, 68ab9f2f8b96)
  • Prior review continuity: The latest prior review required preservation of the requester sender-policy ceiling. The current head carries a policy for new children, but the absent-value fallback still leaves resumed legacy children without that ceiling. (src/agents/subagent-capabilities.ts:386, 68ab9f2f8b96)
  • Real-behavior proof: The PR body provides focused Vitest output only; it does not show an after-fix live spawn with a restrictive toolsBySender configuration and the resulting parent/child inventories. (68ab9f2f8b96)

Likely related people:

  • SunnyShu0925: Authored the current policy-propagation implementation and the focused coverage; current-main feature-history ownership could not be confirmed because the repository read sandbox failed before local history inspection. (role: current repair author; confidence: medium; commits: 68ab9f2f8b96; files: src/agents/conversation-capability-profile.ts, src/agents/subagent-capabilities.ts, src/agents/subagent-spawn.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (6 earlier review cycles)
  • reviewed 2026-07-16T14:46:49.307Z sha 897db633f753f0c496e4b1bd605903e494b78421 :: needs real behavior proof before merge. :: [P1] Restrict the bypass to recognized inherited-policy sessions
  • reviewed 2026-07-16T16:55:32.374Z sha cbe2da5 :: needs real behavior proof before merge. :: [P1] Preserve the requester’s sender-policy ceiling
  • reviewed 2026-07-16T17:35:43.874Z sha cbe2da5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-18T01:35:37.340Z sha 049b6d0 :: needs real behavior proof before merge. :: [P1] Preserve the requester’s sender-policy ceiling
  • reviewed 2026-07-18T01:50:07.049Z sha 673cc5c :: needs real behavior proof before merge. :: [P1] Preserve the requester’s sender-policy ceiling
  • reviewed 2026-07-18T01:55:11.310Z sha 673cc5c :: needs real behavior proof before merge. :: [P1] Preserve the requester’s sender-policy ceiling

@SunnyShu0925
SunnyShu0925 force-pushed the fix/subagent-sender-tool-policy-109025 branch 2 times, most recently from 8914e8c to 4118735 Compare July 16, 2026 16:36
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]>
@SunnyShu0925
SunnyShu0925 force-pushed the fix/subagent-sender-tool-policy-109025 branch from 4118735 to cbe2da5 Compare July 16, 2026 16:47
…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
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
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
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Jul 18, 2026
…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.
@SunnyShu0925

Copy link
Copy Markdown
Contributor Author

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).

@joshavant

Copy link
Copy Markdown
Collaborator

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 main in 3372088.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Subagent loses sender-scoped tool authorization

2 participants