From a9c58b407eb602c792e047c0c484a23a48987544 Mon Sep 17 00:00:00 2001 From: Toni Bergholm Date: Sat, 18 Jul 2026 12:31:56 +0300 Subject: [PATCH 1/3] test(fuzz): nightly cargo-fuzz target on the wire decode surface (OSTIF T-13, G-001) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fuzz/ standalone workspace (excluded from root): libfuzzer-sys target wire_decode covering the framed wire reader (read_frame_opt — the ADR-0039 self-identified residual weakness), Request::decode, parse_response, every body decoder, and Object::decode. - .github/workflows/fuzz.yml: nightly schedule + workflow_dispatch, 10-minute libFuzzer run, crash reproducers uploaded on failure, SHA-pinned actions, contents:read. Never a PR gate. - The fuzz crate carries the same [patch.crates-io] glib pin as the root workspace so dependency resolution matches production. Verified: cargo check clean locally (Homebrew Rust has no rustup/ nightly, so the libFuzzer build is verified via a dispatched CI run on this branch — see PR). --- .github/workflows/fuzz.yml | 51 ++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- fuzz/.gitignore | 5 ++++ fuzz/Cargo.toml | 30 +++++++++++++++++++ fuzz/fuzz_targets/wire_decode.rs | 37 +++++++++++++++++++++++ 5 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/fuzz.yml create mode 100644 fuzz/.gitignore create mode 100644 fuzz/Cargo.toml create mode 100644 fuzz/fuzz_targets/wire_decode.rs diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml new file mode 100644 index 00000000..0230f58b --- /dev/null +++ b/.github/workflows/fuzz.yml @@ -0,0 +1,51 @@ +name: fuzz + +# Nightly libFuzzer run on the remote-facing decode surface (OSTIF audit +# T-13, G-001): the framed wire protocol `sc serve` parses from untrusted +# peers, its body decoders, and canonical object decoding. Runs on a +# schedule, never as a PR gate — nightly + sanitizers don't belong in the +# merge path. A crash uploads its reproducer input as an artifact. +on: + schedule: + # Nightly, before the 06:23 audit run. + - cron: "17 3 * * *" + # Build + short run when the fuzz surface itself changes, so a broken + # harness is caught in the PR that breaks it (not a required check). + pull_request: + paths: + - "fuzz/**" + - ".github/workflows/fuzz.yml" + workflow_dispatch: + +permissions: + contents: read + +jobs: + wire-decode: + name: cargo fuzz (wire_decode) + runs-on: ubuntu-latest + timeout-minutes: 30 + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: dtolnay/rust-toolchain@2fe4ca74464c5902a4f6e302d0a619b4ea911ccc # tag 1.96.1; toolchain input overrides + with: + toolchain: nightly + - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 + with: + workspaces: fuzz + - name: install cargo-fuzz + run: cargo install cargo-fuzz --locked + - name: build fuzz target + run: cargo fuzz build wire_decode + - name: fuzz for 10 minutes + # rss_limit above MAX_OBJECT_SIZE-sized legitimate allocations so the + # documented frame-length pre-allocation (ADR-0039 deferred item) + # doesn't false-positive; a real runaway still trips it. + run: cargo fuzz run wire_decode -- -max_total_time=600 -rss_limit_mb=4096 + - name: upload crash reproducers + if: failure() + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 + with: + name: fuzz-artifacts + path: fuzz/artifacts/ + if-no-files-found: ignore diff --git a/Cargo.toml b/Cargo.toml index 414c83d2..742e6e0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace] resolver = "2" members = ["crates/core", "crates/vfs", "crates/gitio", "crates/crypto", "crates/repo", "crates/cli", "crates/tlsio", "apps/desktop/src-tauri"] -exclude = ["vendor/glib-0.18.5-patched"] +exclude = ["vendor/glib-0.18.5-patched", "fuzz"] # Tauri 2's Linux GTK3 stack is pinned to glib 0.18.5, whose VariantStrIter # implementation contains RUSTSEC-2024-0429. This published-source copy carries diff --git a/fuzz/.gitignore b/fuzz/.gitignore new file mode 100644 index 00000000..ab0eaa1a --- /dev/null +++ b/fuzz/.gitignore @@ -0,0 +1,5 @@ +target/ +corpus/ +artifacts/ +coverage/ +Cargo.lock diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml new file mode 100644 index 00000000..1a509897 --- /dev/null +++ b/fuzz/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "scl-fuzz" +version = "0.0.0" +publish = false +edition = "2021" + +# Its own workspace: fuzz targets need nightly + libFuzzer and must not join +# the stable root workspace (root Cargo.toml excludes this directory). +[workspace] + +[package.metadata] +cargo-fuzz = true + +[dependencies] +libfuzzer-sys = "0.4" +scl-core = { path = "../crates/core" } +scl-repo = { path = "../crates/repo" } + +[patch.crates-io] +glib = { path = "../vendor/glib-0.18.5-patched" } + +[[bin]] +name = "wire_decode" +path = "fuzz_targets/wire_decode.rs" +test = false +doc = false +bench = false + +[profile.release] +debug = 1 diff --git a/fuzz/fuzz_targets/wire_decode.rs b/fuzz/fuzz_targets/wire_decode.rs new file mode 100644 index 00000000..bbb24d38 --- /dev/null +++ b/fuzz/fuzz_targets/wire_decode.rs @@ -0,0 +1,37 @@ +//! Fuzz the remote-facing decode surface: the framed wire protocol that +//! `sc serve` parses from untrusted peers, and the canonical object decoding +//! underneath it. ADR-0039 hardened these paths against hostile input and +//! self-identified the frame-length header as the residual weak point — this +//! target exercises exactly that surface (OSTIF audit T-13, G-001). +//! +//! The invariant under test is totality: every entry point returns Ok or Err +//! on arbitrary bytes; a panic, overflow, or runaway allocation is a finding. + +#![no_main] + +use libfuzzer_sys::fuzz_target; +use std::io::Cursor; + +use scl_repo::wire; + +fuzz_target!(|data: &[u8]| { + // The socket layer: attacker bytes through the frame reader, then each + // recovered frame through both request and response parsing. + let mut cur = Cursor::new(data); + while let Ok(Some(frame)) = wire::read_frame_opt(&mut cur) { + let _ = wire::Request::decode(&frame); + let _ = wire::parse_response(frame); + } + + // The same bytes straight into each body decoder (a hostile peer controls + // frame payloads independently of the framing). + let _ = wire::Request::decode(data); + let _ = wire::decode_refs_body(data); + let _ = wire::decode_ids_body(data); + let _ = wire::decode_str_body(data); + let _ = wire::decode_u32_body(data); + let _ = wire::decode_bool_body(data); + + // The object layer transfers ultimately deserialize into. + let _ = scl_core::Object::decode(data); +}); From 49708035ccf5f54bc645978d0c01987d3efcb7d6 Mon Sep 17 00:00:00 2001 From: Toni Bergholm Date: Sat, 18 Jul 2026 12:40:35 +0300 Subject: [PATCH 2/3] =?UTF-8?q?fix(ci):=20rust-toolchain=20pins=20carry=20?= =?UTF-8?q?the=20version=20in=20the=20tag=20SHA=20=E2=80=94=20nightly=20ta?= =?UTF-8?q?g=20for=20fuzz,=20drop=20ignored=20toolchain=20inputs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dtolnay/rust-toolchain tag commits hardcode their toolchain and have no 'toolchain' input (surfaced as a warning annotation on the first sbom run, and a hard failure on the fuzz job which needed nightly but got 1.96.1). Pin the nightly tag's SHA for fuzz.yml; remove the ignored inputs from ci.yml/sbom.yml and correct comments. --- .github/workflows/ci.yml | 6 +++--- .github/workflows/fuzz.yml | 7 ++++--- .github/workflows/sbom.yml | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e7aaa06..cb986592 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,11 +36,11 @@ jobs: libssl-dev \ libayatana-appindicator3-dev \ librsvg2-dev - # SHA-pinned; the toolchain version no longer rides on the action ref, so - # it must be passed explicitly (kept in sync with rust-toolchain.toml). + # dtolnay/rust-toolchain hardcodes the version in the tag commit the SHA + # pins (no `toolchain` input exists at it) — this is the `1.96.1` tag, + # kept in sync with rust-toolchain.toml. Bump = new tag's SHA. - uses: dtolnay/rust-toolchain@2fe4ca74464c5902a4f6e302d0a619b4ea911ccc # 1.96.1 with: - toolchain: 1.96.1 components: rustfmt, clippy - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 - name: fmt diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 0230f58b..4d1b0847 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -27,9 +27,10 @@ jobs: timeout-minutes: 30 steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - - uses: dtolnay/rust-toolchain@2fe4ca74464c5902a4f6e302d0a619b4ea911ccc # tag 1.96.1; toolchain input overrides - with: - toolchain: nightly + # dtolnay/rust-toolchain encodes the toolchain in the tag the SHA pins + # (there is no `toolchain` input at these commits) — this is the + # `nightly` tag's commit. + - uses: dtolnay/rust-toolchain@4fd1da8b0805d2d2e936788875a7d65dbd677dc2 # nightly - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 with: workspaces: fuzz diff --git a/.github/workflows/sbom.yml b/.github/workflows/sbom.yml index 5d9ffd6d..2cacf687 100644 --- a/.github/workflows/sbom.yml +++ b/.github/workflows/sbom.yml @@ -25,9 +25,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + # The pinned tag commit hardcodes 1.96.1 (no `toolchain` input exists). - uses: dtolnay/rust-toolchain@2fe4ca74464c5902a4f6e302d0a619b4ea911ccc # 1.96.1 - with: - toolchain: 1.96.1 - name: install cargo-cyclonedx run: cargo install cargo-cyclonedx --locked --version 0.5.9 - name: rust SBOMs (binaries, all target platforms) From e25befe102707bd316791d416a8e133db054f760 Mon Sep 17 00:00:00 2001 From: Toni Bergholm Date: Sat, 18 Jul 2026 12:42:55 +0300 Subject: [PATCH 3/3] fix(fuzz): RUSTUP_TOOLCHAIN=nightly outranks the repo-root toolchain file rust-toolchain.toml pins stable 1.96.1 and silently overrode the installed nightly default inside the checkout ('option Z is only accepted on the nightly compiler'). Job-level env wins over the file. --- .github/workflows/fuzz.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/fuzz.yml b/.github/workflows/fuzz.yml index 4d1b0847..27014a5c 100644 --- a/.github/workflows/fuzz.yml +++ b/.github/workflows/fuzz.yml @@ -25,6 +25,11 @@ jobs: name: cargo fuzz (wire_decode) runs-on: ubuntu-latest timeout-minutes: 30 + env: + # The repo-root rust-toolchain.toml pins stable 1.96.1 and overrides the + # installed rustup default; libFuzzer needs nightly, and this env var + # outranks the toolchain file. + RUSTUP_TOOLCHAIN: nightly steps: - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 # dtolnay/rust-toolchain encodes the toolchain in the tag the SHA pins