Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

fix(permissions): also deny safe-read for ANSI-C quoting ($'...')

Salman Qureshi66511886f504
diff --git a/src/capabilities/permissions.test.ts b/src/capabilities/permissions.test.ts
index b79c483c..144424c6 100644
--- a/src/capabilities/permissions.test.ts
+++ b/src/capabilities/permissions.test.ts
@@ -163,6 +163,8 @@ describe('PermissionManager remote safety', () => {
await expect(permissions.checkShellCommand('echo $TOKEN')).resolves.toMatchObject({ allowed: false });
// Home shorthands expand after the check too.
await expect(permissions.checkShellCommand('cat ~/secret.txt')).resolves.toMatchObject({ allowed: false });
+ // ANSI-C quoting expands hex/unicode escapes post-check (same class as #95).
+ await expect(permissions.checkShellCommand("head $'\\x2fetc\\x2fpasswd'")).resolves.toMatchObject({ allowed: false });
// A plain read relative to cwd stays auto-approved.
await expect(permissions.checkShellCommand('head file.txt')).resolves.toMatchObject({ allowed: true });
});
diff --git a/src/capabilities/permissions.ts b/src/capabilities/permissions.ts
index 62efa908..deb86369 100644
--- a/src/capabilities/permissions.ts
+++ b/src/capabilities/permissions.ts
@@ -571,7 +571,8 @@ export class PermissionManager {
// resolve outside the workspace (`head $HOME/secret`, CVE-2026-28463) or
// disclose environment values (`echo $TOKEN`). Require approval for any
// segment that relies on variable expansion or a home shorthand.
- if (/\$[{(0-9A-Za-z_]|`/.test(segment)) return false;
+ // ANSI-C quoting ($'\x2f...') also expands post-check — caught by the same class.
+ if (/\$[{(0-9A-Za-z_']|`/.test(segment)) return false;
if (/(?:^|\s)~[A-Za-z0-9_-]*(?:\/|$)/.test(segment)) return false;
const branchArgs = segment.match(/^git\s+branch(?:\s+(.*))?$/)?.[1]?.trim();
if (branchArgs && (