Skip to content

fix(security): refuse GCONV_PATH, SHELLOPTS, BASHOPTS and PS4 from a caller, and archive the merged security changes - #2453

Merged
dan-petty merged 18 commits into
mainfrom
fix/2433-finish-merged-security-fixes
Oct 28, 2026
Merged

dan-petty merged 18 commits into
mainfrom
fix/2433-finish-merged-security-fixes

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

This change completes the security work of #1469, #1492 and #2205. A person merged their pull requests before their review and their OpenSpec archive ran, and the review then found the defects that this change removes.

  • The changes 1469-audit-keys-leak-exit-code, 1492-drop-gh-go-trivy-ignores and 2205-refuse-code-loading-env-keys are archived, one commit each. Thus openspec/specs/ holds their requirements.
  • build_subprocess_env refuses a caller override of GCONV_PATH, SHELLOPTS, BASHOPTS and PS4, in upper and lower case, with environment isolation on and off. It raises the same SecurityError as for the other refused keys. glibc iconv_open(3) loads the gconv modules from the directories that GCONV_PATH names. bash enables the options of SHELLOPTS and BASHOPTS at start. With xtrace on, bash expands PS4, command substitution included, before each command. Thus each of these keys can make a child run code that its caller did not choose.
  • New tests pin the prefix rule: the guard refuses each key that starts with DYLD_ or BASH_FUNC_, also a key that no fixed list names.
  • The comment of CONST_CODE_LOADING_ENV_PATTERNS and the child environment bullet of ARCHITECTURE.md name only the refused families. The bullet describes isolate_env on and off. It says that other keys that make a child run code, for example PYTHONPATH, NODE_OPTIONS and ZDOTDIR, still reach the child (fix(security): the subprocess environment guard refuses the zsh and interpreter keys that make a child run code #2429).
  • tests/test_config_audit_keys.py asserts the success line of a compliant audit, and the name of the leak in the security alert.
  • The invariants of the Service image move into tests/invariants/test_service_image.py, and tests/test_service_image_gh.py is deleted. The gh pin test finds each gh release path in the Dockerfile text, also in quotes or after another character. It accepts only the two tagged downloads of one release. docs/TESTING.md lists the new subject file.

Closes #2433

Change: openspec/changes/archive/2026-10-28-2433-finish-merged-security-fixes/

The change 1469-audit-keys-leak-exit-code was still active on main. The archive adds its exit-code requirement to the config-commands spec.

Refs #2433
The change 1492-drop-gh-go-trivy-ignores was still active on main. It has no spec delta.

Refs #2433
The change 2205-refuse-code-loading-env-keys was still active on main. The archive creates the subprocess-environment spec.

Refs #2433
The change 2433-finish-merged-security-fixes plans the review findings of #1469, #1492 and #2205 that are in the scope of those issues. The three archives come first, so their tasks are ticked.

Refs #2433
…un code

The refused keys add GCONV_PATH, SHELLOPTS, BASHOPTS and PS4. They also add DYLD_ and BASH_FUNC_ keys that no fixed list names, so a pattern that lists names fails the test.

Refs #2433
…HOPTS or PS4

glibc iconv loads the gconv modules from the directories in GCONV_PATH. bash enables the options of SHELLOPTS and BASHOPTS at start, and with xtrace on it runs each command substitution in PS4. Thus each key makes a child run code that its caller did not choose. The comment of the constant names the source of each entry in short sentences.

Refs #2433
…and off

The bullet said that a child gets the environment without credentials, but isolate_env=False gives the full environment. It names CONST_CODE_LOADING_ENV_PATTERNS as the full list of refused keys, in place of "and more", and each sentence obeys the STE limits.

Refs #2433
…nfig audit-keys

The config-commands spec says that a compliant table shows the success line, and that the security alert names the leak. No test asserted either clause, so an edit that removed one passed the suite.

Refs #2433
docs/TESTING.md puts an invariant test in tests/invariants/, one file per subject. The gh pin test, the .trivyignore test and the digest test of the base images now share tests/invariants/test_service_image.py. The flat file tests/test_service_image_gh.py is deleted.

Refs #2433
…er another character

The pin test kept only the bare tokens that start with the gh release URL. A quoted RUN curl of an older gh then passed it. The finder is now a function with its own test, which fails on the token rule.

Refs #2433
The finder searches the text with one regular expression, so it sees a gh release URL that is bare, in quotes or after another character. A Dockerfile with a quoted curl of gh v2.102.0 now fails the pin test.

Refs #2433
… name

A pattern that keeps only the function name x passed every test. The test now refuses BASH_FUNC_git%%, the key that replaces git in a bash child, so that pattern fails.
…mes no tag

The finder saw only releases/download/ URLs. A curl of releases/latest/download/, or a base URL that a later line completes, passed the pin test.
…gged downloads

The finder matched only releases/download/ URLs, so a curl of releases/latest/download/ passed the pin test. It now returns each path after releases/, and the pin test needs exactly the amd64 and arm64 assets of one tag.
…ility of #2433

openspec/config.yaml keeps pull request numbers out of an artifact.
…nd ARCHITECTURE.md

The comment of CONST_CODE_LOADING_ENV_PATTERNS and the child environment bullet said that the list holds every key that makes a child load or run code. The guard accepts PYTHONPATH, NODE_OPTIONS and ZDOTDIR, which run code (#2429). The comment now names the loader, gconv and bash families and their manual pages in 25 words. The bullet writes out the families and names the keys that the guard does not refuse.
@dan-petty dan-petty added scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak labels Oct 28, 2026
@dan-petty

dan-petty commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner Author

Test results

Targeted tests on the head after the rebase onto origin/main:

uv run devops ci test tests/test_subprocess_env_boundary.py tests/test_review_rules_pack.py tests/test_config_audit_keys.py tests/invariants/test_service_image.py tests/test_architectural_invariants.py
247 passed in 183.54s

Fail-to-pass

uv run devops ci fail-to-pass --base origin/main exited 0. 16 tests failed on the base, 0 errored, and all pass on the head. The 16 are test_a_caller_override_that_loads_code_into_the_child_is_refused for GCONV_PATH, SHELLOPTS, BASHOPTS and PS4, in upper and lower case, with isolation on and off. Each failed on the base with "DID NOT RAISE SecurityError". The lines below are from the output of the command; the lines "passed on base" are left out.

failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[BASHOPTS-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[BASHOPTS-not-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[GCONV_PATH-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[GCONV_PATH-not-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[PS4-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[PS4-not-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[SHELLOPTS-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[SHELLOPTS-not-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[bashopts-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[bashopts-not-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[gconv_path-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[gconv_path-not-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[ps4-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[ps4-not-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[shellopts-isolated] (Failed: DID NOT RAISE SecurityError)
failed on base: tests.test_subprocess_env_boundary::test_a_caller_override_that_loads_code_into_the_child_is_refused[shellopts-not-isolated] (Failed: DID NOT RAISE SecurityError)
16 failed on base (16 failed and 219 passed in tests/invariants/test_service_image.py, tests/test_architectural_invariants.py, tests/test_config_audit_keys.py, tests/test_subprocess_env_boundary.py; 0 errored).

The fail-to-pass workflow of CI also replays the changed tests on the base.

Readiness notes for a person

uv run devops pr check-readiness 2453 --allow-draft --allow-pending-checks reports two grounding problems. CI does not run this check, and the agent did not change the pull request for them:

@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 17:04
@dan-petty
dan-petty merged commit 1f9231d into main Oct 28, 2026
17 of 18 checks passed
@dan-petty
dan-petty deleted the fix/2433-finish-merged-security-fixes branch October 28, 2026 17:07
dan-petty pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.10.0](v0.9.0...v0.10.0)
(2026-10-28)


### Features

* **review:** devops review intake hands the findings of a session on
merged code to roadmap intake
([#2455](#2455))
([a5c7b82](a5c7b82))
* **security:** devops k8s audit runs Popeye in the tool sandbox with a
kube-api network profile that only reads the API server
([#2467](#2467))
([e02c3fb](e02c3fb))
* **security:** the App's installation tokens carry only the permissions
the roadmap jobs use
([#2482](#2482))
([9599ef2](9599ef2)),
closes [#2473](#2473)


### Bug Fixes

* **config:** a config file that is not valid YAML stops the load with
an error that quotes none of its text
([#2468](#2468))
([91fe5dc](91fe5dc))
* **config:** config set reports an unknown key as unknown, not as a key
that needs a value
([#2465](#2465))
([8b650a6](8b650a6))
* **devcontainer:** run the checkout's devops in devcontainer terminals
([#2460](#2460))
([abd2d41](abd2d41))
* **k8s:** loki runs from the grafana-community chart on loki 3.7.9, out
of reach of CVE-2026-21729
([#2470](#2470))
([96c50c9](96c50c9))
* **security:** a credential keyword at the end of a line no longer
masks the first word of the next line
([#2461](#2461))
([b754a73](b754a73))
* **security:** a credential value is masked also when the next line
starts with a parenthesis
([#2477](#2477))
([ece25ca](ece25ca)),
closes [#2471](#2471)
* **security:** pin kubeconform and replace Checkov with Trivy's
misconfiguration scan
([#2464](#2464))
([960e357](960e357))
* **security:** refuse GCONV_PATH, SHELLOPTS, BASHOPTS and PS4 from a
caller, and archive the merged security changes
([#2453](#2453))
([1f9231d](1f9231d))


### Code Refactoring

* **ai:** chat_structured is the one structured-output path
([#2452](#2452))
([3509732](3509732))
* **github:** pr check-readiness reads one merge-readiness verdict from
github/ ([#2456](#2456))
([16442c4](16442c4))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/security Security linters (trivy, bandit, gitleaks, kubeconform) and Vault type/security Type security: a vulnerability or a leak

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant