Skip to content

safe-bash: host-env warning is identity-only — {...process.env} copies bypass it while README claims detection #659

Closed

Description

@kamilio

Where: packages/safe-bash/src/shell/env-warning.ts:6 — if (env !== process.env) return; — the "you passed the host environment" warning fires only on object identity. packages/safe-bash/README.md ("Environment" section) says the shell detects passing the host environment.

PoC: construct three shells with console.warn counted:

new Shell({ fs, env: process.env });                                    // identity
new Shell({ fs, env: { ...process.env } });                             // spread copy
new Shell({ fs, env: Object.assign(Object.create(null), process.env) }); // null-proto copy

Measured: identity=1 spread copy=0 Object.assign copy=0.

Impact: (a)/(e) — the common Workers/Node wiring mistake env: { ...process.env, EXTRA } (exactly the v1 finding-1 scenario, where nodejs_compat maps Worker secret bindings into process.env) produces no warning, while the README text overstates the guard.

Fix: also warn when the supplied env shares a large fraction of key/value pairs with process.env (or contains well-known secret-bearing keys such as *_TOKEN, *_SECRET, AWS_*), or reword the README to "warns only when the identical process.env object is passed".

Found in security audit v3 (2026-09-07).

Activity

  1. added
    bug
    on Sep 8, 2026
  2. poe-code-agent commented on Sep 8, 2026

    @poe-code-agent
    Contributor

    Issue was resolved by #691aafe

    Update poe-code via npm install -g poe-code@14.0.90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugreleasedsecurityseverity:low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions