feat(binaries): hardening, signatures, .NET references and Intel HEX checks of committed binaries (#495) (#501)
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:
1 parent
9d1f8b6883
commit
b7dbd8f196
14 files changed
+2129
-11
No files matched your search
@@ -20,6 +20,7 @@ together on stage in one pass before the next prod promotion.
|
||||
| #467 (follow-up) | npm and Maven licenses from their public registries |
|
||||
| #491 | Findings keyed by the code they flag, not its line number |
|
||||
| #491 (PLC) | PLC findings keyed the same way |
|
||||
| #495 | Binary depth: PE/ELF hardening, signatures, .NET references, CPE/purl candidates, Intel HEX checks |
|
||||
|
||||
**Customer-visible on the next prod rescan** is marked **[visible]**: these
|
||||
change what a customer sees on their existing targets, without them doing
|
||||
@@ -368,6 +369,54 @@ target with history (findings, at least one marked by a person, issues).
|
||||
- **[visible]** PLC targets no longer get a duplicate finding for every line
|
||||
shift in an export.
|
||||
|
||||
### 21. #495 Binary depth: hardening, signatures, references, HEX
|
||||
|
||||
Builds on check 15 (committed binaries). Nothing to switch on; no ClamAV
|
||||
needed. Make the files locally, never commit them:
|
||||
|
||||
```sh
|
||||
printf '#include <stdio.h>\n#include <string.h>\nint main(int c,char**v){char b[16];strcpy(b,v[0]);puts(b);return 0;}\n' > t.c
|
||||
gcc -O2 -fno-stack-protector -no-pie -Wl,-z,norelro -o weak t.c
|
||||
gcc -O2 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -pie -fPIE -Wl,-z,relro,-z,now -o strong t.c
|
||||
cp fixtures/nightly/firmware/c-sensor-node/Prebuilt/bootloader.hex good.hex
|
||||
sed '3s/^\(:10.......\)./\1F/' good.hex > broken.hex # one data digit changed
|
||||
```
|
||||
|
||||
plus one .NET DLL and one native Windows DLL (e.g. `lib/net45/Newtonsoft.Json.dll`
|
||||
from the nupkg on nuget.org, and any unsigned native DLL you have).
|
||||
|
||||
- **Do:** upload an archive with `weak`, `strong`, `good.hex`, `broken.hex`
|
||||
and the two DLLs under `bin/`.
|
||||
- **Expect:**
|
||||
- every file keeps its **Info** finding **Committed binary …**, whose text
|
||||
now ends with what was found: `Hardening: RELRO none, NX yes, PIE no,
|
||||
stack protector no, FORTIFY no.` for `weak`, `RELRO full, NX yes, PIE
|
||||
yes, stack protector yes, FORTIFY yes.` for `strong`; for the .NET DLL `References N assemblies:
|
||||
…` (mscorlib, System …); for the native DLL `Candidates from the version
|
||||
resource (low confidence …): cpe:2.3:a:…, pkg:generic/…`; for
|
||||
`good.hex` `Intel HEX: 129 records, 2048 bytes of data in 1 address range
|
||||
(0x00000000-0x000007FF).` and `Every record checksum is valid.`
|
||||
- for `weak`, **Niedrig** findings **Committed binary without ASLR** and
|
||||
**… without RELRO**, and **Info** **… without stack protector** and
|
||||
**… without _FORTIFY_SOURCE**; none for `strong`;
|
||||
- **Niedrig** **Committed Intel HEX image is damaged** on `broken.hex`
|
||||
(its inventory finding says `wrong checksum on line 3`);
|
||||
- **Info** **Committed executable without a signature** for each unsigned
|
||||
DLL; a signed one says `Authenticode signature: present (not verified)`;
|
||||
- the ASLR/NX/RELRO findings show control **cra-ai-1**, the HEX finding
|
||||
**cra-ai-6**; in the CRA view a target without binaries does not turn
|
||||
cra-ai-1 green because of this stage;
|
||||
- a bare-metal firmware `.elf` (no dynamic section) gets no hardening
|
||||
findings: `Statically linked or bare-metal ELF: … not assessed.`;
|
||||
- more than five files with the same gap become one finding per rule
|
||||
(#477), listing the files.
|
||||
- **Log:** nothing new; the stage runs inside the binary inventory.
|
||||
- **[visible]** repositories with committed DLLs, executables or `.hex`
|
||||
images get new Low/Info hardening, signature and HEX findings on the next
|
||||
rescan. An inventory finding stored before keeps its old text (stored
|
||||
findings are not rewritten); grouped ones (#477) and new or changed files
|
||||
show the evidence.
|
||||
|
||||
## After the pass
|
||||
|
||||
- The nightly job on `main` is green with the new mobile targets.
|
||||
|
||||
Reference in new issue
Block a user