Skip to content

Commit a2fd2c3

Browse files
committed
security: pass Haiku classifier prompt via stdin instead of argv
Scanned content (user messages, tool outputs up to 8KB) was passed as a CLI argument to `claude -p <prompt>`, making it visible in `ps aux` and `/proc/<pid>/cmdline` for up to 15 seconds per classification. On shared Linux hosts (default hidepid=0) any local user could read it. Fix: pipe the prompt through stdin (`claude -p` reads from stdin when no argument follows) and scope the child env to PATH + HOME + ANTHROPIC_API_KEY only.
1 parent 675717e commit a2fd2c3

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

browse/src/security-classifier.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,20 @@ export async function checkTranscript(params: {
494494
// ~44k cache_creation tokens per call (massive cost inflation).
495495
// Using os.tmpdir() gives Haiku a clean context for pure classification.
496496
const p = spawn('claude', [
497-
'-p', prompt,
497+
'-p',
498498
'--model', HAIKU_MODEL,
499499
'--output-format', 'json',
500-
], { stdio: ['ignore', 'pipe', 'pipe'], cwd: os.tmpdir() });
500+
], {
501+
stdio: ['pipe', 'pipe', 'pipe'],
502+
cwd: os.tmpdir(),
503+
env: {
504+
PATH: process.env.PATH,
505+
HOME: process.env.HOME,
506+
ANTHROPIC_API_KEY: process.env.ANTHROPIC_API_KEY,
507+
},
508+
});
509+
p.stdin.write(prompt);
510+
p.stdin.end();
501511

502512
let stdout = '';
503513
let done = false;

0 commit comments

Comments
 (0)