返回资讯中心
外部精选
软件工程
#开发者实时流

secret-scratch 拦截密钥,让编码 agent 看不到明文密码

来源标题:Securely share passwords with your Agents

@inixiative/secret-scratch 推出,可在密钥进入模型前将其替换为占位符,LLM、会话记录和日志全程看不到明文。agent 通过 secret_scratch 和 secret_pipe 工具写入 .env 文件并推送到 GitHub Actions,同时禁止读取该文件。该工具零运行时依赖,支持 Node.js 20+ 和 Bun 1.4+,可通过 npx 或全局安装包裹任意 ACP agent 命令。

Hacker News 最新inixiative2026/11/21 · 今天12 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

Pass secrets to coding agents as $$value without the LLM, transcript, or logs ever seeing them.

You type: Put $$sk_live_9876543210 into .env.local as STRIPE_KEY, then push it to GitHub Actions. Agent sees: Put †m1.1 into .env.local as STRIPE_KEY, then push it to GitHub Actions. Agent calls: secret_scratch(action: "env", ref: "†m1.1", path: ".env.local", key: "STRIPE_KEY") secret_pipe(envFile: ".env.local", key: "STRIPE_KEY", command: "gh secret set STRIPE_KEY") Agent gets: { ok: true, exitCode: 0 } Agent tries: cat .env.local -> BLOCKED (.env.local is held by secret-scratch)

Zero runtime dependencies. Works with Node.js 20+ and Bun 1.4+. Ships three ways to integrate:

Pasting an API key or private key into a coding agent chat sends the secret to the model provider, writes it into session transcripts, and leaves it in tool logs and crash dumps.

secret-scratch intercepts secrets before they reach the model:

Wrap any ACP agent command with npx @inixiative/secret-scratch --:

npx -y @inixiative/secret-scratch -- <your-acp-agent-command> [args...]

Or install globally:

npm install -g @inixiative/secret-scratch secret-scratch -- <your-acp-agent-command> [args...]

Example: Zed (settings.json)

{ "agent_servers": { "Claude Code (secret-scratch)": { "command": "npx", "args": ["-y", "@inixiative/secret-scratch", "--", "claude-agent-acp"] }, "Codex (secret-scratch)": { "command": "npx", "args": ["-y", "@inixiative/secret-scratch", "--", "codex-acp"] }, "Gemini CLI (secret-scratch)": { "command": "npx", "args": ["-y", "@inixiative/secret-scratch", "--", "gemini", "--experimental-acp"] } } }

When a session starts, the proxy:

secret-scratch [options] -- <acp-agent-command> [args...] secret-scratch mcp --dir <path> --thread <id> [--cwd <path>] secret-scratch list [--dir <path>] [--thread <id>] secret-scratch clear <thread> [--dir <path>]

Options: --dir <path> Scratch pad directory (default: ~/.secret-scratch) --private <glob> Extra private path glob to block (repeatable) --no-lift-shaped Only lift explicit $$value markers --no-scrub Disable scrubbing held values from session/update

Library usage

import { SecretScratchPad, SHAPED_SECRET_PATTERNS, privatePathGate, scratchTarget, } from '@inixiative/secret-scratch';

const pad = new SecretScratchPad('~/.secret-scratch');

// 1. Lift before sending to the LLM const { text, refs } = pad.lift( 'Set STRIPE_KEY to $$sk_live_example1234567890 in .env.local', { thread: 'thread_1', message: 'm1' }, { patterns: SHAPED_SECRET_PATTERNS }, ); // text === 'Set STRIPE_KEY to †m1.1 in .env.local'

// 2. Write safely inside cwd (rejects .., symlink escapes, .git, .claude, .ssh) const target = scratchTarget(process.cwd(), '.env.local'); pad.env({ ref: refs[0]! }, 'thread_1', target, 'STRIPE_KEY', { consume: true });

// 3. Pipe straight to a CLI without returning stdout/stderr const { exitCode } = await pad.pipe( { envFile: target, key: 'STRIPE_KEY' }, 'thread_1', 'gh secret set STRIPE_KEY', );

// 4. Gate agent file/shell tools const gate = privatePathGate({ scratchDir: pad.dir, heldFiles: pad.heldFiles(), }); gate({ toolName: 'Bash', toolInput: { command: 'cat .env.local' } }); // { behavior: 'deny', message: '.env.local is private: ...' }

See docs/VERBS.md for the complete public API table.

Prevents accidental exposure to the LLM, agent transcripts, and tool output. Secrets lifted at the prompt boundary never enter model context, prompt caches, or downstream agent session transcripts. secret_pipe discards stdout and stderr and kills the whole process group on timeout.

On-disk storage is 0600 plaintext in a 0700 directory. Scratch pads live at ~/.secret-scratch/<thread>.pad until consumed or cleared (secret-scratch clear <thread>). They protect against LLM and transcript leakage, not against another process running as your OS user.

Shell gating and secret_pipe defend against accidental leaks, not a hostile sandbox. If a downstream agent runs shell commands directly inside its own process without asking the ACP host via session/request_permission or terminal/create, the ACP proxy cannot intercept those local subprocess calls. Likewise, an adversarial model that can pass arbitrary shell commands to secret_pipe could write stdin to an untracked file or encode bytes in the exit code. For enforcement against an untrusted model, pair secret-scratch with an OS sandbox or a harness that routes all tool calls through privatePathGate and restricts allowed pipe commands.

Single-word marker. $$value lifts up to the next whitespace. Multi-line secrets (such as PEM private keys) are lifted by shape automatically; arbitrary multi-line secrets should be passed by file or env key rather than $$.

Origin

Extracted from Foundry, a source-available (BSL 1.1) local agent harness built by inixiative.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →