Reject NUL bytes in reviewed terminal input (#41354)

## Why

Manual terminal-input approvals shell-quote the proposed input, which cannot
preserve NUL bytes for an accurate review.

## What changed

Reject terminal input containing a NUL byte before creating an approval request
or sending any of the input to the terminal.

## Testing

Extend the unreviewable-input integration test to cover both oversized input
and NUL-containing input, and verify that rejected input is not executed.

GitOrigin-RevId: e738c59ba5570012663bf6168ad052be237ca226
This commit is contained in:
jif
2026-08-28 15:44:48 +00:00
committed by copyberry
parent 868c9edb0d
commit 39507eea53
2 changed files with 22 additions and 11 deletions
@@ -217,6 +217,12 @@ impl ProcessEntry {
if sandbox_permissions == SandboxPermissions::UseDefault && !strict_auto_review {
return Ok(None);
}
// Manual approvals shell-quote the input, which cannot preserve NUL bytes.
if input.contains('\0') {
return Err(approval_error(
"terminal input contains a NUL byte and cannot be reviewed safely",
));
}
let reason = permissions
.approval_reason(sandbox_permissions)
.map_err(approval_error)?;