Skip to content

Commit 8e606f3

Browse files
committed
fix(sandbox-backend): raise control frame limit to 2 MiB
The default macOS system CA bundle (~334 KB) inflates ~3.3x under serde's JSON byte-array encoding, pushing StartAgent past the 1 MiB MAX_CONTROL_FRAME_BYTES limit and failing every VM-backed sandbox create. Add a test that round-trips a 400 KB CA bundle through the frame encoder to pin the invariant. Closes #3453 Signed-off-by: Florent Benoit <fbenoit@redhat.com>
1 parent 8bd3dcc commit 8e606f3

1 file changed

Lines changed: 30 additions & 1 deletion

File tree

crates/openshell-sandbox-backend/src/boundary_protocol.rs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use serde::{Deserialize, Serialize};
3232
use sha2::{Digest as _, Sha256};
3333
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
3434

35-
pub const MAX_CONTROL_FRAME_BYTES: usize = 1024 * 1024;
35+
pub const MAX_CONTROL_FRAME_BYTES: usize = 2 * 1024 * 1024;
3636
pub const STREAM_STDIN: u8 = 0;
3737
pub const STREAM_STDOUT: u8 = 1;
3838
pub const STREAM_STDERR: u8 = 2;
@@ -1330,6 +1330,35 @@ mod tests {
13301330
));
13311331
}
13321332

1333+
#[test]
1334+
fn start_agent_with_large_ca_bundle_fits_in_frame_limit() {
1335+
let request = RequestEnvelope::new(Request::StartAgent {
1336+
sandbox_id: "sandbox-1".to_string(),
1337+
spec: AgentSpecWire {
1338+
program: "/bin/true".to_string(),
1339+
args: Vec::new(),
1340+
workdir: None,
1341+
timeout_secs: 5,
1342+
interactive: false,
1343+
},
1344+
policy: Box::new(SandboxPolicyWire::from(SandboxPolicy {
1345+
version: 1,
1346+
filesystem: FilesystemPolicy::default(),
1347+
network: NetworkPolicy::default(),
1348+
landlock: LandlockPolicy::default(),
1349+
process: ProcessPolicy::default(),
1350+
})),
1351+
ca_cert: Some(vec![0xAB; 16 * 1024]),
1352+
ca_bundle: Some(vec![0xCD; 400 * 1024]),
1353+
provider_env_revision: 0,
1354+
provider_env: std::collections::HashMap::new(),
1355+
})
1356+
.expect("request envelope");
1357+
let frame = encode_frame(&request).expect("large CA bundle must fit in frame limit");
1358+
let decoded: RequestEnvelope = decode_frame(&frame).expect("round-trip");
1359+
assert_eq!(decoded, request);
1360+
}
1361+
13331362
#[test]
13341363
fn rejects_declared_oversize() {
13351364
let oversized = u32::try_from(MAX_CONTROL_FRAME_BYTES + 1).expect("test size fits u32");

0 commit comments

Comments
 (0)