feat(binaries): hardening, signatures, .NET references and Intel HEX checks of committed binaries (#495) (#501)
CI / Check (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Docs (push) Successful in 1m12s
CI / Deploy Dashboard (push) Successful in 5m49s
CI / Deploy Agent (push) Successful in 8m31s
CI / Deploy MCP (push) Successful in 3m35s

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 was merged in pull request #501.
This commit is contained in:
sharangandClaude Opus 5.5 committed 2026-10-06 11:40:54 +00:00
1 parent 9d1f8b6883
commit b7dbd8f196
14 files changed
+2129 -11

No files matched your search

+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();