feat(binaries): hardening, signatures, .NET references and Intel HEX checks of committed binaries (#495)

On top of the committed-binary inventory (#465), natively in Rust:

- PE: ASLR (DYNAMICBASE, relocations), high-entropy ASLR, DEP, CFG,
  SafeSEH, /GS, Authenticode present; IL-only .NET assemblies skip the
  native-only checks
- ELF (dynamically linked only): RELRO, NX stack, PIE, stack protector,
  FORTIFY; static and bare-metal ELF are not assessed
- .NET: AssemblyRefs from the CLI metadata tables (own ECMA-335 reader)
- native PE: CPE/purl candidates from the version resource, low confidence
- Intel HEX: record checksums, address ranges, size, start address

Evidence goes on the inventory finding; each gap is its own Low/Info
finding per rule (grouped by #477). ASLR/NX/RELRO gaps bind to cra-ai-1 and
a damaged HEX image to cra-ai-6 through attach-only control-map bindings,
which never make a control count as checked.

PE/ELF headers are read with the object crate, already in the build via
firmwerk-sbom: no new crate, no Python helper, no image change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-10-06 13:32:11 +02:00
1 parent 9d1f8b6883
commit ee4a9b8905
14 files changed
+2127 -11

No files matched your search

+24
View File
@@ -50,6 +50,19 @@
"dotnet-config-custom-errors-off"
],
"check": "The shipped configuration must be secure by default; ASP.NET debug compilation or detailed errors shown to every client violates it."
},
{
"tool": "binary-inventory",
"scan_type": "malware",
"languages": [],
"cwe": [],
"rules": [
"binary-no-aslr",
"binary-no-nx",
"binary-no-relro"
],
"check": "A committed executable or library must be built with the operating system's basic exploit mitigations on (ASLR/PIE, DEP/non-executable stack, RELRO); one without them is not secure by default. Defence-in-depth extras (CFG, SafeSEH, stack protector, FORTIFY, high-entropy ASLR) are reported but not bound here.",
"attach_only": true
}
],
"note": null,
@@ -106,6 +119,17 @@
],
"cwe": [],
"rules": []
},
{
"tool": "binary-inventory",
"scan_type": "malware",
"languages": [],
"cwe": [],
"rules": [
"binary-hex-invalid"
],
"check": "A committed firmware image whose Intel HEX record checksums or structure do not verify cannot be shown to be the image that was built.",
"attach_only": true
}
],
"note": "covered by the grounded surface check (retrieve code surface + grounded LLM judge decides presence/absence); validated live",
+27 -2
View File
@@ -46,12 +46,18 @@ pub struct ScanBinding {
/// CI/CD pipeline"); a buffer overflow is judged against this instead.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub check: Option<String>,
/// The binding links its findings to the control but never makes the
/// control count as checked: a tool that only looks at some files (the
/// committed binaries, #495) says nothing about a tree without them.
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub attach_only: bool,
}
impl ScanBinding {
/// Whether this binding checks code in any of `languages`.
pub fn applies_to(&self, languages: &[String]) -> bool {
self.languages.is_empty() || self.languages.iter().any(|l| languages.contains(l))
!self.attach_only
&& (self.languages.is_empty() || self.languages.iter().any(|l| languages.contains(l)))
}
}
@@ -299,7 +305,7 @@ mod tests {
for scan in &control.scans {
let reads_code = !matches!(
scan.tool.as_str(),
"gitleaks" | "secret-files" | "syft" | "osv"
"gitleaks" | "secret-files" | "syft" | "osv" | "binary-inventory"
);
assert_eq!(
reads_code,
@@ -312,6 +318,25 @@ mod tests {
}
}
#[test]
fn binary_findings_attach_without_claiming_coverage() {
let map = ControlMap::cra().expect("map");
let controls = |rule: &str| -> Vec<&str> {
map.controls_for_finding("binary-inventory", None, Some(rule))
.into_iter()
.map(|c| c.control.as_str())
.collect()
};
assert_eq!(controls("binary-no-aslr"), ["cra-ai-1"]);
assert_eq!(controls("binary-hex-invalid"), ["cra-ai-6"]);
assert!(controls("binary-unsigned").is_empty());
assert!(controls("binary-no-cfg").is_empty());
// A Go tree without binaries does not make cra-ai-1 checked.
let c = map.coverage("cra-ai-1").expect("cra-ai-1");
assert!(!c.checked_for(&["go".to_string()]));
assert!(c.checked_for(&["python".to_string()]));
}
#[test]
fn hardcoded_password_control_is_tool_covered() {
let map = ControlMap::cra().unwrap();