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
// boundary.rs
pub const NULL_DEREFERENCE_BOUNDARY: u64 = 32 * 1024;
pub const CLUSTERFUZZ_BOUNDARY: u64 = 4 * 1024;
pub const LIBCASR_BOUNDARY: u64 = 64 * 1024;
const _: () = assert!(CLUSTERFUZZ_BOUNDARY < NULL_DEREFERENCE_BOUNDARY);
const _: () = assert!(NULL_DEREFERENCE_BOUNDARY < LIBCASR_BOUNDARY);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum FaultAddress {
Absent,
NearNull(u64),
Wild(u64),
}
impl FaultAddress {
#[must_use]
pub fn of(address: Option<u64>) -> Self {
match address {
None => Self::Absent,
Some(value) if value < NULL_DEREFERENCE_BOUNDARY => Self::NearNull(value),
Some(value) => Self::Wild(value),
}
}
#[must_use]
pub fn is_security_relevant(self) -> bool {
!matches!(self, Self::NearNull(_))
}
#[must_use]
pub fn address(self) -> Option<u64> {
match self {
Self::Absent => None,
Self::NearNull(value) | Self::Wild(value) => Some(value),
}
}
}
#[must_use]
pub fn group_is_security_relevant(representative: FaultAddress, group: &[FaultAddress]) -> bool {
let Some(FaultAddress::NearNull(first)) = group.first() else {
return representative.is_security_relevant();
};
let mut varies = false;
for fault in group {
let FaultAddress::NearNull(value) = fault else {
return representative.is_security_relevant();
};
if value != first {
varies = true;
}
}
varies
}
#[cfg(test)]
mod tests {
use super::*;
const BAND_ADDRESS: u64 = 0x9000;
const _: () = assert!(BAND_ADDRESS > CLUSTERFUZZ_BOUNDARY);
const _: () = assert!(BAND_ADDRESS > NULL_DEREFERENCE_BOUNDARY);
const _: () = assert!(BAND_ADDRESS < LIBCASR_BOUNDARY);
#[test]
fn the_adopted_boundary_is_chromiums_and_not_the_one_libcasr_would_have_supplied() {
assert_eq!(
NULL_DEREFERENCE_BOUNDARY,
32 * 1024,
"ClusterFuzz uses 4 KiB, libcasr 64 KiB, Chromium 32 KiB; the ordering of the three is asserted at compile time and this pins which one lisdex adopted"
);
}
#[test]
fn an_offset_inside_a_plausible_struct_is_not_a_security_finding() {
assert_eq!(FaultAddress::of(Some(0)), FaultAddress::NearNull(0));
assert_eq!(FaultAddress::of(Some(0x10)), FaultAddress::NearNull(0x10));
assert!(!FaultAddress::of(Some(0x10)).is_security_relevant());
}
#[test]
fn the_band_the_three_systems_disagree_about_resolves_to_security() {
let band = BAND_ADDRESS;
assert_eq!(FaultAddress::of(Some(band)), FaultAddress::Wild(band));
assert!(
FaultAddress::of(Some(band)).is_security_relevant(),
"libcasr calls 36 KiB near-null and would file this as non-security; ClusterFuzz at 4 KiB and Chromium at 32 KiB both call it security, and lisdex follows them"
);
}
#[test]
fn the_boundary_itself_is_already_beyond_it() {
assert!(FaultAddress::of(Some(NULL_DEREFERENCE_BOUNDARY)).is_security_relevant());
assert!(!FaultAddress::of(Some(NULL_DEREFERENCE_BOUNDARY - 1)).is_security_relevant());
}
#[test]
fn a_group_faulting_at_one_fixed_small_offset_stays_non_security() {
let group = [FaultAddress::NearNull(0x10), FaultAddress::NearNull(0x10)];
assert!(
!group_is_security_relevant(FaultAddress::NearNull(0x10), &group),
"a struct field read off a null pointer lands at the same offset every time, and Chromium calls that non-security"
);
}
#[test]
fn a_group_whose_small_offsets_disagree_is_security_relevant() {
let group = [FaultAddress::NearNull(0x10), FaultAddress::NearNull(0x4000)];
assert!(
group_is_security_relevant(FaultAddress::NearNull(0x10), &group),
"Chromium's rule is non-security only for a CONSISTENT small offset; an offset that moves with the input is attacker-influenced even though every address is small, and judging the representative alone files it as non-security"
);
}
#[test]
fn one_wild_address_in_the_group_falls_back_to_the_per_report_verdict() {
let group = [
FaultAddress::NearNull(0x10),
FaultAddress::Wild(BAND_ADDRESS),
];
assert!(
group_is_security_relevant(FaultAddress::Wild(BAND_ADDRESS), &group),
"the consistency rule only governs groups that are entirely near-null; anything else keeps the verdict it already had"
);
assert!(
!group_is_security_relevant(FaultAddress::NearNull(0x10), &group),
"and it defers to the representative rather than inventing a verdict of its own"
);
}
#[test]
fn an_empty_group_defers_rather_than_inventing_a_verdict() {
assert!(!group_is_security_relevant(
FaultAddress::NearNull(0x10),
&[]
));
assert!(group_is_security_relevant(
FaultAddress::Wild(BAND_ADDRESS),
&[]
));
}
#[test]
fn a_single_crash_group_cannot_be_shown_to_vary() {
let group = [FaultAddress::NearNull(0x10)];
assert!(
!group_is_security_relevant(FaultAddress::NearNull(0x10), &group),
"one observation is not evidence of a moving offset, and claiming otherwise would file every null dereference as security"
);
}
#[test]
fn a_report_with_no_fault_address_answers_nothing_rather_than_safe() {
assert_eq!(FaultAddress::of(None), FaultAddress::Absent);
assert!(
FaultAddress::of(None).is_security_relevant(),
"only a measured small offset earns the non-security verdict; an absent address must never be read as one"
);
assert_eq!(FaultAddress::of(None).address(), None);
}
}