fix(worker): security audit of R0 — no core dumps, tkill/tgkill limited to SIGABRT on self, mmap without PROT_EXEC, Broken outcome for a broken child environment, frame vs canvas check, unsafe denied with local allows, sandbox tests and derivation on the release profile (syscall marker); wasm proof exports behind a feature; ci: release-images hardened (typed input via env, advisories gate, ephemeral builder, env secrets + logout, ref gate, pinned checkout)

This commit is contained in:
bchanot committed 2026-10-13 00:18:53 +02:00
1 parent 9d3e0294e2
commit 11813f5560
14 files changed
+293 -58

No files matched your search

+30 -9
View File
@@ -79,13 +79,20 @@ pub fn inspect(bytes: &[u8]) -> Result<WebpSummary, WebpIssue> {
if !ALLOWED_CHUNKS.contains(&&fourcc) {
return Err(WebpIssue::ForbiddenChunk(fourcc));
}
if dimensions.is_none() {
dimensions = match &fourcc {
b"VP8X" => Some(parse_vp8x(payload)?),
b"VP8 " => Some(parse_vp8(payload)?),
b"VP8L" => Some(parse_vp8l(payload)?),
_ => None,
};
let declared = match &fourcc {
b"VP8X" => Some(parse_vp8x(payload)?),
b"VP8 " => Some(parse_vp8(payload)?),
b"VP8L" => Some(parse_vp8l(payload)?),
_ => None,
};
// The canvas (VP8X) and the frame (VP8 / VP8L) must agree: a container whose frame
// disagrees with its canvas is not something the encoder produces.
match (dimensions, declared) {
(None, Some(size)) => dimensions = Some(size),
(Some(canvas), Some(frame)) if canvas != frame => {
return Err(WebpIssue::BadBitstream);
}
_ => {}
}
chunks.push(fourcc);
offset = end + (size & 1);
@@ -164,11 +171,25 @@ mod tests {
#[test]
fn a_square_vp8x_file_passes() {
let bytes = riff(&[(b"VP8X", &vp8x(512, 512)), (b"VP8 ", &[0; 20])]);
let mut vp8 = vec![0u8; 20];
vp8[3..6].copy_from_slice(&[0x9d, 0x01, 0x2a]);
vp8[6..8].copy_from_slice(&512u16.to_le_bytes());
vp8[8..10].copy_from_slice(&512u16.to_le_bytes());
let bytes = riff(&[(b"VP8X", &vp8x(512, 512)), (b"VP8 ", &vp8)]);
let summary = expect_square(&bytes, 512);
assert_eq!(summary.map(|s| (s.width, s.height)), Ok((512, 512)));
}
#[test]
fn a_frame_disagreeing_with_its_canvas_is_refused() {
let mut vp8 = vec![0u8; 10];
vp8[3..6].copy_from_slice(&[0x9d, 0x01, 0x2a]);
vp8[6..8].copy_from_slice(&256u16.to_le_bytes());
vp8[8..10].copy_from_slice(&512u16.to_le_bytes());
let bytes = riff(&[(b"VP8X", &vp8x(512, 512)), (b"VP8 ", &vp8)]);
assert_eq!(inspect(&bytes), Err(WebpIssue::BadBitstream));
}
#[test]
fn metadata_chunks_are_refused() {
let bytes = riff(&[(b"VP8X", &vp8x(512, 512)), (b"EXIF", b"x")]);
@@ -177,7 +198,7 @@ mod tests {
#[test]
fn wrong_sizes_are_refused() {
let bytes = riff(&[(b"VP8X", &vp8x(511, 512)), (b"VP8 ", &[0; 20])]);
let bytes = riff(&[(b"VP8X", &vp8x(511, 512))]);
assert_eq!(
expect_square(&bytes, 512),
Err(WebpIssue::Dimensions {