Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/fuzz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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
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
# (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
- 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
3 changes: 1 addition & 2 deletions .github/workflows/sbom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 5 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
target/
corpus/
artifacts/
coverage/
Cargo.lock
30 changes: 30 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions fuzz/fuzz_targets/wire_decode.rs
Original file line number Diff line number Diff line change
@@ -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);
});
Loading