Security: App keys and decrypted env vars written with world-readable permissions
还没有人认领这个 Issue。
评估
调研方向
从 dstack-util/src/system_setup.rs 中 AppKeys 在第 1350-1351 行附近的写入,以及第 1409-1419 行附近已解密环境变量的写入开始。了解这些文件是如何打开和写入的,然后确认新写入的机密文件仅限所有者访问,而不是所有人都可读。两个写入路径都使用限制性权限,并且现有的 Rust 检查通过后,即可视为完成。
由索引模型根据 Issue 内容生成。
描述
Note: This issue documents a vulnerability that was originally reported privately as the repository security advisory GHSA-535m-2x67-prhm by @pbeza.
Root Cause
fs::write() is used with default permissions (0o644) to write AppKeys to the filesystem. The AppKeys structure contains disk_crypt_key, env_crypt_key, and k256_key — all highly sensitive cryptographic secrets. Similarly, decrypted environment variables are written to files with default world-readable permissions.
// Default fs::write() creates files with 0o644 permissions
fs::write(&app_keys_path, serde_json::to_string(&app_keys)?)?;
Attack Path
- Any process inside the CVM can read
/path/to/app-keys.json - Attacker compromises any container workload (web vulnerability, dependency exploit, etc.)
- Compromised process reads
app-keys.jsonwithdisk_crypt_key,env_crypt_key,k256_key - Attacker can decrypt the disk, decrypt environment variables, and use the k256 signing key
Impact
Any compromised process inside the CVM can read all application cryptographic keys and decrypted environment variables. This includes the disk encryption key (enables offline disk reading), the env encryption key (decrypts all environment secrets), and the k256 key (enables signing as the CVM).
Suggested Fix
Set restrictive permissions before writing:
use std::os::unix::fs::OpenOptionsExt;
let mut file = std::fs::OpenOptions::new()
.write(true)
.create(true)
.truncate(true)
.mode(0o600)
.open(&app_keys_path)?;
file.write_all(serde_json::to_string(&app_keys)?.as_bytes())?;
Consider further restricting to 0o400 (read-only by owner) after the initial write.
Note: This finding was reported automatically as part of an AI/Claude-driven internal audit by the NEAR One MPC team. It has not been manually verified by a human to confirm whether it constitutes an actual security issue.
- 主要语言
- Rust
- 星标
- 551
- 派生
- 97
- 平均合并
- 19 小时 22 分钟
- 30 天内合并 PR
- 109
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Dstack-TEE/dstack 的其他 Issue
-
难度 5/5 一周以上 新手友好度 30/100
Dstack-TEE/dstack#1301 ·
-
难度 3/5 1-2 天 新手友好度 55/100
Dstack-TEE/dstack#1300 ·
-
难度 4/5 3-5 天 新手友好度 48/100
Dstack-TEE/dstack#1299 ·
-
难度 4/5 3-5 天 新手友好度 48/100
Dstack-TEE/dstack#1298 ·
-
P0
难度 5/5 一周以上 新手友好度 25/100
Dstack-TEE/dstack#1297 ·
查看 Dstack-TEE/dstack 的全部 Issue
相似的 Issue
-
bug github_actions
难度 2/5 1-3 小时 新手友好度 75/100
registrystack/registry-stack#1393 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
longbridge/gpui-kit#3223 ·
-
bug engine
难度 2/5 1-3 小时 新手友好度 65/100
rocky-data/rocky#2181 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
oasisprotocol/oasis-sdk#2523 ·
-
bot:ai-assisted component:indexer QA-roadmap status:untriaged
难度 2/5 1-3 小时 新手友好度 75/100
midnightntwrk/midnight-indexer#1557 ·