fix: restrict WriteAgentStateFile to explicit filename allowlist
Addresses mara's security review: replace validate_state_filename (which accepted any non-traversal filename) with a tight allowlist containing only the two known credential filenames: forge-token and matrix-token. Also addresses argus review feedback: - drop issue tag from priv_proto.rs doc comment - add comment explaining the path-detection heuristic in forge.rs - add note about create_dir_all uid=0 edge case in write_agent_state_file
This commit is contained in:
parent
eb51362d50
commit
89092caba4
3 changed files with 29 additions and 16 deletions
|
|
@ -241,12 +241,13 @@ pub enum PrivRequest {
|
|||
///
|
||||
/// Required because hive-c0re runs as the unprivileged `hive-core`
|
||||
/// user and cannot write to agent-owned (0755) state directories
|
||||
/// after the privsep introduced in #702.
|
||||
/// after the privsep that moved c0re from root to a dedicated unix user.
|
||||
WriteAgentStateFile {
|
||||
/// Logical agent name (validated by `validate_agent_name`).
|
||||
agent_name: String,
|
||||
/// Plain filename within the state dir — no path separators allowed.
|
||||
/// Example: `"forge-token"`, `"matrix-token"`.
|
||||
/// Allowlisted credential filename within the state dir.
|
||||
/// Only `"forge-token"` and `"matrix-token"` are accepted;
|
||||
/// hive-priv rejects any other value.
|
||||
filename: String,
|
||||
/// File content to write. Written as-is; caller is responsible for
|
||||
/// including any trailing newline.
|
||||
|
|
|
|||
Loading…
Reference in a new issue