Skip to content

fix(security): refuse GCONV_PATH and the bash trace keys, and archive the merged changes of #1469, #1492 and #2205 #2433

Closed

Description

@dan-petty

Problem Description

A person merged PR #2401 (issue #1469), PR #2402 (issue #1492) and PR #2405 (issue #2205) before their review, fixes and OpenSpec archive ran. The review then found these defects on main. Each is in the scope of its issue:

  1. The three change folders are still active: openspec/changes/1469-audit-keys-leak-exit-code/, openspec/changes/1492-drop-gh-go-trivy-ignores/ and openspec/changes/2205-refuse-code-loading-env-keys/. Thus openspec/specs/ does not hold the exit-code requirement of config-commands or the new capability subprocess-environment. AGENTS.md rule 1 says that the pull request archives its change.
  2. fix(config): devops config audit-keys exits 1 when it finds a plaintext secret #1469: two scenario clauses of the spec have no test assertion. test_config_audit_keys_table_rendering does not check the success line of a compliant audit. The table test of a leak checks only the text Security Alert, not that the alert names the leak.
  3. fix(security): the service image ships a gh built with go 1.27.2 or later, and the two go stdlib ignores are dropped #1492: the two gh pin tests are in the flat file tests/test_service_image_gh.py. docs/TESTING.md puts an invariant test in tests/invariants/, one file per subject. The digest invariant of the same Dockerfile is in tests/test_architectural_invariants.py.
  4. fix(security): the service image ships a gh built with go 1.27.2 or later, and the two go stdlib ignores are dropped #1492: the pin test sees a gh URL only as a bare whitespace-split token. A gh URL in quotes, or with a character in front of it, is not seen.
  5. fix(security): the subprocess environment guard refuses ld_audit, every dyld_ key and exported bash functions #2205: the guard accepts GCONV_PATH, which the issue covers as a glibc key that loads code. iconv_open(3) loads the gconv modules from the directories that GCONV_PATH names.
  6. fix(security): the subprocess environment guard refuses ld_audit, every dyld_ key and exported bash functions #2205: the guard accepts the bash keys SHELLOPTS, BASHOPTS and PS4. bash enables the options of SHELLOPTS and BASHOPTS at start. With xtrace on, bash expands PS4, command substitution included, before each command.
  7. fix(security): the subprocess environment guard refuses ld_audit, every dyld_ key and exported bash functions #2205: no test pins the rule that every key that starts with DYLD_ or BASH_FUNC_ is refused. A narrower pattern passes the whole suite.
  8. fix(security): the subprocess environment guard refuses ld_audit, every dyld_ key and exported bash functions #2205: ARCHITECTURE.md says that build_subprocess_env gives a child the environment without credentials. That is true only with isolate_env=True. The bullet also breaks the STE rules: a sentence of 35 words, and "and more" in place of the list. The comment of CONST_CODE_LOADING_ENV_PATTERNS is one sentence of about 60 words.

Reproduction Steps

  1. Run ls openspec/changes/ on main.
  2. Run uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; print(sorted(b(env={"GCONV_PATH": "x", "SHELLOPTS": "xtrace", "PS4": "x", "BASHOPTS": "x"})))'.
  3. Run subprocess.run(["bash", "-c", "true"], env=build_subprocess_env(env={"SHELLOPTS": "xtrace", "PS4": "$(echo PS4-CODE-RAN >&2)+ "})).
  4. In the pin test, add a quoted RUN curl ... "https://github.com/cli/cli/releases/download/v2.102.0/..." line to a copy of the Dockerfile. The test passes.

Expected vs Actual Behavior

Expected: main holds no active change folder of a merged item. The guard refuses GCONV_PATH, SHELLOPTS, BASHOPTS and PS4. The tests pin each spec clause and each family pattern, and the Service image invariants are in one subject file. The documents say what the guard does.

Actual: the three folders are active. Step 2 returns all four keys with no SecurityError. Step 3 prints PS4-CODE-RAN before the command runs. The tests pass on the mutants that items 2, 4 and 7 name.

Environment Diagnostics

  • DevOps CLI Version: main at d739a47
  • Python Version: 3.14.10
  • OS & Architecture: Linux x86_64 (WSL2)
  • Execution Environment: DevContainer

Logs, Traces, or Terminal Output

$ env -i PATH=/usr/bin:/bin SHELLOPTS=xtrace PS4='$(echo PS4-CODE-RAN >&2)+ ' bash -c true   # bash 5.3.15
PS4-CODE-RAN
+ true
$ GCONV_PATH=<dir> iconv -f PWN -t UTF-8   # glibc 2.43, <dir> holds gconv-modules and x.so
GCONV-CODE-RAN

