fix: reject DEL character (0x7F) in input validation (#122)

The reject_control_chars helper rejected bytes 0x00-0x1F but allowed
the DEL character (0x7F), which is also an ASCII control character.
This could allow malformed input from LLM agents to bypass validation.
This commit is contained in:
Joe Eftekhari
2026-03-04 20:50:09 -10:00
committed by GitHub
parent 263a8e5479
commit 364542b2c5
2 changed files with 17 additions and 2 deletions
+9
View File
@@ -0,0 +1,9 @@
---
"@googleworkspace/cli": patch
---
fix: reject DEL character (0x7F) in input validation
The `reject_control_chars` helper rejected bytes 0x000x1F but allowed
the DEL character (0x7F), which is also an ASCII control character. This
could allow malformed input from LLM agents to bypass validation.
+8 -2
View File
@@ -118,9 +118,10 @@ pub fn validate_safe_dir_path(dir: &str) -> Result<PathBuf, GwsError> {
Ok(canonical)
}
/// Rejects strings containing null bytes or ASCII control characters.
/// Rejects strings containing null bytes or ASCII control characters
/// (including DEL, 0x7F).
fn reject_control_chars(value: &str, flag_name: &str) -> Result<(), GwsError> {
if value.bytes().any(|b| b < 0x20) {
if value.bytes().any(|b| b < 0x20 || b == 0x7F) {
return Err(GwsError::Validation(format!(
"{flag_name} contains invalid control characters"
)));
@@ -388,6 +389,11 @@ mod tests {
assert!(reject_control_chars("hello\nworld", "test").is_err());
}
#[test]
fn test_reject_control_chars_del() {
assert!(reject_control_chars("hello\x7Fworld", "test").is_err());
}
// -- encode_path_segment --------------------------------------------------
#[test]