diff --git a/book/src/security/overview.md b/book/src/security/overview.md index e5449b9342..ffa4104804 100644 --- a/book/src/security/overview.md +++ b/book/src/security/overview.md @@ -10,6 +10,7 @@ PhotoCraft processes complex attacker-controlled files and exposes automation th | Raster codecs | Default dimension/pixel/allocation limits; decoder-specific budgets; malformed/property tests; fuzz targets | Continuous fuzzing and more format-specific semantic cases | | `.pcraft` | Manifest/blob/total-byte limits; bounded decompression; CRC/hash and version checks; fuzz target | Tighter complexity/entry limits and directory-bundle path-race analysis | | Engine commands | Error-return contract, focused bad-parameter tests, adversarial `panic_hunt` test | Continue eliminating input-derived panic and exhaustion paths | +| Automation filesystem | Separate read roots and one write root held as directory capabilities; traversal and symlink escapes refused; writes are atomic replacements | A hardlink inside a root still reads the inode it names outside the root; writing over it replaces only the link, leaving the outside name unchanged | | Control TCP | Loopback binding; bearer-token authentication; rooted read/write authority; 1 MiB request lines; 8 MiB replies; 16 active connections; I/O timeouts | No general method capabilities, encryption, client identity, explicit JSON-depth policy, aggregate session-memory/command-duration budgets, or audit trail | | MCP | Stdio; typed tools; authenticated and bounded bridge; rooted read/write authority; 256-step batches with aggregate reply budgets; headless preview/output ceilings | No general tool authorization scopes, aggregate session-memory accounting, or command cancellation; desktop screenshot capture is admission-bounded (4 outstanding requests, 128 MiB per image, 256 MiB aggregate, 8 s deadline) but that admission is far above the 8 MiB reply cap | | Dependencies | Cargo lockfile and normal CI build/test/clippy | No `cargo-audit` or `cargo-deny` job/configuration confirmed in current tree | diff --git a/crates/automation/src/workspace/tests.rs b/crates/automation/src/workspace/tests.rs index d7ff20a3ed..a19a35e7ea 100644 --- a/crates/automation/src/workspace/tests.rs +++ b/crates/automation/src/workspace/tests.rs @@ -1499,6 +1499,22 @@ fn same_root_leaf_link_save_replaces_the_link_without_writing_its_target() { assert!(!std::fs::symlink_metadata(inside.join("link.png")).unwrap().file_type().is_symlink()); } +/// A hardlink inside a root names the outside inode, so it reads that content. Writing over it is +/// an atomic replace of the directory entry: the other name and its inode keep their bytes. +#[cfg(unix)] +#[test] +fn hardlink_inside_a_root_reads_the_target_but_write_over_replaces_the_link() { + let (inside, outside, workspace) = roots("hardlink"); + let target = outside.join("target.png"); + std::fs::write(&target, b"outside").unwrap(); + std::fs::hard_link(&target, inside.join("linked.png")).unwrap(); + + assert_eq!(workspace.read("linked.png").unwrap(), b"outside"); + workspace.write("linked.png", b"replacement").unwrap(); + assert_eq!(std::fs::read(&target).unwrap(), b"outside", "the outside inode is not modified"); + assert_eq!(std::fs::read(inside.join("linked.png")).unwrap(), b"replacement"); +} + #[test] fn directory_pcraft_uses_ordered_roots_without_falling_back_after_selection() { let (library, work, _) = roots("pcraft-ordered"); diff --git a/crates/io/src/svg/tests.rs b/crates/io/src/svg/tests.rs index d8a60194b3..2fe64fbd87 100644 --- a/crates/io/src/svg/tests.rs +++ b/crates/io/src/svg/tests.rs @@ -1045,7 +1045,14 @@ fn the_deepest_chain_of_embedded_svg_images_fits_a_small_stack() { for levels in 1..=MAX_EMBEDDED_SVG_DEPTH + 1 { match rasterize_bounded(chain(levels).as_bytes(), 1.0, MAX_RASTER_PIXELS) { Ok(buf) => { - assert!(buf.px[4 * 8 + 4][3] > 0.99, "{levels} levels: the innermost rect draws through every level"); + let drawn = buf.px[4 * 8 + 4][3] > 0.99; + if levels > MAX_EMBEDDED_SVG_DEPTH { + // A chain past the limit is left out rather than rejected; it must not + // still draw its innermost image through the exhausted depth budget. + assert!(!drawn, "{levels} levels: the too-deep image is left out"); + break; + } + assert!(drawn, "{levels} levels: the innermost rect draws through every level"); accepted = levels; } Err(_) => assert!(accepted > 0, "a one-level chain renders"),