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 👇
Go aicertificationcloud-engineeringcybercybersecuritycybersecurity-analystcybersecurity-certificationcybersecurity-certificationscybersecurity-educationcybersecurity-jobscybersecurity-portfoliocybersecurity-projectscybersecurity-toolsgrchackinglearningpentestingproject-repositoryprojetcspython
// ©AngelaMos | 2026
// advisory.rs
use lisdex_core::campaign::TreeProvenance;
use lisdex_core::dedup::CrashGroup;
use lisdex_core::report::SanitizerReport;
use lisdex_triage::boundary::{FaultAddress, group_is_security_relevant};
use lisdex_triage::classify::classify;
use lisdex_triage::severity::Severity;
use crate::weakness::{Weakness, weakness_for};
const BENCHMARK_CANARY_FRAME: &str = "magma_log";
const BENCHMARK_FUNCTION_PREFIX: &str = "MAGMA_";
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Provenance {
Field,
SyntheticBenchmark,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum OperatorInput {
AffectedVersionRange,
CvssVector,
AttackerReachability,
}
impl OperatorInput {
#[must_use]
pub fn field(self) -> &'static str {
match self {
Self::AffectedVersionRange => "Affected version range",
Self::CvssVector => "CVSS vector and score",
Self::AttackerReachability => "Attacker-reachability of this entry point",
}
}
#[must_use]
pub fn why(self) -> &'static str {
match self {
Self::AffectedVersionRange => {
"lisdex fuzzed one build and persists no version identifier for it. Establishing \
the earliest affected release means building and re-testing released versions, \
which this campaign did not do."
}
Self::CvssVector => {
"A CVSS vector encodes attack complexity, privileges required, user interaction \
and scope. None of those are observable from a crash, and a score derived from \
the crash class alone would be a guess wearing a number."
}
Self::AttackerReachability => {
"lisdex drove a harness it synthesized against a ranked entry point. That the \
entry point is public API is measured; that a real deployment feeds it \
attacker-controlled bytes is a judgement about the consumer, not the library."
}
}
}
}
pub const OPERATOR_INPUTS: [OperatorInput; 3] = [
OperatorInput::AffectedVersionRange,
OperatorInput::CvssVector,
OperatorInput::AttackerReachability,
];
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Advisory {
target: String,
key: String,
class: String,
severity: Severity,
weakness: Option<Weakness>,
security_relevant: bool,
crash_site: Option<String>,
frames: Vec<String>,
crash_count: usize,
reproducer_bytes: usize,
provenance: Provenance,
tree: TreeProvenance,
sanitizer_report: String,
}
impl Advisory {
#[must_use]
pub fn draft(target: &str, group: &CrashGroup<'_>, tree: TreeProvenance) -> Option<Advisory> {
let representative = group.representative()?;
let text = representative.sanitizer_report();
let parsed = SanitizerReport::parse(text)?;
let classification = classify(text)?;
let key = representative.stack_hash()?.to_owned();
let faults: Vec<FaultAddress> = group
.crashes()
.iter()
.map(|crash| {
SanitizerReport::parse(crash.sanitizer_report())
.map_or(FaultAddress::Absent, |report| {
FaultAddress::of(report.fault_address())
})
})
.collect();
Some(Advisory {
target: target.to_owned(),
key,
class: classification.class().to_owned(),
severity: classification.severity(),
weakness: weakness_for(classification.class()),
security_relevant: group_is_security_relevant(classification.fault_address(), &faults),
crash_site: parsed.crash_site().map(str::to_owned),
frames: parsed.frames().to_vec(),
crash_count: group.len(),
reproducer_bytes: representative.input().len(),
provenance: resolve_provenance(tree, &parsed),
tree,
sanitizer_report: text.to_owned(),
})
}
#[must_use]
pub fn target(&self) -> &str {
&self.target
}
#[must_use]
pub fn key(&self) -> &str {
&self.key
}
#[must_use]
pub fn class(&self) -> &str {
&self.class
}
#[must_use]
pub fn severity(&self) -> Severity {
self.severity
}
#[must_use]
pub fn weakness(&self) -> Option<Weakness> {
self.weakness
}
#[must_use]
pub fn is_security_relevant(&self) -> bool {
self.security_relevant
}
#[must_use]
pub fn crash_site(&self) -> Option<&str> {
self.crash_site.as_deref()
}
#[must_use]
pub fn frames(&self) -> &[String] {
&self.frames
}
#[must_use]
pub fn crash_count(&self) -> usize {
self.crash_count
}
#[must_use]
pub fn reproducer_bytes(&self) -> usize {
self.reproducer_bytes
}
#[must_use]
pub fn provenance(&self) -> Provenance {
self.provenance
}
#[must_use]
pub fn tree(&self) -> TreeProvenance {
self.tree
}
#[must_use]
pub fn sanitizer_report(&self) -> &str {
&self.sanitizer_report
}
#[must_use]
pub fn is_disclosable(&self) -> bool {
self.provenance == Provenance::Field
}
#[must_use]
pub fn severity_is_assessed(&self) -> bool {
self.severity != Severity::Undefined
}
}
#[must_use]
pub fn provenance_of(report: &SanitizerReport) -> Provenance {
let planted = report.frames().iter().any(|frame| {
frame == BENCHMARK_CANARY_FRAME || frame.starts_with(BENCHMARK_FUNCTION_PREFIX)
});
if planted {
Provenance::SyntheticBenchmark
} else {
Provenance::Field
}
}
#[must_use]
pub fn resolve_provenance(tree: TreeProvenance, report: &SanitizerReport) -> Provenance {
if tree.is_benchmark() {
return Provenance::SyntheticBenchmark;
}
provenance_of(report)
}
#[cfg(test)]
mod tests {
use lisdex_core::campaign::CampaignId;
use lisdex_core::crash::Crash;
use lisdex_core::dedup;
use super::*;
const CAMPAIGN: CampaignId = CampaignId(1);
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
";
const CANARY_RUNTIME_ONLY: &str = "\
=================================================================
==29093==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000071a4 (pc 0x1 bp 0x1 sp 0x2 T0)
==29093==The signal is caused by a READ memory access.
#0 0x1 in kill (/lib/x86_64-linux-gnu/libc.so.6+0x4553b)
#1 0x2 in magma_log /opt/magma/magma/src/canary.c:92:5
#2 0x3 in some_unrenamed_parser /repo/parse.c:10:4
SUMMARY: AddressSanitizer: SEGV (/lib/x86_64-linux-gnu/libc.so.6+0x4553b) in kill
";
const CANARY_RENAME_ONLY: &str = "\
=================================================================
==29094==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x602000000018 at pc 0x4a1
WRITE of size 1 at 0x602000000018 thread T0
#0 0x4a1 in MAGMA_png_handle_PLTE /opt/magma-work/libpng/repo/pngrutil.c:992:4
SUMMARY: AddressSanitizer: heap-buffer-overflow (/out/harness+0x4a1) in MAGMA_png_handle_PLTE
";
fn crash(report: &str) -> Crash {
Crash::from_report(CAMPAIGN, b"reproducer-bytes".to_vec(), report)
}
fn draft(report: &str, count: usize, tree: TreeProvenance) -> Option<Advisory> {
let crashes: Vec<Crash> = (0..count).map(|_| crash(report)).collect();
let grouping = dedup::group_crashes(&crashes);
Advisory::draft("libpng", grouping.groups().first()?, tree)
}
fn near_null_segv(address: &str) -> String {
format!(
"=================================================================
==11==ERROR: AddressSanitizer: SEGV on unknown address {address} (pc 0x55a bp 0x1 sp 0x2 T0)
==11==The signal is caused by a READ memory access.
#0 0x55a in png_read_filter_row /src/libpng/pngrutil.c:4180:9
#1 0x55b in png_read_row /src/libpng/pngread.c:512:7
SUMMARY: AddressSanitizer: SEGV (/out/harness+0x55a) in png_read_filter_row
"
)
}
#[test]
fn a_draft_carries_the_measured_facts_of_its_group() {
let advisory = draft(REAL_HEAP_WRITE, 44, TreeProvenance::Field).unwrap();
assert_eq!(advisory.target(), "libpng");
assert_eq!(advisory.class(), "heap-buffer-overflow(write)");
assert_eq!(advisory.severity(), Severity::Exploitable);
assert_eq!(advisory.weakness().unwrap().id, "CWE-122");
assert_eq!(advisory.crash_site(), Some("png_handle_iCCP"));
assert_eq!(advisory.crash_count(), 44);
assert_eq!(advisory.reproducer_bytes(), b"reproducer-bytes".len());
assert!(advisory.is_security_relevant());
}
#[test]
fn a_crash_with_no_dedup_key_drafts_no_advisory() {
let unkeyed = Crash::from_report(
CAMPAIGN,
b"x".to_vec(),
"==12==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x1 at pc 0x2\n #0 0x3 (/out/lib.so+0x4)\n",
);
assert_eq!(unkeyed.stack_hash(), None);
let crashes = vec![unkeyed];
let grouping = dedup::group_crashes(&crashes);
assert!(
grouping.groups().is_empty() && grouping.unkeyed_crashes() == 1,
"an advisory names one bug, and a crash the triage layer refused to key never forms a group to name"
);
}
#[test]
fn a_planted_benchmark_crash_is_never_disclosable() {
let advisory = draft(CANARY_CRASH, 44, TreeProvenance::Field).unwrap();
assert_eq!(advisory.provenance(), Provenance::SyntheticBenchmark);
assert!(
!advisory.is_disclosable(),
"this is an injected benchmark canary in a research build of libpng; an advisory that looked genuine could be filed against a real, widely deployed library for a bug that was deliberately planted"
);
}
#[test]
fn the_canary_runtime_alone_is_enough_to_mark_it() {
let report = SanitizerReport::parse(CANARY_RUNTIME_ONLY).unwrap();
assert!(
!report
.frames()
.iter()
.any(|f| f.starts_with(BENCHMARK_FUNCTION_PREFIX)),
"the fixture must isolate the signal: no renamed function here, only the canary runtime"
);
assert_eq!(provenance_of(&report), Provenance::SyntheticBenchmark);
}
#[test]
fn a_renamed_benchmark_function_alone_is_enough_to_mark_it() {
let report = SanitizerReport::parse(CANARY_RENAME_ONLY).unwrap();
assert!(
!report.frames().iter().any(|f| f == BENCHMARK_CANARY_FRAME),
"the fixture must isolate the signal: no canary runtime frame here, only a renamed function"
);
assert_eq!(provenance_of(&report), Provenance::SyntheticBenchmark);
}
#[test]
fn a_real_crash_is_not_mistaken_for_a_benchmark() {
let advisory = draft(REAL_HEAP_WRITE, 1, TreeProvenance::Field).unwrap();
assert_eq!(
advisory.provenance(),
Provenance::Field,
"marking every finding synthetic would make the mark meaningless"
);
assert!(advisory.is_disclosable());
}
#[test]
fn the_guard_reads_every_frame_and_not_just_the_significant_ones() {
let report = SanitizerReport::parse(CANARY_RUNTIME_ONLY).unwrap();
assert!(
!report
.significant_frames()
.contains(&BENCHMARK_CANARY_FRAME),
"magma_log is filtered out of the significant frames by the dedup noise list, so a guard reading those would never see the canary runtime at all"
);
assert!(report.frames().iter().any(|f| f == BENCHMARK_CANARY_FRAME));
}
#[test]
fn a_benchmark_tree_makes_a_crash_with_no_canary_frame_undisclosable() {
let report = SanitizerReport::parse(REAL_HEAP_WRITE).unwrap();
assert_eq!(
provenance_of(&report),
Provenance::Field,
"the fixture must isolate the signal: the frame guard sees nothing benchmark-shaped here"
);
let advisory = draft(REAL_HEAP_WRITE, 44, TreeProvenance::Benchmark).unwrap();
assert_eq!(advisory.provenance(), Provenance::SyntheticBenchmark);
assert!(
!advisory.is_disclosable(),
"magma forward-ports real historical CVEs into current source, so a benchmark tree contains already-fixed vulnerabilities; a crash that misses the canary would otherwise be filed as a new bug against a library that fixed it years ago"
);
}
#[test]
fn an_unknown_tree_decides_on_frame_evidence_in_both_directions() {
let planted = draft(CANARY_CRASH, 1, TreeProvenance::Unknown).unwrap();
assert_eq!(planted.provenance(), Provenance::SyntheticBenchmark);
let field = draft(REAL_HEAP_WRITE, 1, TreeProvenance::Unknown).unwrap();
assert_eq!(
field.provenance(),
Provenance::Field,
"a database written before lisdex measured trees must keep behaving exactly as it did, or the fix silently retracts every finding ever recorded"
);
}
#[test]
fn the_tree_and_the_frames_are_independent_arms() {
let clean = SanitizerReport::parse(REAL_HEAP_WRITE).unwrap();
let planted = SanitizerReport::parse(CANARY_CRASH).unwrap();
assert_eq!(
resolve_provenance(TreeProvenance::Benchmark, &clean),
Provenance::SyntheticBenchmark,
"the tree arm alone must be enough"
);
assert_eq!(
resolve_provenance(TreeProvenance::Field, &planted),
Provenance::SyntheticBenchmark,
"the frame arm alone must be enough, so a benchmark tree that was never recorded is still caught"
);
assert_eq!(
resolve_provenance(TreeProvenance::Field, &clean),
Provenance::Field,
"and with neither arm firing the finding stays disclosable, or the mark means nothing"
);
}
#[test]
fn an_advisory_remembers_which_tree_it_came_from() {
let advisory = draft(REAL_HEAP_WRITE, 1, TreeProvenance::Benchmark).unwrap();
assert_eq!(advisory.tree(), TreeProvenance::Benchmark);
}
#[test]
fn a_null_deref_group_whose_offset_moves_is_filed_as_security() {
let fixed = near_null_segv("0x0000000000000010");
let moved = near_null_segv("0x0000000000004000");
let varying = vec![crash(&fixed), crash(&moved)];
let grouping = dedup::group_crashes(&varying);
assert_eq!(
grouping.groups().len(),
1,
"the two captures must land in ONE group or this tests nothing about group consistency"
);
assert_eq!(grouping.groups()[0].len(), 2);
let advisory =
Advisory::draft("libpng", &grouping.groups()[0], TreeProvenance::Field).unwrap();
assert!(
advisory.is_security_relevant(),
"Chromium files a null dereference as non-security only when the offset is CONSISTENT; an offset that moves from 0x10 to 0x4000 with the input is attacker-influenced, and judging the representative crash alone files it as non-security"
);
}
#[test]
fn a_null_deref_group_at_one_fixed_offset_stays_non_security() {
let advisory = draft(
&near_null_segv("0x0000000000000010"),
2,
TreeProvenance::Field,
)
.unwrap();
assert!(
!advisory.is_security_relevant(),
"the consistency rule must not promote every null dereference, or the non-security verdict stops meaning anything"
);
}
#[test]
fn every_operator_input_states_a_field_and_a_reason() {
for input in OPERATOR_INPUTS {
assert!(!input.field().is_empty());
assert!(
input.why().len() > 40,
"a field lisdex declines to fill has to say why, or the reader cannot tell a gap from an oversight"
);
}
}
#[test]
fn an_undefined_severity_is_reported_as_unassessed() {
let advisory = draft(
"pngrutil.c:1204:7: runtime error: left shift of negative value -1\n #0 0x55a in png_do_read_transform pngrtran.c:1204:7\n",
1,
TreeProvenance::Field,
)
.unwrap();
assert_eq!(advisory.severity(), Severity::Undefined);
assert!(
!advisory.severity_is_assessed(),
"lisdex has no ground-truth corpus for UBSan severity (B91), so an advisory must not present the placeholder tier as an assessment"
);
assert_eq!(
advisory.weakness(),
None,
"and the same gap applies to naming a CWE for it"
);
}
}