Skip to content

Executed jobs inherit the backend's full environment, including every provider API key #31

Description

@ldaiding
        # Setup environment
        env = os.environ.copy()
        if env_vars:
            env.update(env_vars)

backend/app/code/run/job_runner.py:391

That environment is exactly where the provider secrets live: set_runtime_key writes them into the process env (backend/app/core/settings.py:209), and _load_runtime re-injects all persisted keys on boot (backend/app/core/settings.py:283).

Trigger: create a job with command: "env" and start it.
Observed: stdout.log contains OPENAI_API_KEY, ANTHROPIC_API_KEY, MOONSHOT_API_KEY, DATABASE_URL, … and that log is then registered as a downloadable artifact (backend/app/modules/code/code_jobs_api.py:185) and served by GET /{job_id}/logs/download (backend/app/modules/code/code_jobs_api.py:491). The secrets are now readable by anyone who can list jobs.
Expected: build the child environment from an explicit allowlist (PATH, HOME, LANG, PYTHONPATH) plus caller-supplied env_vars, never os.environ.copy().

This is a straightforward fix and it meaningfully reduces the blast radius of issue-09 even before sandboxing lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions