Skip to content

fix(jq): prevent process env pollution in jq builtin#452

Merged
chaliy merged 1 commit intomainfrom
claude/fix-410-Y2nIj
Mar 1, 2026
Merged

fix(jq): prevent process env pollution in jq builtin#452
chaliy merged 1 commit intomainfrom
claude/fix-410-Y2nIj

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Mar 1, 2026

Summary

  • Replace std::env::set_var() calls with a custom env implementation that reads from ctx.env/ctx.variables directly
  • Eliminates thread-unsafety, host env info leak, and race conditions between concurrent jq calls

Closes #410

Test plan

  • Tests verify env variables are accessible via jaq without mutating process env
  • Tests verify host env vars don't leak
  • cargo test --all-features passes (1451+ tests)
  • cargo clippy and cargo fmt pass

@chaliy chaliy force-pushed the claude/fix-410-Y2nIj branch from 38a7b32 to 0612557 Compare March 1, 2026 09:04
Replace std::env::set_var() calls with a custom env implementation that
passes shell variables to jaq via a global variable ($__bashkit_env__).
The `env` filter is overridden with `def env: $__bashkit_env__;` which
reads from the injected object instead of the process environment.

This fixes three issues (TM-INF-013):
- Thread-unsafe: set_var is unsound in multi-threaded contexts
- Info leak: host process env vars were visible to jq's env filter
- Race condition: concurrent jq calls could corrupt each other's env

https://claude.ai/code/session_01WZjYqxm5xMPAEe7FSHJkDy
@chaliy chaliy force-pushed the claude/fix-410-Y2nIj branch from 0612557 to 33590cb Compare March 1, 2026 09:09
@chaliy chaliy merged commit 827d747 into main Mar 1, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[H-4] Process env pollution in jq builtin (thread-unsafe)

2 participants