The out-of-scope findings of the same reviews are in #2426 and #2429, and in a comment on #2255. The merge commit of PR #2401 names the active change folder and has no Change: line. A rewrite of main is the only way to change it, so this item does not change it.

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.

Source: #2405

Proposed design

Problem statement

The guard in build_subprocess_env accepts GCONV_PATH, SHELLOPTS, BASHOPTS, and PS4, which let a child process load or run attacker-chosen code. Three change folders of merged items are still active. The gh pin test misses quoted URLs. No test pins the DYLD_ and BASH_FUNC_ family patterns. ARCHITECTURE.md states a wrong condition for build_subprocess_env.

Acceptance criteria

  • Criterion 1: The three change folders are archived into openspec/changes/archive/.
    Verification: Run ls openspec/changes/. No folder for 1469, 1492, or 2205 appears. Run ls openspec/changes/archive/. All three folders appear.
  • Criterion 2: The guard refuses GCONV_PATH, SHELLOPTS, BASHOPTS, and PS4.
    Verification: Run uv run python -c 'from devops_cli.core.process import build_subprocess_env as b; b(env={"GCONV_PATH": "x", "SHELLOPTS": "xtrace", "PS4": "x", "BASHOPTS": "x"})'. The command raises SecurityError.
  • Criterion 3: The compliant-audit test asserts the success line. The leak test asserts the alert names the leaked key.
    Verification: Read test_config_audit_keys_table_rendering. It asserts the success line text of a compliant audit. The leak table test asserts the alert text names the leaked key, not only the text Security Alert.
  • Criterion 4: The gh pin tests sit in a file under tests/invariants/.
    Verification: The file tests/test_service_image_gh.py does not exist. A file under tests/invariants/ holds the two gh pin tests.
  • Criterion 5: The gh pin test catches a quoted URL and a URL with a character in front.
    Verification: Add a line RUN curl ... "https://github.com/cli/cli/releases/download/v2.102.0/..." to a copy of the Dockerfile. The test fails.
  • Criterion 6: A test fails when a narrower pattern replaces the DYLD_ or BASH_FUNC_ prefix rule.
    Verification: Remove the DYLD_ prefix from CONST_CODE_LOADING_ENV_PATTERNS. Run the new test. It fails. Restore the prefix. The test passes.
  • Criterion 7: ARCHITECTURE.md names isolate_env=True as the condition for credential removal. No sentence exceeds 25 words. No 'and more' replaces a list.
    Verification: Read the build_subprocess_env bullet in ARCHITECTURE.md. It names isolate_env=True. Count the words in each sentence. None exceeds 25. The list is written out, not shortened with 'and more'.
  • Criterion 8: The comment of CONST_CODE_LOADING_ENV_PATTERNS is 25 words or fewer.
    Verification: Read the comment above CONST_CODE_LOADING_ENV_PATTERNS in src/devops_cli/core/process.py. Count the words. The total is 25 or fewer.

Key questions

  • Where do invariant tests belong?: In tests/invariants/, one file per subject. [sources: docs/TESTING.md]
  • Which environment keys must the guard add to its refusal list?: GCONV_PATH, SHELLOPTS, BASHOPTS, and PS4, in addition to the existing DYLD_ and BASH_FUNC_ prefix patterns. [sources: src/devops_cli/core/process.py]
  • Should the merge commit of PR fix(config): exit 1 when audit-keys finds a plaintext secret #2401 be changed?: No. A rewrite of main is the only way to change it, and this item does not change it. (proposed)
  • What detection method does the gh pin test use today?: It splits the Dockerfile on whitespace and checks each token for the gh release URL prefix. A quoted URL or a URL with a character in front is not seen. [sources: tests/test_service_image_gh.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/security
    on Oct 28, 2026
  2. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

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

    • Type: type/security. The core fix refuses environment keys that let a child process load or run attacker-chosen code.
    • Priority: P1-High. GCONV_PATH and PS4 enable confirmed code execution in a child process, as shown by the reproduction output.
    • Value: High. Closing the guard stops a caller from running arbitrary code through the subprocess environment.
    • Effort: Medium. The fix touches the guard, several test files, two doc files, and three archive folders.
    • Related: fix(security): the subprocess environment guard refuses ld_audit, every dyld_ key and exported bash functions #2205, which asks for a different change. Both target build_subprocess_env in process.py; #2205 added LD_AUDIT and DYLD_* refusal, the candidate adds GCONV_PATH and bash trace keys plus tests for the #2205 patterns.
  3. dan-petty commented on Oct 28, 2026

    @dan-petty
    OwnerAuthor

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

  4. added a commit that references this issue on Oct 28, 2026
    1f9231d
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

    source/agenttype/security

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions