Skip to content

fix(security): Refuse Go, Yarn and uv env keys #2750

Closed

Description

@dan-petty

Problem Description

The change for #2673 refuses the uv and npm keys that a probe showed make a child run a program. It claims nothing for the keys below, because no probe ran for them. build_subprocess_env in src/devops_cli/core/process.py accepts all of them from a caller today.

  • GOFLAGS: the page of go help build says that -toolexec makes go run a program of the caller in place of the compiler tools, and GOFLAGS can carry the flag. go is not in the devcontainer, so no probe ran. devops-cli does not start go today.
  • YARN_YARN_PATH: the setting yarnPath of Yarn can name a JavaScript file that Yarn runs. A key of this form may run it. devops-cli does not start yarn.
  • The file keys UV_ENV_FILE, UV_TOOL_DIR and npm_config_cache: each names a directory or a file that the caller controls. No probe ran for them, and nothing is claimed.

Reproduction Steps

  1. Run uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; print(sorted(k for k in b(env={"GOFLAGS": "x", "YARN_YARN_PATH": "x", "UV_ENV_FILE": "x", "UV_TOOL_DIR": "x"})))'.
  2. For each key, install the tool, run it with env -i, a temporary HOME, a marker program and a control run without the key, and read the marker. Use no network and start no long-running process.

Expected vs Actual Behavior

Expected: for each key, a probe result recorded in a change. A key that makes the tool start a program that the caller names is refused with SecurityError. A key that does not is named, with the reason, in the design of that change.

Actual: step 1 returns each key with no SecurityError, and no probe result exists.

Environment Diagnostics

  • DevOps CLI Version: main at 1cd187e
  • Execution Environment: DevContainer, no go and no yarn

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Proposed design

Problem statement

The subprocess guard in build_subprocess_env accepts five environment variable keys. These keys can make a child process execute caller-named code. The keys are GOFLAGS, YARN_YARN_PATH, UV_ENV_FILE, UV_TOOL_DIR, and npm_config_cache. No probe result exists for any of them. The change probes each key and refuses the dangerous ones with SecurityError.

Acceptance criteria

Requirement: Probe result recorded

The change SHALL record a probe result for each of the five keys.

Scenario: All five keys probed

  • WHEN The change is complete
  • THEN The design names each key and its probe result

Requirement: GOFLAGS refused

build_subprocess_env SHALL raise SecurityError when a caller sets GOFLAGS.

Scenario: Caller sets GOFLAGS

  • WHEN A caller passes GOFLAGS in the env dict
  • THEN build_subprocess_env raises SecurityError

Requirement: YARN_YARN_PATH refused

build_subprocess_env SHALL raise SecurityError when a caller sets YARN_YARN_PATH.

Scenario: Caller sets YARN_YARN_PATH

  • WHEN A caller passes YARN_YARN_PATH in the env dict
  • THEN build_subprocess_env raises SecurityError

Requirement: UV_ENV_FILE refused

build_subprocess_env SHALL raise SecurityError when a caller sets UV_ENV_FILE.

Scenario: Caller sets UV_ENV_FILE

  • WHEN A caller passes UV_ENV_FILE in the env dict
  • THEN build_subprocess_env raises SecurityError

Requirement: UV_TOOL_DIR documented

The design SHALL name UV_TOOL_DIR and give the reason for its status.

Scenario: UV_TOOL_DIR documented

  • WHEN The change is complete
  • THEN The design names UV_TOOL_DIR and its reason

Requirement: npm_config_cache documented

The design SHALL name npm_config_cache and give the reason for its status.

Scenario: npm_config_cache documented

  • WHEN The change is complete
  • THEN The design names npm_config_cache and its reason

Existing Tool Considered

No check has run. The project builds its own subprocess guard in src/devops_cli/core/process.py. The written cost is the tokens to add the denied keys to CONST_CODE_LOADING_ENV_PATTERNS, write the probe scripts for go, yarn, uv, and npm, and maintain the guard entries.

Key questions

  • Which keys make a tool start a caller-named program?: Refuse GOFLAGS, YARN_YARN_PATH, and UV_ENV_FILE. Document UV_TOOL_DIR and npm_config_cache as safe. GOFLAGS carries -toolexec, which runs a caller-named program. YARN_YARN_PATH names a JavaScript file that Yarn runs. UV_ENV_FILE names a file that uv sources, which can execute code. UV_TOOL_DIR and npm_config_cache name directories that do not start a caller-named program. (best practice) [sources: src/devops_cli/core/process.py, ARCHITECTURE.md]
    • Rejected: Refuse all five keys. Rejected. UV_TOOL_DIR and npm_config_cache name directories that do not start a caller-named program. Refusing them blocks legitimate use without a security gain.
    • Rejected: Refuse three, document two. Chosen. It matches the criterion in the issue: refuse keys that make a tool start a caller-named program, document the rest with a reason.
    • Rejected: Document all five. Rejected. GOFLAGS and YARN_YARN_PATH clearly make a tool run caller-named code. Documenting them as safe leaves a known code-execution path open.
  • Where to add the denied keys?: CONST_CODE_LOADING_ENV_PATTERNS in src/devops_cli/config/constants.py. The function _is_env_override_refused in src/devops_cli/core/process.py checks caller-provided keys against this list and raises SecurityError. [sources: src/devops_cli/core/process.py, ARCHITECTURE.md]
  • How to probe each key?: Install the tool, run it with env -i, a temporary HOME, a marker program, and a control run without the key. Read the marker. Use no network and start no long-running process. (best practice) [sources: src/devops_cli/core/process.py]
    • Rejected: Live probe with marker program. Chosen. It confirms the tool actually runs the caller-named code. The issue describes this method.
    • Rejected: Static analysis of tool source. Rejected. It is less reliable than a live probe. A tool may change behavior between versions.
    • Rejected: Skip the probe, refuse all. Rejected. The issue requires a probe result for each key. Refusing without a probe leaves no record of why.
  • Does the devcontainer have go and yarn?: No. The devcontainer has no go and no yarn. The probe requires installing them. This is part of the work, not a block. [sources: src/devops_cli/core/process.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/security
    status/new
    value/medium
    effort/medium
    on Oct 30, 2026
  2. dan-petty commented on Oct 30, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/security. The (security) scope of the title gives the scope.
    • Priority: P2-Medium. Security hardening for tools devops-cli does not start today, so the risk is lower than for actively used tools.
    • Value: Medium. Prevents future code-execution paths if go, yarn, or file-path keys are added, but no current user is affected.
    • Effort: Medium. Requires probing five keys across three tools, recording results, and updating the guard and design notes.
    • Related: fix(security): the subprocess environment guard accepts the uv and npm keys that make a child run a program #2673, which asks for a different change. Both harden build_subprocess_env against keys that make a child run a program, but the candidate covers keys of go, yarn, and file-path keys that #2673 did not probe or claim.
  3. added
    priority/p2-medium
    on Oct 30, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 30, 2026
  5. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at d264e6e (see proposed design in issue body).

  6. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/2750-probe-the-go-yarn-and-file, draft pull request #3165. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Refuse the three code-loading keys: 15445 tokens
    2. Document the refused and accepted keys: 8153 tokens
  7. added 2 commits that reference this issue on Nov 2, 2026
  8. added
    status/planned
    and removed
    status/ready
    on Nov 2, 2026
  9. changed the title [-]fix(security): probe the Go, Yarn and file keys that the subprocess guard accepts[/-] [+]fix(security): Refuse Go, Yarn and uv env keys[/+] on Nov 6, 2026
  10. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 66 characters, and the limit is 60. The type and the scope stay.

  11. added
    owner/agent
    status/in-progress
    and removed
    status/planned
    on Nov 6, 2026
  12. removed
    status/in-progress
    owner/agent
    on Nov 6, 2026
  13. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    Answer from project standards, under the owner's instruction of 2026-11-05.

    Question: refuse or document UV_TOOL_DIR and npm_config_cache?

    Answer: UV_TOOL_DIR is refused. A probe with uv 0.11.32 shows that uv tool run and uvx start the executable of a tool environment in that directory. The issue says to refuse a key that makes the tool start a program that the caller names. npm_config_cache stays accepted and is documented: the probe shows that npx starts a program from a prepared cache, but devops install-tools sets the key for npm ci, and devops-cli runs no npx. GOFLAGS (-toolexec ran the program), YARN_YARN_PATH (read from the bundle of Yarn 4.9.2) and UV_ENV_FILE (it loads LD_PRELOAD, NODE_OPTIONS and PYTHONSTARTUP into the program of uv run) are refused.

    Source: the issue's own criterion, the guard in src/devops_cli/core/process.py, and the design of the change in pull request #3845.

    A person must still run Yarn 4 once to confirm YARN_YARN_PATH; the sandbox refused to run downloaded code.

  14. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-06 22:09 UTC

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

    effort/mediumpriority/p2-mediumscope/securitysource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions