Your coding agent can read your .env. Here’s what we did about it
说明与用途
penv 通过将环境变量模式与实际值分离、在执行前验证、掩码输出以及自动生成特定 harness 的保护规则,防止 AI 代码代理泄露机密信息。
问题
Coding agents run in the same user context as developers, so they can read .env files and leak secrets through logs, transcripts, or stack traces.
结果
penv protects secrets from being read or leaked by coding agents by separating the schema from the values, validating before execution, masking output, and generating harness‑specific guard rules.
工作流
- Run
penv initto read the existing .env, generate .env.schema, and gitignore .env. - Use
penv run -- <command>to validate the environment, inject values, and mask any sensitive output when an agent session is detected. - Generate typed accessors with
penv gen tsorpenv gen pyto replace direct process.env usage. - If using a team, run
penv loginandpenv pushto store secrets in penv.cloud and delete local .env. - Use
penv reveal KEYunder an agent session to request a secret with human approval.
证据
penv init # reads .env, writes .env.schema, gitignores .env
penv run -- pnpm dev # validates, injects, masks
penv guard writes what each harness actually enforces
penv keeps secrets out of the files, the repo, the shell history and the captured output an agent reads.
- 记录日期: 2026-09-15T19:01:41.892Z