Skip to content

Building 70 Projects ranging from beginner to advanced so anyone can — learn from, build upon, use as a reference, or even copy directly. Owned by my cybersecurity company đŸ‘‡

feat(lisdex): M8 exit gate - 28 checks, and the one that matters is the crash it agrees to disclose

CarterPerez-dev23e8a3ed81d0
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-core/src/config.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-core/src/config.rs
index 1bbd0f6f..b3d705b8 100644
--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-core/src/config.rs
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-core/src/config.rs
@@ -9,6 +9,11 @@ pub const DEFAULT_TRIALS: usize = 30;
pub const DEFAULT_REPRODUCE_TIMEOUT_MS: u64 = 10_000;
pub const DEFAULT_MINIMIZE_EXEC_TIMEOUT_MS: u64 = 1_000;
+pub const ENV_ASAN_OPTIONS: &str = "ASAN_OPTIONS";
+pub const ENV_UBSAN_OPTIONS: &str = "UBSAN_OPTIONS";
+pub const REPRODUCE_SANITIZER_OPTIONS: &str = "symbolize=0:detect_leaks=0:handle_segv=1";
+pub const REPRODUCE_SANITIZER_OPTIONS_WITH_LEAKS: &str = "symbolize=0:detect_leaks=1:handle_segv=1";
+
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum LlmTier {
None,
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-fuzz/src/runner.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-fuzz/src/runner.rs
index d97f6b25..58e3c246 100644
--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-fuzz/src/runner.rs
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-fuzz/src/runner.rs
@@ -7,7 +7,10 @@ use std::process::{Command, Stdio};
use std::time::{Duration, Instant};
use lisdex_core::campaign::CampaignId;
-use lisdex_core::config::DEFAULT_REPRODUCE_TIMEOUT_MS;
+use lisdex_core::config::{
+ DEFAULT_REPRODUCE_TIMEOUT_MS, ENV_ASAN_OPTIONS, ENV_UBSAN_OPTIONS,
+ REPRODUCE_SANITIZER_OPTIONS as SANITIZER_OPTIONS,
+};
use lisdex_core::crash::Crash;
use lisdex_core::report::SanitizerReport;
@@ -18,9 +21,6 @@ pub const DEFAULT_INSTANCE: &str = "default";
pub const MAX_REPORT_BYTES: usize = 256 * 1024;
const REPRODUCE_POLL_MS: u64 = 25;
-const ENV_ASAN_OPTIONS: &str = "ASAN_OPTIONS";
-const ENV_UBSAN_OPTIONS: &str = "UBSAN_OPTIONS";
-const SANITIZER_OPTIONS: &str = "symbolize=0:detect_leaks=0:handle_segv=1";
const UNPARSEABLE_REASON: &str = "no parseable sanitizer report";
const UNSYMBOLIZED_REASON: &str =
"no symbolized frames, so any key would be shared by every crash of this kind in this module";
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/bundle.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/bundle.rs
new file mode 100644
index 00000000..cc7d5c20
--- /dev/null
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/bundle.rs
@@ -0,0 +1,186 @@
+// ©AngelaMos | 2026
+// bundle.rs
+
+use std::fmt::Write as _;
+use std::path::{Path, PathBuf};
+
+use lisdex_core::config::{
+ ENV_ASAN_OPTIONS, ENV_UBSAN_OPTIONS, REPRODUCE_SANITIZER_OPTIONS,
+ REPRODUCE_SANITIZER_OPTIONS_WITH_LEAKS,
+};
+
+use crate::advisory::Advisory;
+use crate::{json, markdown};
+
+pub const ADVISORY_MARKDOWN: &str = "advisory.md";
+pub const ADVISORY_JSON: &str = "advisory.json";
+pub const REPRODUCER: &str = "poc";
+pub const SANITIZER_REPORT: &str = "report.txt";
+pub const REPRODUCE_SCRIPT: &str = "reproduce.sh";
+
+const LEAK_CLASS: &str = "memory-leaks";
+const SCRIPT_MODE: u32 = 0o755;
+
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub enum Reproducer {
+ Minimized,
+ Original,
+}
+
+impl Reproducer {
+ #[must_use]
+ pub fn note(self) -> &'static str {
+ match self {
+ Self::Minimized => {
+ "This input was reduced by afl-tmin and lisdex re-ran it to confirm it still \
+ produces the same stack signature as the crash it came from."
+ }
+ Self::Original => {
+ "This is the original crashing input as the fuzzer saved it, not a reduced one. \
+ lisdex only ships a reduced input when it has re-run it and confirmed the bug did \
+ not change underneath the reduction."
+ }
+ }
+ }
+}
+
+#[must_use]
+pub fn sanitizer_options(class: &str) -> &'static str {
+ if class == LEAK_CLASS {
+ REPRODUCE_SANITIZER_OPTIONS_WITH_LEAKS
+ } else {
+ REPRODUCE_SANITIZER_OPTIONS
+ }
+}
+
+#[must_use]
+pub fn reproduce_script(class: &str) -> String {
+ let options = sanitizer_options(class);
+ let mut script = String::new();
+ let _ = write!(
+ script,
+ "#!/bin/sh\n\
+ set -eu\n\
+ if [ $# -ne 1 ]; then\n\
+ \x20 echo \"usage: $0 <path to the built target>\" >&2\n\
+ \x20 exit 2\n\
+ fi\n\
+ {ENV_ASAN_OPTIONS}='{options}'\n\
+ {ENV_UBSAN_OPTIONS}='{options}'\n\
+ export {ENV_ASAN_OPTIONS} {ENV_UBSAN_OPTIONS}\n\
+ exec \"$1\" \"$(dirname \"$0\")/{REPRODUCER}\"\n"
+ );
+ script
+}
+
+fn make_executable(path: &Path) -> std::io::Result<()> {
+ #[cfg(unix)]
+ {
+ use std::os::unix::fs::PermissionsExt;
+ let mut permissions = std::fs::metadata(path)?.permissions();
+ permissions.set_mode(SCRIPT_MODE);
+ std::fs::set_permissions(path, permissions)?;
+ }
+ #[cfg(not(unix))]
+ {
+ let _ = path;
+ }
+ Ok(())
+}
+
+pub fn write(
+ dir: &Path,
+ advisory: &Advisory,
+ input: &[u8],
+ reproducer: Reproducer,
+) -> std::io::Result<Vec<PathBuf>> {
+ std::fs::create_dir_all(dir)?;
+
+ let markdown_path = dir.join(ADVISORY_MARKDOWN);
+ let json_path = dir.join(ADVISORY_JSON);
+ let poc_path = dir.join(REPRODUCER);
+ let report_path = dir.join(SANITIZER_REPORT);
+ let script_path = dir.join(REPRODUCE_SCRIPT);
+
+ std::fs::write(&markdown_path, markdown::render(advisory, Some(reproducer)))?;
+ std::fs::write(&json_path, json::render_string(advisory))?;
+ std::fs::write(&poc_path, input)?;
+ std::fs::write(&report_path, advisory.sanitizer_report())?;
+ std::fs::write(&script_path, reproduce_script(advisory.class()))?;
+ make_executable(&script_path)?;
+
+ Ok(vec![
+ markdown_path,
+ json_path,
+ poc_path,
+ report_path,
+ script_path,
+ ])
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn the_script_carries_the_same_options_the_reproduce_path_uses() {
+ let script = reproduce_script("heap-buffer-overflow(write)");
+ assert!(
+ script.contains(REPRODUCE_SANITIZER_OPTIONS),
+ "the bundle documents how to reproduce a crash lisdex produced, so it has to name the options lisdex actually ran under; a command that differs from the one that produced the report may simply not crash for the maintainer"
+ );
+ }
+
+ #[test]
+ fn a_leak_finding_is_reproduced_with_leak_detection_switched_on() {
+ assert_eq!(
+ sanitizer_options(LEAK_CLASS),
+ REPRODUCE_SANITIZER_OPTIONS_WITH_LEAKS
+ );
+ assert!(
+ REPRODUCE_SANITIZER_OPTIONS.contains("detect_leaks=0"),
+ "this is the whole reason the leak case needs its own options: the campaign reproduce path disables leak detection, so shipping it for a leak finding would hand over a command that reports nothing"
+ );
+ assert!(
+ reproduce_script(LEAK_CLASS).contains("detect_leaks=1"),
+ "and the emitted script has to carry the corrected options, not just the helper"
+ );
+ }
+
+ #[test]
+ fn every_other_class_keeps_the_campaign_options() {
+ for class in [
+ "heap-buffer-overflow(read)",
+ "heap-use-after-free(write)",
+ "double-free",
+ "SourceAvNearNull",
+ "",
+ ] {
+ assert_eq!(sanitizer_options(class), REPRODUCE_SANITIZER_OPTIONS);
+ }
+ }
+
+ #[test]
+ fn the_script_takes_the_target_from_the_caller_and_the_input_from_beside_itself() {
+ let script = reproduce_script("double-free");
+ assert!(
+ script.contains("exec \"$1\""),
+ "lisdex fuzzed a build at a path that means nothing on the maintainer's machine, so the target has to be an argument"
+ );
+ assert!(
+ script.contains("dirname"),
+ "the reproducer travels with the script, so the script must find it relative to itself rather than the caller's working directory"
+ );
+ assert!(script.starts_with("#!/bin/sh\nset -eu\n"));
+ }
+
+ #[test]
+ fn the_two_reproducer_kinds_say_different_things_about_what_was_verified() {
+ assert_ne!(
+ Reproducer::Minimized.note(),
+ Reproducer::Original.note(),
+ "shipping an unreduced input under a note claiming its identity was verified would overstate what lisdex checked"
+ );
+ assert!(Reproducer::Original.note().contains("not a reduced one"));
+ }
+}
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/lib.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/lib.rs
index ef8f33cb..ede42305 100644
--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/lib.rs
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/lib.rs
@@ -2,6 +2,7 @@
// lib.rs
pub mod advisory;
+pub mod bundle;
pub mod json;
pub mod markdown;
pub mod weakness;
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/markdown.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/markdown.rs
index f6d500fb..677fcbfa 100644
--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/markdown.rs
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/src/markdown.rs
@@ -6,6 +6,7 @@ use std::fmt::Write;
use lisdex_triage::severity::Severity;
use crate::advisory::{Advisory, OperatorInput, Provenance};
+use crate::bundle::{self, Reproducer};
const NOT_ESTABLISHED: &str = "NOT ESTABLISHED";
const OPERATOR_SUPPLIES: &str = "_(you supply this)_";
@@ -63,6 +64,11 @@ const GHSA_CREDIT_NOTE: &str = "GitHub's credit roles include `Tool` (\"Names of
vulnerability discovery or identification\") separately from `Finder` and `Reporter`, so \
lisdex can be credited without displacing the person who ran it.";
+const SYMBOLIZATION_NOTE: &str = "The frames below carry function names and source lines because \
+ lisdex resolved them after capturing the report. The script runs the sanitizer with \
+ `symbolize=0` deliberately, so a direct run prints raw module offsets instead — that is the \
+ same crash, not a different one.";
+
const PACKAGE_NAME_NOTE: &str = "The name above is whatever this campaign's target was called, \
which is usually the fuzz harness rather than the library as it is distributed. Check it \
before filing, and pass `--package` to set it.";
@@ -184,14 +190,28 @@ fn push_severity(out: &mut String, advisory: &Advisory) {
);
}
-fn push_proof_of_concept(out: &mut String, advisory: &Advisory) {
+fn push_proof_of_concept(out: &mut String, advisory: &Advisory, bundled: Option<Reproducer>) {
let _ = write!(
out,
- "{POC_HEADING}\n\nA {} byte input drives `{}` into this fault. The sanitizer report it \
- produced is reproduced verbatim below; it is the evidence, and it has not been edited.\n\n\
- ```\n{}\n```\n\n",
+ "{POC_HEADING}\n\nA {} byte input drives `{}` into this fault.",
advisory.reproducer_bytes(),
- advisory.target(),
+ advisory.target()
+ );
+ if let Some(reproducer) = bundled {
+ let _ = write!(
+ out,
+ " It is the file `{}` beside this one, and `./{} <path to the built target>` replays \
+ it under the same sanitizer options lisdex used. {}",
+ bundle::REPRODUCER,
+ bundle::REPRODUCE_SCRIPT,
+ reproducer.note()
+ );
+ let _ = write!(out, " {SYMBOLIZATION_NOTE}");
+ }
+ let _ = write!(
+ out,
+ " The sanitizer report it produced is reproduced verbatim below; it is the evidence, and \
+ it has not been edited.\n\n```\n{}\n```\n\n",
advisory.sanitizer_report().trim_end()
);
}
@@ -227,7 +247,7 @@ fn push_filing(out: &mut String, advisory: &Advisory) {
}
#[must_use]
-pub fn render(advisory: &Advisory) -> String {
+pub fn render(advisory: &Advisory, bundled: Option<Reproducer>) -> String {
let mut out = String::new();
let site = advisory.crash_site().unwrap_or(UNNAMED_SITE);
let _ = write!(
@@ -243,7 +263,7 @@ pub fn render(advisory: &Advisory) -> String {
let _ = write!(out, "{DRAFTED_BY}\n\n");
push_summary(&mut out, advisory);
push_severity(&mut out, advisory);
- push_proof_of_concept(&mut out, advisory);
+ push_proof_of_concept(&mut out, advisory, bundled);
let _ = write!(out, "{REMEDIATION_HEADING}\n\n{REMEDIATION_BODY}\n\n");
push_analysis(&mut out, advisory);
let _ = write!(out, "{TIMELINE_HEADING}\n\n{TIMELINE_BODY}\n\n");
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/tests/bundling.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/tests/bundling.rs
new file mode 100644
index 00000000..2db097d6
--- /dev/null
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/tests/bundling.rs
@@ -0,0 +1,128 @@
+// ©AngelaMos | 2026
+// bundling.rs
+
+use lisdex_core::campaign::CampaignId;
+use lisdex_core::crash::Crash;
+use lisdex_report::advisory::Advisory;
+use lisdex_report::bundle::{
+ self, ADVISORY_JSON, ADVISORY_MARKDOWN, REPRODUCE_SCRIPT, REPRODUCER, Reproducer,
+ SANITIZER_REPORT,
+};
+
+const CAMPAIGN: CampaignId = CampaignId(1);
+const POC: &[u8] = b"\x89PNG\r\n\x1a\n-crafted-bytes";
+
+const REAL_HEAP_WRITE: &str = "\
+=================================================================
+==53767==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x7bd6bfde0020 at pc 0x558474e40fd9
+WRITE of size 32 at 0x7bd6bfde0020 thread T0
+ #0 0x558474e40fd8 in png_handle_iCCP /src/libpng/pngrutil.c:1447:5
+ #1 0x558474e41111 in png_read_info /src/libpng/pngread.c:160:10
+SUMMARY: AddressSanitizer: heap-buffer-overflow (/out/harness+0xcdfd8) in png_handle_iCCP
+";
+
+const CANARY_CRASH: &str = "\
+=================================================================
+==29092==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000071a4 (pc 0x7fa6518a053b bp 0x1 sp 0x2 T0)
+==29092==The signal is caused by a READ memory access.
+ #0 0x7fa6518a053b in kill (/lib/x86_64-linux-gnu/libc.so.6+0x4553b)
+ #1 0x55a5aee02220 in magma_log /opt/magma/magma/src/canary.c:92:5
+ #2 0x55a5aee68dae in MAGMA_png_handle_PLTE /opt/magma-work/libpng/repo/pngrutil.c:992:4
+SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x4553b) in kill
+";
+
+fn advisory(report: &str) -> Advisory {
+ let crash = Crash::from_report(CAMPAIGN, POC.to_vec(), report);
+ Advisory::draft("libpng", &crash, 12).expect("fixture must draft")
+}
+
+fn scratch(name: &str) -> std::path::PathBuf {
+ let dir = std::env::temp_dir().join(format!("lisdex-bundle-test-{name}"));
+ let _ = std::fs::remove_dir_all(&dir);
+ dir
+}
+
+#[test]
+fn a_bundle_carries_every_file_a_maintainer_needs_and_nothing_is_empty() {
+ let dir = scratch("complete");
+ let written = bundle::write(&dir, &advisory(REAL_HEAP_WRITE), POC, Reproducer::Minimized)
+ .expect("bundle must write");
+
+ for name in [
+ ADVISORY_MARKDOWN,
+ ADVISORY_JSON,
+ REPRODUCER,
+ SANITIZER_REPORT,
+ REPRODUCE_SCRIPT,
+ ] {
+ let path = dir.join(name);
+ let meta = std::fs::metadata(&path)
+ .unwrap_or_else(|err| panic!("{name} must exist in the bundle: {err}"));
+ assert!(
+ meta.len() > 0,
+ "{name} is present but empty, which is worse than absent because the bundle looks complete"
+ );
+ }
+ assert_eq!(written.len(), 5);
+ let _ = std::fs::remove_dir_all(&dir);
+}
+
+#[test]
+fn the_reproducer_is_written_byte_for_byte() {
+ let dir = scratch("bytes");
+ bundle::write(&dir, &advisory(REAL_HEAP_WRITE), POC, Reproducer::Minimized)
+ .expect("bundle must write");
+ let written = std::fs::read(dir.join(REPRODUCER)).expect("poc must be readable");
+ assert_eq!(
+ written, POC,
+ "the reproducer is the one artifact that must survive byte-for-byte; a re-encoded or truncated PoC does not reproduce anything"
+ );
+ let _ = std::fs::remove_dir_all(&dir);
+}
+
+#[test]
+fn the_report_in_the_bundle_is_the_report_the_advisory_names() {
+ let dir = scratch("report");
+ let drafted = advisory(REAL_HEAP_WRITE);
+ bundle::write(&dir, &drafted, POC, Reproducer::Minimized).expect("bundle must write");
+ let written = std::fs::read_to_string(dir.join(SANITIZER_REPORT)).expect("report readable");
+ assert_eq!(
+ written,
+ drafted.sanitizer_report(),
+ "two copies of the evidence that disagree would leave a maintainer unable to tell which one the finding rests on"
+ );
+ let _ = std::fs::remove_dir_all(&dir);
+}
+
+#[test]
+fn a_bundle_for_a_planted_benchmark_bug_still_refuses_to_be_filed() {
+ let dir = scratch("planted");
+ bundle::write(&dir, &advisory(CANARY_CRASH), POC, Reproducer::Minimized)
+ .expect("bundle must write");
+ let rendered = std::fs::read_to_string(dir.join(ADVISORY_MARKDOWN)).expect("advisory readable");
+ assert!(
+ rendered.contains("DO NOT FILE THIS ADVISORY"),
+ "packaging a finding into a tidy bundle must not launder away the reason it cannot be disclosed"
+ );
+ let json: serde_json::Value =
+ serde_json::from_str(&std::fs::read_to_string(dir.join(ADVISORY_JSON)).expect("json"))
+ .expect("valid json");
+ assert_eq!(json["disclosable"], false);
+ let _ = std::fs::remove_dir_all(&dir);
+}
+
+#[test]
+fn the_bundled_advisory_points_at_the_files_beside_it_and_the_standalone_one_does_not() {
+ let drafted = advisory(REAL_HEAP_WRITE);
+ let dir = scratch("pointers");
+ bundle::write(&dir, &drafted, POC, Reproducer::Original).expect("bundle must write");
+ let bundled = std::fs::read_to_string(dir.join(ADVISORY_MARKDOWN)).expect("advisory readable");
+ assert!(bundled.contains(REPRODUCE_SCRIPT) && bundled.contains(Reproducer::Original.note()));
+
+ let standalone = lisdex_report::markdown::render(&drafted, None);
+ assert!(
+ !standalone.contains(REPRODUCE_SCRIPT),
+ "an advisory rendered on its own must not tell a reader to run a script that was never written beside it"
+ );
+ let _ = std::fs::remove_dir_all(&dir);
+}
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/tests/rendering.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/tests/rendering.rs
index 04d76c63..50fb36ef 100644
--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/tests/rendering.rs
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex-report/tests/rendering.rs
@@ -40,7 +40,7 @@ fn advisory(report: &str) -> Advisory {
#[test]
fn every_field_lisdex_declines_appears_in_the_rendered_advisory_with_its_reason() {
- let rendered = markdown::render(&advisory(REAL_HEAP_WRITE));
+ let rendered = markdown::render(&advisory(REAL_HEAP_WRITE), None);
for input in OPERATOR_INPUTS {
assert!(
rendered.contains(input.why()),
@@ -52,7 +52,7 @@ fn every_field_lisdex_declines_appears_in_the_rendered_advisory_with_its_reason(
#[test]
fn the_advisory_never_states_a_version_range_or_a_cvss_vector() {
- let rendered = markdown::render(&advisory(REAL_HEAP_WRITE));
+ let rendered = markdown::render(&advisory(REAL_HEAP_WRITE), None);
assert!(
!rendered.contains("CVSS:3.1/") && !rendered.contains("CVSS:4.0/"),
"a CVSS vector in this document would be derived from the crash class alone, which is a guess wearing a number"
@@ -65,7 +65,7 @@ fn the_advisory_never_states_a_version_range_or_a_cvss_vector() {
#[test]
fn a_planted_benchmark_finding_is_rendered_with_a_refusal_and_no_filing_instructions() {
- let rendered = markdown::render(&advisory(CANARY_CRASH));
+ let rendered = markdown::render(&advisory(CANARY_CRASH), None);
assert!(
rendered.contains("DO NOT FILE THIS ADVISORY"),
"the refusal has to be the first thing the reader meets, not a footnote"
@@ -78,7 +78,7 @@ fn a_planted_benchmark_finding_is_rendered_with_a_refusal_and_no_filing_instruct
#[test]
fn a_real_finding_is_rendered_with_the_filing_route_that_actually_applies() {
- let rendered = markdown::render(&advisory(REAL_HEAP_WRITE));
+ let rendered = markdown::render(&advisory(REAL_HEAP_WRITE), None);
assert!(!rendered.contains("DO NOT FILE THIS ADVISORY"));
assert!(
rendered.contains("There is no C or C++ ecosystem"),
@@ -92,7 +92,7 @@ fn a_real_finding_is_rendered_with_the_filing_route_that_actually_applies() {
#[test]
fn the_sanitizer_report_is_reproduced_verbatim_as_the_evidence() {
- let rendered = markdown::render(&advisory(REAL_HEAP_WRITE));
+ let rendered = markdown::render(&advisory(REAL_HEAP_WRITE), None);
assert!(
rendered.contains(REAL_HEAP_WRITE.trim_end()),
"the report is the evidence; an edited or reflowed copy is not the thing the sanitizer said"
@@ -101,7 +101,7 @@ fn the_sanitizer_report_is_reproduced_verbatim_as_the_evidence() {
#[test]
fn an_unassessed_severity_is_flagged_rather_than_presented_as_a_low_one() {
- let rendered = markdown::render(&advisory(UBSAN_REPORT));
+ let rendered = markdown::render(&advisory(UBSAN_REPORT), None);
assert!(
rendered.contains("Severity is unassessed for this finding"),
"UNDEFINED is the tier lisdex uses when it has no labelled corpus (B91); rendering it beside the other tiers with no caveat reads as an assessment that the finding is unremarkable"
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex/src/main.rs b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex/src/main.rs
index 2b46b895..7757de58 100644
--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex/src/main.rs
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/crates/lisdex/src/main.rs
@@ -30,6 +30,7 @@ use lisdex_harness::verify::{Bench, Corpus, Toolchain, Verdict};
use lisdex_ingest::acquire::{self, Source};
use lisdex_ingest::detect;
use lisdex_report::advisory::Advisory;
+use lisdex_report::bundle::{self, Reproducer};
use lisdex_report::{json, markdown};
use lisdex_surface::extract::{self, Language};
use lisdex_surface::surface::{self, SurfaceOptions};
@@ -102,6 +103,33 @@ enum Command {
about = "draft a coordinated-disclosure advisory for each distinct bug in a campaign"
)]
Advisory(AdvisoryArgs),
+ #[command(
+ about = "write a self-contained reproducer bundle per distinct bug: advisory, PoC, report, repro script"
+ )]
+ Bundle(BundleArgs),
+}
+
+#[derive(clap::Args)]
+struct BundleArgs {
+ #[arg(long, help = "sqlite database written by a previous campaign")]
+ db: PathBuf,
+ #[arg(long, help = "campaign id whose bugs to bundle")]
+ campaign: i64,
+ #[arg(
+ long,
+ help = "directory to write one bundle directory per distinct bug"
+ )]
+ out: PathBuf,
+ #[arg(
+ long,
+ help = "directory written by `lisdex minimize`; its verified .min reproducers are preferred over the original crashing inputs"
+ )]
+ minimized: Option<PathBuf>,
+ #[arg(
+ long,
+ help = "the library as it is distributed; defaults to the campaign's fuzz target, which is usually the harness name rather than the package name"
+ )]
+ package: Option<String>,
}
#[derive(Clone, Copy, clap::ValueEnum)]
@@ -434,6 +462,7 @@ fn dispatch() -> Result<(), Box<dyn Error>> {
Command::Verify(args) => verify(args),
Command::Crashes(args) => crashes(args),
Command::Advisory(args) => advisories(args),
+ Command::Bundle(args) => bundles(args),
Command::Minimize(args) => minimize_campaign(args),
Command::Llm(args) => llm(args),
}
@@ -1421,7 +1450,7 @@ fn advisories(args: &AdvisoryArgs) -> Result<(), Box<dyn Error>> {
println!("advisories {}", drafted.len());
for (stem, advisory) in &drafted {
let (text, suffix) = match args.format {
- AdvisoryFormat::Markdown => (markdown::render(advisory), MARKDOWN_SUFFIX),
+ AdvisoryFormat::Markdown => (markdown::render(advisory, None), MARKDOWN_SUFFIX),
AdvisoryFormat::Json => (json::render_string(advisory), JSON_SUFFIX),
};
let path = dir.join(format!("{stem}{suffix}"));
@@ -1440,6 +1469,68 @@ fn advisories(args: &AdvisoryArgs) -> Result<(), Box<dyn Error>> {
Ok(())
}
+fn bundles(args: &BundleArgs) -> Result<(), Box<dyn Error>> {
+ let store = Store::open(&args.db)?;
+ let campaign_id = CampaignId(args.campaign);
+ let campaign = store
+ .get_campaign(campaign_id)?
+ .ok_or("no such campaign in store")?;
+
+ let crashes = store.crashes_for_campaign(campaign_id)?;
+ let grouping = dedup::group_crashes(&crashes);
+ std::fs::create_dir_all(&args.out)?;
+
+ println!("distinct_bugs {}", grouping.keyed_bugs());
+ println!("unkeyed_crashes {}", grouping.unkeyed_crashes());
+
+ for group in grouping.groups() {
+ let Some(crash) = group.representative() else {
+ continue;
+ };
+ let stem = short_hash(crash.stack_hash());
+ let package = args.package.as_deref().unwrap_or_else(|| campaign.target());
+ let Some(advisory) = Advisory::draft(package, crash, group.len()) else {
+ eprintln!(
+ "warning: bug {stem} has no dedup key, so no advisory names it and no bundle is written"
+ );
+ continue;
+ };
+
+ let minimized = args
+ .minimized
+ .as_ref()
+ .map(|dir| dir.join(format!("{stem}{MINIMIZED_SUFFIX}")))
+ .filter(|path| path.is_file());
+ let (input, reproducer) = match &minimized {
+ Some(path) => (std::fs::read(path)?, Reproducer::Minimized),
+ None => (crash.input().to_vec(), Reproducer::Original),
+ };
+
+ let dir = args.out.join(&stem);
+ let written = bundle::write(&dir, &advisory, &input, reproducer)?;
+ println!(
+ " {stem} x{} {} files {} bytes {}{}",
+ group.len(),
+ written.len(),
+ input.len(),
+ dir.display(),
+ if advisory.is_disclosable() {
+ ""
+ } else {
+ NOT_DISCLOSABLE_MARKER
+ }
+ );
+ }
+
+ if args.minimized.is_none() {
+ eprintln!(
+ "warning: no --minimized directory given, so every bundle ships the original crashing input rather than a reduced one"
+ );
+ }
+
+ Ok(())
+}
+
fn print_advisories(
format: AdvisoryFormat,
drafted: &[(String, Advisory)],
@@ -1447,7 +1538,7 @@ fn print_advisories(
match format {
AdvisoryFormat::Markdown => {
for (_, advisory) in drafted {
- println!("{}", markdown::render(advisory));
+ println!("{}", markdown::render(advisory, None));
}
}
AdvisoryFormat::Json => {
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/justfile b/PROJECTS/advanced/zero-day-vulnerability-scanner/justfile
index b9fbfe68..46b35397 100644
--- a/PROJECTS/advanced/zero-day-vulnerability-scanner/justfile
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/justfile
@@ -81,3 +81,9 @@ m7-gate:
m7-gate-reset:
docker compose -f dev.compose.yml exec toolchain bash scripts/m7-gate.sh reset
+
+m8-gate:
+ docker compose -f dev.compose.yml exec toolchain bash scripts/m8-gate.sh
+
+m8-gate-reset:
+ docker compose -f dev.compose.yml exec toolchain bash scripts/m8-gate.sh reset
diff --git a/PROJECTS/advanced/zero-day-vulnerability-scanner/scripts/m8-gate.sh b/PROJECTS/advanced/zero-day-vulnerability-scanner/scripts/m8-gate.sh
new file mode 100755
index 00000000..584c2e8d
--- /dev/null
+++ b/PROJECTS/advanced/zero-day-vulnerability-scanner/scripts/m8-gate.sh
@@ -0,0 +1,279 @@
+#!/usr/bin/env bash
+# ©AngelaMos | 2026
+# m8-gate.sh
+
+set -euo pipefail
+
+WORK="${MAGMA_WORK:-/opt/magma-work}"
+REPO="$WORK/libpng/repo"
+OUT_ROOT="$WORK/out/libpng"
+SEEDS="$WORK/libpng/corpus/libpng_read_fuzzer"
+GATE="$WORK/m8"
+FIXTURES="/work/crates/lisdex-triage/tests/fixtures"
+FINDINGS="$GATE/findings"
+DB="$GATE/lisdex.sqlite"
+FIXTURE_DB="$GATE/fixtures.sqlite"
+MIN_OUT="$GATE/minimized"
+BUNDLES="$GATE/bundles"
+STANDALONE="$GATE/standalone"
+GATE_LOG="$GATE/stage.log"
+LISDEX_BIN="${CARGO_TARGET_DIR:-/cargo-target}/debug/lisdex"
+TARGET="$OUT_ROOT/afl/lisdex_libpng_read"
+CMPLOG="$OUT_ROOT/cmplog/lisdex_libpng_read"
+GATE_DURATION="${LISDEX_M8_DURATION:-600}"
+PACKAGE="libpng"
+FIXTURE_COUNT=19
+IDENTITY_FRAMES=4
+BUNDLE_FILES=5
+
+FAILURES=0
+
+log() { printf '\n[m8] %s\n' "$1"; }
+die() { printf '\n[m8] FAIL: %s\n' "$1" >&2; exit 1; }
+pass() { printf ' PASS %s\n' "$1"; }
+fail() { printf ' FAIL %s\n' "$1"; FAILURES=$((FAILURES + 1)); }
+
+if [ "${1:-}" = "reset" ]; then
+ log "resetting $GATE"
+ rm -rf "$GATE"
+fi
+
+[ -d "$REPO" ] || die "magma libpng not fetched; run: just magma-libpng"
+[ -x "$TARGET" ] || die "magma libpng not built; run: just magma-libpng"
+[ -x "$CMPLOG" ] || die "cmplog target missing at $CMPLOG"
+[ -d "$SEEDS" ] || die "seed corpus missing at $SEEDS"
+[ -d "$FIXTURES" ] || die "captured report fixtures missing at $FIXTURES"
+
+mkdir -p "$GATE"
+
+log "stage 1/8: build lisdex"
+cargo build -p lisdex
+[ -x "$LISDEX_BIN" ] || die "lisdex binary not found at $LISDEX_BIN"
+
+log "stage 2/8: the report layer answers for itself"
+# The end-to-end checks below all read one rendered advisory, so a single corpus-wide
+# assertion cannot tell the provenance guard from the refusal rendering from the bundle
+# writer. Each owns tests that no other mechanism can satisfy.
+if cargo test -p lisdex-report > "$GATE_LOG" 2>&1; then
+ pass "lisdex-report unit and integration tests"
+else
+ fail "lisdex-report tests (see $GATE_LOG)"
+fi
+
+log "stage 3/8: a crash that cannot be keyed is never named as a bug"
+rm -f "$FIXTURE_DB"
+sqlite3 "$FIXTURE_DB" <<'SQL'
+CREATE TABLE campaigns (id INTEGER PRIMARY KEY, target TEXT NOT NULL, status TEXT NOT NULL);
+CREATE TABLE crashes (
+ id INTEGER PRIMARY KEY,
+ campaign_id INTEGER NOT NULL REFERENCES campaigns(id),
+ input BLOB NOT NULL,
+ sanitizer_report TEXT NOT NULL,
+ stack_hash TEXT
+);
+INSERT INTO campaigns (id, target, status) VALUES (1, 'captured-reports', 'completed');
+SQL
+for fixture in "$FIXTURES"/*.txt; do
+ sqlite3 "$FIXTURE_DB" \
+ "INSERT INTO crashes (campaign_id, input, sanitizer_report, stack_hash)
+ VALUES (1, zeroblob(1), CAST(readfile('$fixture') AS TEXT), NULL);"
+done
+LOADED="$(sqlite3 "$FIXTURE_DB" 'SELECT COUNT(*) FROM crashes;')"
+if [ "$LOADED" -eq "$FIXTURE_COUNT" ]; then
+ pass "$LOADED captured reports loaded as a campaign the shipped binary reads"
+else
+ fail "expected $FIXTURE_COUNT captured reports, loaded $LOADED"
+fi
+
+"$LISDEX_BIN" advisory --db "$FIXTURE_DB" --campaign 1 --package "$PACKAGE" \
+ --format json > "$GATE/fixture-advisories.json" 2> "$GATE/fixture-advisories.err" || true
+# These captures are verbatim ASAN output taken with symbolize=0, so every frame is a bare
+# module offset. Keying one would give every crash in that module the same identity, so the
+# triage layer refuses, and an advisory that cannot name one bug is not written at all.
+if [ "$(python3 -c 'import json,sys; print(len(json.load(open(sys.argv[1]))))' "$GATE/fixture-advisories.json")" -eq 0 ] \
+ && grep -q "$FIXTURE_COUNT crashes carry no dedup key" "$GATE/fixture-advisories.err"; then
+ pass "$FIXTURE_COUNT unsymbolized captures produce no advisory, and the binary says why"
+else
+ fail "an advisory was drafted for a crash that could only be keyed on a module offset"
+fi
+
+log "stage 4/8: re-find a magma bug (${GATE_DURATION}s)"
+rm -rf "$FINDINGS" "$DB"
+"$LISDEX_BIN" fuzz --target "$TARGET" --cmplog "$CMPLOG" --seeds "$SEEDS" \
+ --findings "$FINDINGS" --db "$DB" --duration "$GATE_DURATION" \
+ > "$GATE_LOG" 2>&1 || die "campaign failed (see $GATE_LOG)"
+
+BUGS="$("$LISDEX_BIN" crashes --db "$DB" --campaign 1 2>/dev/null | grep -c 'stack_hash' || true)"
+if [ "$BUGS" -gt 0 ]; then
+ pass "campaign persisted $BUGS crash(es)"
+else
+ fail "campaign found no crashes; the gate has nothing to report on"
+fi
+
+log "stage 5/8: minimize, then bundle"
+rm -rf "$MIN_OUT" "$BUNDLES" "$STANDALONE"
+"$LISDEX_BIN" minimize --db "$DB" --campaign 1 --target "$TARGET" --out "$MIN_OUT" \
+ > "$GATE/minimize.log" 2>&1 || die "minimize failed (see $GATE/minimize.log)"
+MINIMIZED="$(find "$MIN_OUT" -name '*.min' | wc -l)"
+if [ "$MINIMIZED" -gt 0 ]; then
+ pass "$MINIMIZED identity-verified reproducer(s) written"
+else
+ fail "no .min reproducer survived identity verification"
+fi
+
+"$LISDEX_BIN" bundle --db "$DB" --campaign 1 --package "$PACKAGE" \
+ --minimized "$MIN_OUT" --out "$BUNDLES" > "$GATE/bundle.log" 2>&1 \
+ || die "bundle failed (see $GATE/bundle.log)"
+"$LISDEX_BIN" advisory --db "$DB" --campaign 1 --package "$PACKAGE" \
+ --out "$STANDALONE" > /dev/null 2>&1 || die "standalone advisory failed"
+
+BUNDLE_DIRS="$(find "$BUNDLES" -mindepth 1 -maxdepth 1 -type d | sort)"
+BUNDLE_COUNT="$(printf '%s\n' "$BUNDLE_DIRS" | grep -c . || true)"
+if [ "$BUNDLE_COUNT" -gt 0 ]; then
+ pass "$BUNDLE_COUNT bundle(s) written"
+else
+ fail "no bundle written"
+fi
+
+log "stage 6/8: every bundle is complete, refuses disclosure, and states what it declined"
+for dir in $BUNDLE_DIRS; do
+ stem="$(basename "$dir")"
+ present="$(find "$dir" -maxdepth 1 -type f -size +0c | wc -l)"
+ if [ "$present" -eq "$BUNDLE_FILES" ]; then
+ pass "$stem: $BUNDLE_FILES non-empty files"
+ else
+ fail "$stem: $present non-empty files, expected $BUNDLE_FILES"
+ fi
+
+ if cmp -s "$dir/poc" "$MIN_OUT/$stem.min"; then
+ pass "$stem: the bundled reproducer is byte-identical to the verified minimized input"
+ else
+ fail "$stem: the bundled reproducer is NOT the file minimize verified"
+ fi
+
+ python3 - "$dir/advisory.json" <<'PY' && pass "$stem: the machine-readable advisory refuses what it cannot establish" || fail "$stem: advisory.json states something lisdex never measured"
+import json, sys
+d = json.load(open(sys.argv[1]))
+ghsa = d["ghsa"]
+assert ghsa["ecosystem"] == "other", ghsa["ecosystem"]
+for field in ("vulnerable_version_range", "patched_versions", "cvss_vector_string", "cve_id"):
+ assert ghsa[field] is None, f"{field} was invented: {ghsa[field]}"
+assert len(d["declined"]) == 3, d["declined"]
+assert d["disclosable"] is False, "a magma canary finding must never be disclosable"
+assert d["provenance"] == "synthetic_benchmark", d["provenance"]
+PY
+
+ if grep -q 'DO NOT FILE THIS ADVISORY' "$dir/advisory.md"; then
+ pass "$stem: the advisory leads with the refusal, and the bundle did not launder it away"
+ else
+ fail "$stem: a planted benchmark bug was packaged with no refusal"
+ fi
+
+ if grep -q 'Anyone with admin permissions' "$dir/advisory.md"; then
+ fail "$stem: an undisclosable finding carries filing instructions"
+ else
+ pass "$stem: no filing route is offered for a finding that must not be filed"
+ fi
+
+ if grep -qE 'CVSS:3\.1/|CVSS:4\.0/' "$dir/advisory.md"; then
+ fail "$stem: the advisory states a CVSS vector it cannot derive from a crash"
+ else
+ pass "$stem: no CVSS vector is asserted"
+ fi
+
+ if grep -q 'NOT ESTABLISHED' "$dir/advisory.md"; then
+ pass "$stem: declined fields are named in the page, not silently dropped"
+ else
+ fail "$stem: the advisory declines fields without saying so"
+ fi
+
+ if grep -q 'reproduce.sh' "$STANDALONE/$stem.md"; then
+ fail "$stem: the standalone advisory points at a script that was never written beside it"
+ else
+ pass "$stem: the standalone advisory claims no files it did not ship"
+ fi
+done
+
+log "stage 7/8: the same crash without benchmark frames IS disclosable"
+# Everything above asserts NOT DISCLOSABLE, which a guard hardwired to refuse everything
+# would also satisfy. This takes one report the campaign really produced and removes only
+# the benchmark instrumentation from it - the canary runtime frame, and the MAGMA_ prefix
+# the harness patcher adds - leaving the same fault in the same functions as the library
+# ships them. If that does not come back disclosable, the mark means nothing.
+CONTROL_DB="$GATE/control.sqlite"
+rm -f "$CONTROL_DB"
+sqlite3 "$CONTROL_DB" <<'SQL'
+CREATE TABLE campaigns (id INTEGER PRIMARY KEY, target TEXT NOT NULL, status TEXT NOT NULL);
+CREATE TABLE crashes (
+ id INTEGER PRIMARY KEY,
+ campaign_id INTEGER NOT NULL REFERENCES campaigns(id),
+ input BLOB NOT NULL,
+ sanitizer_report TEXT NOT NULL,
+ stack_hash TEXT
+);
+INSERT INTO campaigns (id, target, status) VALUES (1, 'libpng', 'completed');
+SQL
+FIRST_BUNDLE="$(printf '%s\n' "$BUNDLE_DIRS" | head -1)"
+grep -v 'in magma_log ' "$FIRST_BUNDLE/report.txt" | sed 's/ in MAGMA_/ in /' > "$GATE/control-report.txt"
+if grep -qE 'magma_log|MAGMA_' "$GATE/control-report.txt"; then
+ fail "the control still carries benchmark instrumentation, so it controls nothing"
+else
+ pass "the control report retains the fault and drops only the benchmark frames"
+fi
+sqlite3 "$CONTROL_DB" \
+ "INSERT INTO crashes (campaign_id, input, sanitizer_report, stack_hash)
+ VALUES (1, zeroblob(1), CAST(readfile('$GATE/control-report.txt') AS TEXT), NULL);"
+"$LISDEX_BIN" advisory --db "$CONTROL_DB" --campaign 1 --package "$PACKAGE" \
+ --format json > "$GATE/control-advisories.json" 2>/dev/null || true
+python3 - "$GATE/control-advisories.json" <<'PY' && pass "the de-instrumented crash drafts an advisory and it IS disclosable" || fail "the guard refuses a crash with no benchmark frames in it, so NOT DISCLOSABLE is a constant"
+import json, sys
+documents = json.load(open(sys.argv[1]))
+assert documents, "no advisory drafted from the de-instrumented report"
+for d in documents:
+ assert d["disclosable"] is True, f"{d['dedup_key']} still undisclosable"
+ assert d["provenance"] == "field", d["provenance"]
+print(f" {len(documents)} advisory, disclosable, provenance field")
+PY
+if grep -q 'Anyone with admin permissions' "$GATE/control-advisories.json" \
+ || "$LISDEX_BIN" advisory --db "$CONTROL_DB" --campaign 1 --package "$PACKAGE" 2>/dev/null \
+ | grep -q 'Anyone with admin permissions'; then
+ pass "and it carries the filing route the undisclosable findings withhold"
+else
+ fail "a disclosable advisory was rendered without a filing route"
+fi
+
+log "stage 8/8: the shipped reproducer still crashes, and the bundles do not all carry the same bug"
+SIGNATURES="$GATE/signatures.txt"
+: > "$SIGNATURES"
+for dir in $BUNDLE_DIRS; do
+ stem="$(basename "$dir")"
+ output="$GATE/$stem.replay"
+ ( cd "$dir" && ./reproduce.sh "$TARGET" ) > "$output" 2>&1 || true
+ if grep -qE 'ERROR: (AddressSanitizer|LeakSanitizer)' "$output"; then
+ pass "$stem: the emitted reproduce.sh reproduces the fault on the shipped PoC"
+ else
+ fail "$stem: the emitted reproduce.sh did NOT reproduce (see $output)"
+ fi
+ grep -oE '\(/[^ ]+\+0x[0-9a-f]+\)' "$output" | head -"$IDENTITY_FRAMES" \
+ | tr '\n' ' ' >> "$SIGNATURES"
+ printf '\n' >> "$SIGNATURES"
+done
+
+DISTINCT="$(sort -u "$SIGNATURES" | grep -c . || true)"
+if [ "$DISTINCT" -eq "$BUNDLE_COUNT" ]; then
+ pass "all $BUNDLE_COUNT bundle(s) replay to distinct top-$IDENTITY_FRAMES signatures, so no two ship the same bug"
+else
+ fail "$BUNDLE_COUNT bundle(s) replayed to only $DISTINCT distinct signature(s)"
+fi
+
+log "RESULT"
+if [ "$FAILURES" -eq 0 ]; then
+ printf '\n[m8] M8 EXIT GATE PASSED\n'
+ printf ' CHECK 1 a re-found magma bug yields a complete advisory and reproducer bundle\n'
+ printf ' CHECK 2 that bundle is stamped NOT DISCLOSABLE, and carries no filing route\n'
+ printf ' CHECK 3 real captured errors are still disclosable, so the mark is not a constant\n'
+ printf ' CHECK 4 the shipped reproducer replays the fault it names\n'
+ exit 0
+fi
+printf '\n[m8] M8 EXIT GATE FAILED: %s check(s)\n' "$FAILURES" >&2
+exit 1