Repository navigation
fix(security): refuse every loader and shell key that loads code into a child - #2405
Merged
Merged
Conversation
Plan #2205 as the change 2205-refuse-code-loading-env-keys: the proposal with its feasibility evidence, the design, the spec delta of the new capability subprocess-environment, and the tasks.
… a child build_subprocess_env refused six keys only. It now refuses a caller override whose upper-case key matches CONST_CODE_LOADING_ENV_PATTERNS: LD_AUDIT, LD_LIBRARY_PATH, LD_ORIGIN_PATH, LD_PRELOAD, every DYLD_ key, BASH_ENV, ENV and every BASH_FUNC_ key. The constant names its sources, glibc ld.so(8), macOS dyld(1) and bash function export. The local key set of the function is deleted.
…f the person run_rule_pack_tests gave Semgrep the full ambient environment as its caller override. The guard on code-loading keys checks each override key, so an exported bash function in the environment, such as which on Fedora and RHEL, stopped devops review rules test. The full copy also gave Semgrep the credentials that build_subprocess_env removes. Semgrep now gets only SEMGREP_ENABLE_VERSION_CHECK=0 on top of the isolated environment.
The safe subprocess execution section says which caller keys build_subprocess_env refuses, and that a caller gives a child only the keys that it needs.
Owner
Author
|
Test results of the branch at 0afbce7, rebased onto origin/main at ad0114f.
Fail-to-pass ( |
dan-petty
marked this pull request as ready for review
October 28, 2026 14:13
dan-petty
pushed a commit
that referenced
this pull request
Oct 28, 2026
🤖 I have created a release *beep* *boop* --- ## [0.8.3](v0.8.2...v0.8.3) (2026-10-28) ### Bug Fixes * **ai:** the gateway sweep's URL error names no credential ([#2400](#2400)) ([2e6f1fd](2e6f1fd)), closes [#909](#909) * **config:** exit 1 when audit-keys finds a plaintext secret ([#2401](#2401)) ([ad0114f](ad0114f)), closes [#1469](#1469) * **security:** drop the Go ignores that the pinned gh build does not need ([#2402](#2402)) ([6052083](6052083)), closes [#1492](#1492) * **security:** refuse every loader and shell key that loads code into a child ([#2405](#2405)) ([86d5bce](86d5bce)), closes [#2205](#2205) --- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
build_subprocess_envinsrc/devops_cli/core/process.pyrefused a caller override of six keys only:LD_PRELOAD,LD_LIBRARY_PATH,DYLD_INSERT_LIBRARIES,DYLD_LIBRARY_PATH,BASH_ENVandENV. It accepted other keys that make the loader or the shell of a child load code that the caller did not choose. glibc loads each object thatLD_AUDITnames. The macOS loader reads moreDYLD_keys, for exampleDYLD_FRAMEWORK_PATH. A bash child defines a function from eachBASH_FUNC_<name>%%key, and that function replaces a command of the same name.CONST_CODE_LOADING_ENV_PATTERNSinsrc/devops_cli/config/constants.pyholds the refused families asfnmatchpatterns:LD_AUDIT,LD_LIBRARY_PATH,LD_ORIGIN_PATH,LD_PRELOAD,DYLD_*,BASH_ENV,ENVandBASH_FUNC_*. Its comment names the sources: glibcld.so(8), macOSdyld(1)and the function export of bash.build_subprocess_envmatches the upper-case key of each caller override against the constant with_is_env_var_denied, the helper of the credential patterns. A match raises the sameSecurityErrorand error code as before. The local key set of the function is deleted.run_rule_pack_testsinsrc/devops_cli/review/rules_pack.pygave Semgrep the full ambient environment as its override. The wider guard thus stoppeddevops review rules teston a host where bash exports a function, such aswhichon Fedora and RHEL. The full copy also gave Semgrep the credentials thatbuild_subprocess_envremoves. Semgrep now gets onlySEMGREP_ENABLE_VERSION_CHECK=0on top of the isolated environment.tests/test_subprocess_env_boundary.pyaddsLD_AUDIT,LD_ORIGIN_PATH, threeDYLD_keys andBASH_FUNC_x%%to the refused keys, in upper and lower case. A new test shows thatPATH,HOME,ENVIRONMENT,EXAMPLE_DYLD_FLAGandBASH_FUNCTIONSreach the child.tests/test_review_rules_pack.pyshows that Semgrep gets only its own setting.ARCHITECTURE.mddescribes the guard in its section on safe subprocess execution.subprocess-environment.Closes #2205
Change:
openspec/changes/2205-refuse-code-loading-env-keys/