xai-org/grok-build · error
InvalidData
InvalidData
Error message
invalid bwrap runtime-socket deny handoff: {error} What it means
When bwrap (bubblewrap) sandboxing hands its runtime-socket deny list to the inner process via an environment variable, `runtime_socket_deny_paths_for_context_with_policy` reads that variable. `Err(NotPresent)` means no handoff happened and is fine, but any other `VarError` (e.g. `NotUnicode`) means the handoff is malformed, so the function fails with `InvalidData` rather than silently dropping sandbox denies.
Source
Thrown at crates/codegen/xai-grok-sandbox/src/runtime_sockets.rs:80
fn runtime_socket_deny_paths_for_resolution() -> io::Result<Vec<PathBuf>> {
if !(cfg!(target_os = "linux") && crate::is_inside_bwrap()) {
return materialize_runtime_socket_deny_paths();
}
runtime_socket_deny_paths_for_context_with_policy(
std::env::var(BWRAP_RUNTIME_SOCKET_DENY_ENV_VAR),
runtime_socket_deny_paths(),
)
}
fn runtime_socket_deny_paths_for_context_with_policy(
handed: Result<String, std::env::VarError>,
allowed: Vec<PathBuf>,
) -> io::Result<Vec<PathBuf>> {
match handed {
Ok(encoded) => decode_bwrap_runtime_socket_denies_with_policy(&encoded, allowed),
Err(std::env::VarError::NotPresent) => Ok(Vec::new()),
Err(error) => Err(io::Error::new(
io::ErrorKind::InvalidData,
format!("invalid bwrap runtime-socket deny handoff: {error}"),
)),
}
}
/// Missing candidates are skipped; every other resolution failure is returned.
fn materialize_runtime_socket_deny_paths_from(
candidates: impl IntoIterator<Item = PathBuf>,
) -> io::Result<Vec<PathBuf>> {
let mut paths = Vec::new();
for candidate in candidates {
let with_context = |error: io::Error| {
io::Error::new(
error.kind(),
format!(
"could not resolve runtime-socket deny path {}: {error}",
candidate.display()View on GitHub (pinned to bc7f02eddd)
Solutions
- Fix whatever sets the handoff env var so it only writes valid UTF-8 (JSON) content
- Unset the corrupted env var so the code takes the NotPresent path and re-derives socket denies from policy
- Check for environment-forging (the code deliberately fails closed on malformed handoff as a security measure)
- Log the `VarError` to identify which var is malformed
Example fix
// before (shell wrapper) export BWRAP_SOCKET_DENIES=$(printf '\xff\xfe garbage') // after export BWRAP_SOCKET_DENIES='["/run/user/1000/bus"]'
Defensive patterns
Strategy: try-catch
Validate before calling
if let Some(v) = std::env::var_os("BWRAP_RUNTIME_SOCKET_DENIES") {
if v.to_str().is_none() {
eprintln!("handoff var contains non-UTF-8 data; unset it");
}
} Try / catch
match runtime_socket_deny_paths_for_resolution(ctx) {
Err(e) if e.kind() == io::ErrorKind::InvalidData && e.to_string().starts_with("invalid bwrap runtime-socket deny handoff") => {
log::warn!("malformed bwrap handoff, falling back to policy discovery");
// recompute denies from policy instead
}
other => other,
} Prevention
- Only write UTF-8 JSON into the handoff env var
- Unset rather than partially clear the variable
- Audit wrapper scripts that export the variable
When it happens
Trigger: Reading the bwrap handoff env var when it exists but contains non-UTF-8 bytes (`std::env::VarError::NotUnicode`), i.e. the variable was set with invalid unicode by the parent process or forged externally.
Common situations: A corrupted or tampered environment inside a bubblewrap sandbox; misbehaving wrapper scripts exporting binary garbage into the handoff variable; security tests forging the variable with non-UTF-8 content.
Related errors
- Marketplace source blocked: {}
- deny glob {glob:?} uses unsupported metacharacter '{c}' (bra
- deny glob {glob:?}: empty path segment (a doubled '//' or tr
- no clipboard backend available
- Server returned unsupported verification URI scheme
AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31).
Data as JSON: /api/errors/0930b87f7ce40500.
Report an issue: GitHub.