Skip to content

harden(PATH): trusted-PATH resolution for wrapped binaries (defer trojan-on-PATH defense) #40

Closed

Description

@thehoff

Source

Codex P1 on PR for issue #39: secure_command_with_policy calls resolved_command(policy.name) which uses which::which() against the inherited PATH. A tainted parent PATH (PATH=/tmp/evil:$PATH) can swap in trojan git/rg/etc. before any env stripping fires.

Defense options (pick one in the eventual PR)

  • (a) Resolve against a hardcoded trusted-PATH list: /usr/bin, /bin, /usr/local/bin, /opt/homebrew/bin, ~/.cargo/bin. Anything else gets a warning.
  • (b) Make trusted-PATH a config option in ~/.config/contextcrawler/config.toml with sane defaults.
  • (c) Use which::which_in() against a sanitized PATH that omits world-writable dirs.

Threat model note

The user's zero-trust framing: "ONLY the LLM/Claude is making the calls; they shouldn't do vile things". A tainted PATH typically requires earlier compromise (someone wrote to PATH-listed dir). Lower probability than env-var hijack but still worth a follow-up.

Out of scope

The current PR for #39 leaves PATH resolution unchanged (matches all existing call sites via resolved_command). This issue tracks the discrete hardening pass.

Activity

  1. added
    enhancement
    on May 18, 2026
  2. thehoff commented on Jun 10, 2026

    @thehoff
    OwnerAuthor

    Closing — marked defer; trusted-PATH resolution not on the near-term roadmap.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions