Skip to content

pi launch does not clear LD_* loader variables after sourcing .env #7580

Closed

Description

@waynesun09

What

The pi launch clears some loader variables after it sources the workspace .env, but not all of the ones the Codex launch clears.

  • internal/runtime/codex_run.go:326 unsets NODE_OPTIONS NODE_PATH PYTHONPATH PYTHONHOME PYTHONSTARTUP LD_PRELOAD LD_LIBRARY_PATH LD_AUDIT.
  • internal/runtime/pi_run.go:506 unsets NODE_OPTIONS NODE_PATH only.

The .env file is writable by the agent. So a value like LD_PRELOAD planted in an earlier iteration is still set when pi starts in the next one.

Proposed fix

Add LD_PRELOAD LD_LIBRARY_PATH LD_AUDIT to the pi unset, matching Codex. Add a launch test asserting the unset follows . .env and names each variable.

Activity

  1. fullsend-ai-triage commented on Sep 23, 2026

    @fullsend-ai-triage

    🤖 Finished Triage · ✅ Success · Started 1:13 AM UTC · Completed 1:17 AM UTC

    Commit: e64cf64 · View workflow run →

    Runtime: claude · Model: sonnet → claude-sonnet-5 · Effort: high · Cost: $0.41

  2. added
    triaged
    security
    component/sandbox
    priority/high
    on Sep 23, 2026
  3. fullsend-ai-triage commented on Sep 23, 2026

    @fullsend-ai-triage

    Confirmed by comparing the two launch builders directly: codex's post-.env hygiene (codex_run.go:326) clears LD_PRELOAD LD_LIBRARY_PATH LD_AUDIT alongside the module-loader variables, with an explicit rationale that these can load code into any dynamically linked binary the run starts before its main runs. pi's equivalent (piLoaderEnvNames / piLoaderEnvUnset) does not include them, so a value set via the agent-writable .env in one iteration is never cleared for pi and persists into the next launch.

    One thing worth calling out: the proposed fix is correctly scoped to just the three LD_* names — PYTHON* is not needed here, since pi's hook adapter is a JS extension rather than a Python interpreter like codex's, so that particular hole (documented in codex's comment) doesn't apply to pi's launch.

    There's an existing test, TestBuildPiRunCommand_LoaderEnvHygiene in pi_run_test.go, that already pins the ordering of the loader-env unset relative to . .env across every provider path — that's a direct template to extend with the three new names, per the issue's own suggestion.

    A related but distinct gap exists in issue #3373 (sandbox credential-key blocklist parity), which is not a duplicate of this one — that issue is about env.sandbox credential keys, this one is about launch-time dynamic-linker hygiene.


    Labels: This is a security-relevant sandbox/runtime hygiene gap in the pi launch path, matching the security + component/sandbox + priority/high pattern used on comparable loader/env-hygiene issues in this repo (e.g. #3373, #6920).


    Next steps:

    • /fs-code — agent creates a PR to implement this issue
    • /fs-code <your instruction> — agent implements with your specific guidance
  4. Aliciapet11 commented on Oct 19, 2026

    @Aliciapet11
    Contributor

    Hi @waynesun09 , I’m interested in contributing to this issue.
    I noticed the newer #8498, which covers the broader problem of not sourcing the agent-writable .env as shell across runtimes. Its triage comment describes #7580 as related but not a duplicate, and #8498 is currently blocked by PR #8261.

    Would you prefer a focused fix for #7580 now - adding the missing LD_PRELOAD, LD_LIBRARY_PATH, and LD_AUDIT cleanup to Pi and extending TestBuildPiRunCommand_LoaderEnvHygiene - or should this wait and be incorporated into the broader #8498 work?

    I also saw the references to #6959, #7927, and #7988, but I understand those are related runtime/security work rather than direct implementations of this issue.

  5. waynesun09 commented on Oct 19, 2026

    @waynesun09
    MemberAuthor

    Thanks for the careful read, @Aliciapet11. We're starting #8498 now, and it rewrites the same .env handling in pi_run.go. To avoid two PRs on the same lines, we've folded the LD_* cleanup into that work, and #7580 will close when it lands. Since you've already traced this code path, we'd welcome your review on the #8498 PR once the code agent opens it. I'll tag you there.

  6. added a commit that references this issue on Oct 19, 2026
    eeadc03
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

    bugcomponent/sandboxpriority/highsecuritytriaged

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions