fix(exec-approvals): reject Allow rules with absolute file paths - #379
Conversation
ValidateExecApprovalRules accepted patterns like C:\evil.exe as Allow rules. A local process with the MCP bearer token could use this to whitelist an attacker-controlled binary, then invoke it via system.run (two-step local EoP). Add a check: Allow rules whose pattern starts with a drive root (X:\, X:/) or a UNC/long-path prefix (\) are rejected. Legitimate rules name commands, not paths. Fixes openclaw#347. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
This is the right security direction, but the validator still appears bypassable with quoted absolute paths.
Suggested fix: strip one layer of matching surrounding quotes before the absolute-path check, and add test cases for at least:
I would also consider forward-slash UNC/namespace forms if the command policy accepts them ( |
The validator lowercased the pattern but did not strip surrounding quotes, so "C:\evil.exe" and 'C:\evil.exe' bypassed the absolute-path rejection added in the previous commit. Also add forward-slash UNC/namespace forms (//server/share, //?/C:/evil.exe) to the check. Strip one layer of matching " or ' before testing for drive-root, UNC, and forward-slash UNC prefixes. Add quoted and forward-slash test cases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for catching the quoted-path bypass! Added quote stripping before the absolute-path check, and covered all the cases you mentioned — unquoted and quoted drive paths, UNC and long-path prefix forms, single-quoted variants, and the forward-slash equivalents. |
Summary
ValidateExecApprovalRulesacceptedAllowrules whose pattern was an absolute file path (e.g.C:\Users\Public\evil.exe,\?\C:\evil.exe). A local process that obtained the MCP bearer token could usesystem.execApprovals.setto whitelist an attacker-controlled binary, then invoke it viasystem.run— a two-step local EoP.The existing validator already blocked all-wildcard and dangerous-fragment patterns. This closes the gap on specific-path Allow rules.
Changes
SystemCapability.cs: add check inValidateExecApprovalRules— rejectsAllowpatterns that start with a drive root (X:\,X:/) or a UNC/long-path prefix (\)CapabilityTests.cs: addExecApprovalsSet_RejectsAbsolutePathAllowRulestheory covering drive-rooted, forward-slash, UNC, and long-path namespace patternsFixes #347.
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com