Repository navigation
Skills: apply tool policy to direct slash dispatch - #46793
vincentkoc wants to merge 3 commits into
Conversation
Greptile SummaryThis PR fixes a security gap where direct Key changes:
Confidence Score: 4/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/auto-reply/reply/get-reply-inline-actions.tool-policy.test.ts
Line: 117-133
Comment:
**Missing positive-path and owner-gate test cases**
The suite only exercises the "denied by config" path. Two important scenarios are left uncovered:
1. **Allowed tool is actually executed** — without a test asserting that a non-denied tool reaches `execute`, a future regression that accidentally blocks _all_ tools in this path would be invisible to this suite.
2. **Owner-only gate still blocks non-owners** — the PR description states "the existing owner-only filter still runs before the full pipeline", but there is no assertion for it. Passing `senderIsOwner: false` for a tool marked `ownerOnly: true` should still block execution regardless of the `cfg.tools.deny` config.
Consider adding:
```typescript
it("executes an allowed tool through direct /skill dispatch", async () => {
const input = createInput();
// Override command so it targets the non-denied 'read' tool
(input.skillCommands as SkillCommandSpec[]) = [
{
name: "read-skill",
skillName: "read-skill",
description: "Allowed direct tool dispatch",
dispatch: { kind: "tool", toolName: "read" },
},
];
(input.command as any).rawBodyNormalized = "/read-skill test";
(input.command as any).commandBodyNormalized = "/read-skill test";
readExecuteMock.mockResolvedValue({ content: "OK" });
const result = await handleInlineActions({ ...input, cleanedBody: "/read-skill test" });
expect(result).toEqual({ kind: "reply", reply: { text: "OK" } });
expect(readExecuteMock).toHaveBeenCalled();
});
```
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/auto-reply/reply/get-reply-inline-actions.ts
Line: 129-144
Comment:
**`agentId` destructured name shadows the outer parameter**
`resolveEffectiveToolPolicy` returns an `agentId` field (the normalized/resolved agent ID) which is destructured on this line using the same name as `params.agentId`. This silent shadow means any reader of the function body below this block cannot easily tell which `agentId` is active.
Consider renaming the destructured binding to `resolvedAgentId` (and updating its single usage in `buildDefaultToolPolicyPipelineSteps`) to make the distinction explicit and match the naming convention already used elsewhere for resolved values in this file.
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 6b47a95 |
| describe("handleInlineActions skill tool dispatch", () => { | ||
| beforeEach(() => { | ||
| handleCommandsMock.mockReset(); | ||
| gatewayExecuteMock.mockReset().mockResolvedValue({ content: "EXECUTED" }); | ||
| readExecuteMock.mockReset().mockResolvedValue({ content: "READ" }); | ||
| }); | ||
|
|
||
| it("applies the tool policy pipeline before direct /skill tool execution", async () => { | ||
| const result = await handleInlineActions(createInput()); | ||
|
|
||
| expect(result).toEqual({ | ||
| kind: "reply", | ||
| reply: { text: "❌ Tool not available: gateway" }, | ||
| }); | ||
| expect(gatewayExecuteMock).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Missing positive-path and owner-gate test cases
The suite only exercises the "denied by config" path. Two important scenarios are left uncovered:
- Allowed tool is actually executed — without a test asserting that a non-denied tool reaches
execute, a future regression that accidentally blocks all tools in this path would be invisible to this suite. - Owner-only gate still blocks non-owners — the PR description states "the existing owner-only filter still runs before the full pipeline", but there is no assertion for it. Passing
senderIsOwner: falsefor a tool markedownerOnly: trueshould still block execution regardless of thecfg.tools.denyconfig.
Consider adding:
it("executes an allowed tool through direct /skill dispatch", async () => {
const input = createInput();
// Override command so it targets the non-denied 'read' tool
(input.skillCommands as SkillCommandSpec[]) = [
{
name: "read-skill",
skillName: "read-skill",
description: "Allowed direct tool dispatch",
dispatch: { kind: "tool", toolName: "read" },
},
];
(input.command as any).rawBodyNormalized = "/read-skill test";
(input.command as any).commandBodyNormalized = "/read-skill test";
readExecuteMock.mockResolvedValue({ content: "OK" });
const result = await handleInlineActions({ ...input, cleanedBody: "/read-skill test" });
expect(result).toEqual({ kind: "reply", reply: { text: "OK" } });
expect(readExecuteMock).toHaveBeenCalled();
});Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/get-reply-inline-actions.tool-policy.test.ts
Line: 117-133
Comment:
**Missing positive-path and owner-gate test cases**
The suite only exercises the "denied by config" path. Two important scenarios are left uncovered:
1. **Allowed tool is actually executed** — without a test asserting that a non-denied tool reaches `execute`, a future regression that accidentally blocks _all_ tools in this path would be invisible to this suite.
2. **Owner-only gate still blocks non-owners** — the PR description states "the existing owner-only filter still runs before the full pipeline", but there is no assertion for it. Passing `senderIsOwner: false` for a tool marked `ownerOnly: true` should still block execution regardless of the `cfg.tools.deny` config.
Consider adding:
```typescript
it("executes an allowed tool through direct /skill dispatch", async () => {
const input = createInput();
// Override command so it targets the non-denied 'read' tool
(input.skillCommands as SkillCommandSpec[]) = [
{
name: "read-skill",
skillName: "read-skill",
description: "Allowed direct tool dispatch",
dispatch: { kind: "tool", toolName: "read" },
},
];
(input.command as any).rawBodyNormalized = "/read-skill test";
(input.command as any).commandBodyNormalized = "/read-skill test";
readExecuteMock.mockResolvedValue({ content: "OK" });
const result = await handleInlineActions({ ...input, cleanedBody: "/read-skill test" });
expect(result).toEqual({ kind: "reply", reply: { text: "OK" } });
expect(readExecuteMock).toHaveBeenCalled();
});
```
How can I resolve this? If you propose a fix, please make it concise.| const { | ||
| agentId, | ||
| globalPolicy, | ||
| globalProviderPolicy, | ||
| agentPolicy, | ||
| agentProviderPolicy, | ||
| profile, | ||
| providerProfile, | ||
| profileAlsoAllow, | ||
| providerProfileAlsoAllow, | ||
| } = resolveEffectiveToolPolicy({ | ||
| config: params.cfg, | ||
| sessionKey: params.sessionKey, | ||
| agentId: params.agentId, | ||
| modelProvider: params.provider, | ||
| }); |
There was a problem hiding this comment.
agentId destructured name shadows the outer parameter
resolveEffectiveToolPolicy returns an agentId field (the normalized/resolved agent ID) which is destructured on this line using the same name as params.agentId. This silent shadow means any reader of the function body below this block cannot easily tell which agentId is active.
Consider renaming the destructured binding to resolvedAgentId (and updating its single usage in buildDefaultToolPolicyPipelineSteps) to make the distinction explicit and match the naming convention already used elsewhere for resolved values in this file.
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/auto-reply/reply/get-reply-inline-actions.ts
Line: 129-144
Comment:
**`agentId` destructured name shadows the outer parameter**
`resolveEffectiveToolPolicy` returns an `agentId` field (the normalized/resolved agent ID) which is destructured on this line using the same name as `params.agentId`. This silent shadow means any reader of the function body below this block cannot easily tell which `agentId` is active.
Consider renaming the destructured binding to `resolvedAgentId` (and updating its single usage in `buildDefaultToolPolicyPipelineSteps`) to make the distinction explicit and match the naming convention already used elsewhere for resolved values in this file.
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6b47a95c6f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } = resolveEffectiveToolPolicy({ | ||
| config: params.cfg, | ||
| sessionKey: params.sessionKey, | ||
| agentId: params.agentId, | ||
| modelProvider: params.provider, | ||
| }); |
There was a problem hiding this comment.
Pass model ID into inline tool policy resolution
The direct /skill path resolves policies with modelProvider only, so model-scoped entries in tools.byProvider (for example openai/gpt-4o) never match in this flow. In configurations that rely on model-specific allow/deny rules, inline dispatch can still expose or execute tools that should be blocked; this should pass the selected model ID into resolveEffectiveToolPolicy to match normal tool-execution policy behavior.
Useful? React with 👍 / 👎.
| return applyToolPolicyPipeline({ | ||
| tools: toolsByAuthorization, | ||
| toolMeta: (tool) => getPluginToolMeta(tool), |
There was a problem hiding this comment.
Avoid stripping allowlists against a reduced tool set
This pipeline runs over createOpenClawTools() (not the full core tool catalog) and uses default steps that strip allowlists when no "core" entries are found. If a policy/profile allowlist only names tools outside this reduced set (such as read/exec), the allowlist gets stripped and inline-dispatch tools like gateway remain available, which bypasses allowlist-based restrictions for /skill dispatch.
Useful? React with 👍 / 👎.
|
Addressed the follow-up notes.
Verification:
|
|
Codex review: found issues before merge. Reviewed July 5, 2026, 8:32 AM ET / 12:32 UTC. Summary PR surface: Source +112, Tests +167, Docs +1. Total +280 across 3 files. Reproducibility: yes. source-level. The PR head omits model, sender, inherited, and declared-allowlist policy inputs, while current main has focused tests for denied, allowlisted, sender, subagent, and sandboxed inline dispatch paths; I did not run tests in this read-only review. Review metrics: 1 noteworthy metric.
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:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review findings
Review detailsBest possible solution: Close this PR as superseded by #78525. Do we have a high-confidence way to reproduce the issue? Yes, source-level. The PR head omits model, sender, inherited, and declared-allowlist policy inputs, while current main has focused tests for denied, allowlisted, sender, subagent, and sandboxed inline dispatch paths; I did not run tests in this read-only review. Is this the best way to solve the issue? No. The current main implementation is the better fix because it isolates skill tool dispatch in Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 785ab7477982; fix evidence: release v2026.6.11, commit e085fa1a3ffd. Label changesLabel justifications:
Evidence reviewedPR surface: Source +112, Tests +167, Docs +1. Total +280 across 3 files. View PR surface stats
Security concerns:
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
|
|
ClawSweeper PR egg 🔥 Warming up: real-behavior proof passed; findings, security review, or rank-up moves are still in progress. Hatch commandComment Hatchability rules:
What is this egg doing here?
|
|
Closing as superseded by #78525, merged in That canonical implementation routes inline I compared this branch against the landed helper and current callers. The original direction was correct, but this older patch is narrower and no longer has unique behavior worth replaying. Thanks @vincentkoc for identifying the direct-dispatch policy gap. |
Summary
/skillinline dispatch only applied the owner-only filter and skipped the rest of the tool-policy pipeline./skilldispatch through the full tool-policy resolution pipeline before exposing or invoking a tool.Change Type
User-visible / Behavior Changes
/skillinline dispatch.Verification
pnpm test -- src/auto-reply/reply/get-reply-inline-actions.tool-policy.test.tsHuman Verification
/skilldispatch and is not executed.Compatibility / Migration
Failure Recovery
/skillactions unexpectedly disappearing when a config deny rule already covers them.