Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
**Vulnerability:** The `verify_github_sig` function in `apps/server/src/infra_routes.rs` verified GitHub webhook signatures using standard string comparison `expected.eq_ignore_ascii_case(hex_sig)`.
**Learning:** String comparison functions exit early as soon as a character mismatch is found. In a cryptographic context, this variable response time leaks information and allows an attacker to perform a timing attack to forge a valid HMAC signature by guessing it byte by byte.
**Prevention:** Always use a constant-time comparison library (like `hmac`'s `verify_slice()`) to compare cryptographic hashes, secrets, and signatures to prevent side-channel timing attacks. Avoid custom implementations of standard cryptographic algorithms.
## 2024-05-18 - Exact Token Matching in Command Validation
**Vulnerability:** Command validation in `workdir_cmd.rs` relied on joined strings for multi-word blocked phrases (e.g., `rm `), which allowed an attacker to bypass it by placing the sensitive token at the end of the command string (e.g., `npm run rm`).
**Learning:** Checking a joined string for an exact blocked token padding (like `rm `) is insufficient as it fails to catch exact matches that appear as the last argument where no trailing space exists. Relying solely on tokenized matches also breaks multi-word blocked phrases. Both checks must be implemented simultaneously for robustness.
**Prevention:** Always verify both the joined command string against multi-word blocked phrases AND individual tokenized arguments for exact matches of sensitive binaries.
15 changes: 15 additions & 0 deletions crates/agent/src/tools/workdir_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,20 @@ fn validate_command(raw: &str) -> std::result::Result<Vec<String>, String> {
return Err(format!("token interdit dans la commande : {bad}"));
}
}
for part in &parts {
let p_lower = part.to_ascii_lowercase();
if p_lower == "rm"
|| p_lower == "sudo"
|| p_lower == "chmod"
|| p_lower == "chown"
|| p_lower == "curl"
|| p_lower == "wget"
|| p_lower == "ssh"
|| p_lower == "scp"
{
return Err(format!("token exact interdit dans la commande : {}", part));
}
}
let bin = parts[0].as_str();
let bin_base = Path::new(bin)
.file_name()
Expand Down Expand Up @@ -354,6 +368,7 @@ mod tests {
fn blocks_obfuscated_commands() {
assert!(validate_command("npm run \"s\"udo").is_err());
assert!(validate_command("cat \"..\"/\"..\"/etc/passwd").is_err());
assert!(validate_command("npm run rm").is_err());
}
}

Expand Down
Loading