env: a NUL byte in a `--file` entry reaches `std::env::set_var` unvalidated and aborts the process (exit 134)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 src/uu/env/src/env.rs 第 331-338 行附近开始,跟踪 --file 路径从已解析条目到 std::env::set_var 的过程;将其与会保护 argv 路径的 apply_specified_env_vars 进行比较。复现 issue 中 key 和 value 的 NUL 情况,然后验证两者都会产生诊断并以不触发 panic 的方式失败,而不是以 exit 134 退出。
由索引模型根据 Issue 内容生成。
描述
env --file FILE parses an .env/INI file and passes each key and value straight to std::env::set_var, which panics when either contains a NUL byte. A single NUL anywhere in the file therefore aborts env with a Rust panic instead of a diagnostic.
The argv path (env NAME=VALUE ...) is guarded — apply_specified_env_vars checks for an empty name before calling set_var, but the --file path has no guard at all.
Steps to reproduce
A NUL in the value:
$ printf 'KEY=a\x00b\n' > conf.env
$ env --file conf.env
thread 'main' panicked at library/std/src/env.rs:361:9:
failed to set environment variable `"KEY"` to `"a\0b"`: file name contained an unexpected NUL byte
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ echo $?
134
A NUL in the key does the same:
$ printf 'a\x00b=c\n' > k.env
$ env --file k.env # exit 134, identical panic
Root cause
std::env::set_var panics if either argument contains a NUL. Nothing between the parser and this call validates the bytes.
- 主要语言
- Rust
- 星标
- 24.2k
- 派生
- 2.1k
- 平均合并
- 1 天 11 小时
- 30 天内合并 PR
- 333
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
uutils/coreutils 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
uutils/coreutils#14962 · 1 条评论 ·
维护者通常 1 天内回复
-
awaiting upstream B - low priority dependencies
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
awaiting upstream B - medium priority dependencies
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
B - high priority U - wc
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
software-challenge/player_rust#22 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
foundry-rs/foundry#17175 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
state:triage-needed
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
github/copilot-sdk#2793 ·
维护者通常 1 天内回复