Commit 02740b4
fix(rlm): add SAFETY comment to production set_var in auto_configure_llm
Resolves the P3-1 finding from #2797 (security-sentinel 2026-06-20 scan):
`crates/terraphim_rlm/src/rlm.rs:942` called `unsafe { std::env::set_var(...) }`
in a non-test auto-configure path with no `// SAFETY:` justification, unlike the
established pattern in `terraphim_spawner/src/lib.rs` (pre_exec setrlimit).
Rust 2024 made `set_var` unsafe because env vars are process-global and mutating
one races concurrent readers. Document the invariant that makes this call sound:
`auto_configure_llm` runs once at RLM startup initialisation, before any worker
tasks or child processes are spawned, so there are no concurrent readers of
`OPENROUTER_API_KEY` at the call site. The key value originates from a trusted
source (env var or 1Password), not untrusted input.
Comment-only change: zero behavioural change, zero new code. Surgical scope per
the issue's P3-1 remediation note ("add SAFETY justification" — moving to a
config struct is explicitly the alternative, not required).
Verification (this session):
- cargo check -p terraphim_rlm -> clean (5.30s)
- cargo test -p terraphim_rlm --lib -> 135 passed, 0 failed
- cargo fmt -p terraphim_rlm --check on this hunk -> clean (the crate-wide
fmt drift reported is pre-existing on origin/main, unrelated to this comment)
- cargo clippy -p terraphim_rlm --all-targets -> the 3 errors
(2x doc-list-indent, 1x redundant_closure) are PRE-EXISTING on origin/main
(verified by stashing this edit and re-running on pristine HEAD); this
comment-only change introduces zero new lint findings
- ubs crates/terraphim_rlm/src/rlm.rs -> 0 critical, 0 warning
The P1-1 (LLM proxy 0.0.0.0:3456) and P1-2 (git2 unsound) findings from #2797
are host-infra / upstream respectively and out of scope for this surgical fix;
P1-1 requires human root on bigbox (fleet agents blocked by no_new_privs per
the recurring sentinel comments).
Refs #2797
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 55e959a commit 02740b4
1 file changed
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
938 | 938 | | |
939 | 939 | | |
940 | 940 | | |
941 | | - | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
| 950 | + | |
942 | 951 | | |
943 | 952 | | |
944 | 953 | | |
| |||
0 commit comments