fix(security): block JVM, Python, and .NET env injection vectors in host exec sandbox#49025
Conversation
Greptile SummaryThis PR makes a well-scoped, strictly additive security improvement by blocking five env-injection vectors ( Key observations:
Confidence Score: 5/5
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/infra/host-env-security-policy.json
Line: 25
Comment:
**Missing .NET CLR profiler injection trio**
`DOTNET_STARTUP_HOOKS` is now blocked (managed code injection), but the CLR profiler API is a parallel native-code injection vector that isn't caught by the existing `LD_` prefix block:
| Variable | Role |
|---|---|
| `CORECLR_ENABLE_PROFILING` | Activates the profiler (`1` enables it) |
| `CORECLR_PROFILER` | CLSID of the profiler COM object |
| `CORECLR_PROFILER_PATH` / `CORECLR_PROFILER_PATH_64` | Path to the native profiler `.so`/`.dll` loaded before `Main()` |
Setting all three causes the .NET runtime to `dlopen` an arbitrary native library before any managed code runs — functionally equivalent to `LD_PRELOAD` but not covered by the `LD_` prefix block. If the goal is comprehensive .NET env injection coverage, consider adding these to `blockedKeys` (and mirroring in the generated Swift file).
How can I resolve this? If you propose a fix, please make it concise.Last reviewed commit: 7f8400b |
7b39412 to
a021dd4
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a021dd4611
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
fe2d404 to
7f8400b
Compare
Regression risk noteThese vars go into If someone runs their gateway on a host with In practice the overlap between "openclaw gateway host" and "JVM APM via env vars" is very small, and the security benefit (blocking -javaagent injection) outweighs the convenience loss. |
| "_JAVA_OPTIONS", | ||
| "JDK_JAVA_OPTIONS", | ||
| "PYTHONBREAKPOINT", | ||
| "DOTNET_STARTUP_HOOKS" |
There was a problem hiding this comment.
Missing .NET CLR profiler injection trio
DOTNET_STARTUP_HOOKS is now blocked (managed code injection), but the CLR profiler API is a parallel native-code injection vector that isn't caught by the existing LD_ prefix block:
| Variable | Role |
|---|---|
CORECLR_ENABLE_PROFILING |
Activates the profiler (1 enables it) |
CORECLR_PROFILER |
CLSID of the profiler COM object |
CORECLR_PROFILER_PATH / CORECLR_PROFILER_PATH_64 |
Path to the native profiler .so/.dll loaded before Main() |
Setting all three causes the .NET runtime to dlopen an arbitrary native library before any managed code runs — functionally equivalent to LD_PRELOAD but not covered by the LD_ prefix block. If the goal is comprehensive .NET env injection coverage, consider adding these to blockedKeys (and mirroring in the generated Swift file).
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/infra/host-env-security-policy.json
Line: 25
Comment:
**Missing .NET CLR profiler injection trio**
`DOTNET_STARTUP_HOOKS` is now blocked (managed code injection), but the CLR profiler API is a parallel native-code injection vector that isn't caught by the existing `LD_` prefix block:
| Variable | Role |
|---|---|
| `CORECLR_ENABLE_PROFILING` | Activates the profiler (`1` enables it) |
| `CORECLR_PROFILER` | CLSID of the profiler COM object |
| `CORECLR_PROFILER_PATH` / `CORECLR_PROFILER_PATH_64` | Path to the native profiler `.so`/`.dll` loaded before `Main()` |
Setting all three causes the .NET runtime to `dlopen` an arbitrary native library before any managed code runs — functionally equivalent to `LD_PRELOAD` but not covered by the `LD_` prefix block. If the goal is comprehensive .NET env injection coverage, consider adding these to `blockedKeys` (and mirroring in the generated Swift file).
How can I resolve this? If you propose a fix, please make it concise.…ost exec sandbox (openclaw#49025) Add JAVA_TOOL_OPTIONS, _JAVA_OPTIONS, JDK_JAVA_OPTIONS, PYTHONBREAKPOINT, and DOTNET_STARTUP_HOOKS to blockedKeys in the host exec security policy. Closes openclaw#22681
…ost exec sandbox (openclaw#49025) Add JAVA_TOOL_OPTIONS, _JAVA_OPTIONS, JDK_JAVA_OPTIONS, PYTHONBREAKPOINT, and DOTNET_STARTUP_HOOKS to blockedKeys in the host exec security policy. Closes openclaw#22681
…ost exec sandbox (openclaw#49025) Add JAVA_TOOL_OPTIONS, _JAVA_OPTIONS, JDK_JAVA_OPTIONS, PYTHONBREAKPOINT, and DOTNET_STARTUP_HOOKS to blockedKeys in the host exec security policy. Closes openclaw#22681 (cherry picked from commit f84a41d)
…ost exec sandbox (openclaw#49025) Add JAVA_TOOL_OPTIONS, _JAVA_OPTIONS, JDK_JAVA_OPTIONS, PYTHONBREAKPOINT, and DOTNET_STARTUP_HOOKS to blockedKeys in the host exec security policy. Closes openclaw#22681 (cherry picked from commit f84a41d)
…ost exec sandbox (openclaw#49025) Add JAVA_TOOL_OPTIONS, _JAVA_OPTIONS, JDK_JAVA_OPTIONS, PYTHONBREAKPOINT, and DOTNET_STARTUP_HOOKS to blockedKeys in the host exec security policy. Closes openclaw#22681
Closes #22681
JAVA_TOOL_OPTIONS,_JAVA_OPTIONS, andJDK_JAVA_OPTIONSlet an attacker inject-javaagentinto any JVM process spawned by an agent.PYTHONBREAKPOINTcan redirect Python'sbreakpoint()to an arbitrary callable likeos.system.DOTNET_STARTUP_HOOKSloads arbitrary assemblies into .NET hosts beforeMain()runs. None of these have legitimate use inside the exec sandbox.This adds all five vars to
blockedKeysinhost-env-security-policy.jsonand regenerates the Swift policy file. Strictly additive - no existing entries removed or moved.Changes
src/infra/host-env-security-policy.json: addJAVA_TOOL_OPTIONS,_JAVA_OPTIONS,JDK_JAVA_OPTIONS,PYTHONBREAKPOINT,DOTNET_STARTUP_HOOKStoblockedKeysapps/macos/Sources/OpenClaw/HostEnvSecurityPolicy.generated.swift: regenerated viascripts/generate-host-env-security-policy-swift.mjssrc/infra/host-env-security.test.ts: assertions for all new entries including case-insensitive matchWhy these specific vars?
JAVA_TOOL_OPTIONS-javaagent:/path/evil.jaron any JVM startup (JVMTI standard)_JAVA_OPTIONSJDK_JAVA_OPTIONSPYTHONBREAKPOINTbreakpoint()to arbitrary callable (e.g.os.system)DOTNET_STARTUP_HOOKSStartupHook.Initialize()beforeMain()Not included (already covered or not dangerous)
LD_PRELOAD,LD_LIBRARY_PATH,LD_AUDITcaught by existingLD_prefix blockDYLD_INSERT_LIBRARIEScaught byDYLD_prefix blockPYTHONPATHandPYTHONHOMEalready inblockedKeysPYTHONEXECUTABLEexcluded after verification - it only affectssys.argv[0]reporting on macOS, no execution controlPrior art
#45174 by @BenediktSchackenberg covers some of the same JVM vars but bundles them with unrelated changes to
blockedOverrideKeys(removes GIT_SSH, OPENSSL_CONF, HISTFILE, etc.). This PR is a focused subset that avoids those scope issues.Test plan
pnpm test -- src/infra/host-env-security.test.tspasses (11 tests)pnpm test -- src/agents/bash-tools.exec-runtime.testpasses (3 tests)pnpm checkclean