nx_pamp.nx
buildroot/runtime/nx_pamp.nx
about
nx_pamp.nx -- Pathogen-Associated Molecular Pattern recognition.
Biology: PAMPs are conserved molecular signatures of pathogens
(LPS on gram-negative bacteria, flagellin on motile bacteria, viral
dsRNA) that TLRs and NOD-like receptors detect to mount the innate
immune response. The patterns are recognizable because they're
conserved -- pathogens can't change them without losing function.
Software substrate: certain byte/structural patterns are similarly
conserved across attack classes. Detecting them is cheap and
high-signal. nx_pamp ships a sealed enum of pattern KINDS + a
scanner over caller-supplied byte buffers.
PAMP kinds shipped V1:
- TROJAN_SOURCE_HOMOGLYPH -- Cyrillic-Latin homograph in code
- ENTROPY_ANOMALY -- shellcode-class entropy spikes
- BUILD_INJECTION_HINT -- known build-toolchain backdoor sig
- KNOWN_BAD_EGRESS_HEADER -- C2 protocol leading bytes
- MICROCODE_INJECT_HINT -- known microcode-patch markers
- ROOTKIT_PERSIST_HINT -- known rootkit boot-hook bytes
- SHELLCODE_NOPSLED -- 0x90 NOP sled detection
- DECOY_INVALID_METHYL_HINT -- our own decoy markers (so we
recognize OUR leak fingerprint
if it appears upstream)
THIS IS THE FIRST-LINE DETECTION. nx_pamp tells "is something
suspicious here?". nx_crispr remembers signatures of confirmed
threats. nx_restriction (queued) gates IO using both. nx_xenocell
records the event into the forensic ledger.
V1 ships a scanner over byte buffers with a hardcoded pattern DB.
V2 makes the pattern DB content-addressed peer-sharable so the
community can extend coverage without recompiling substrate.
Gap list (V1 honest perf verdict):
- pattern DB hardcoded (V2 makes it data-driven)
- no fuzzy / regex matching (exact-byte and entropy only)
- no positional context (a pattern in mainline code is same
verdict as same pattern in a comment string)
- false-positive rate not measured against corpus
dependencies 2 imports · 10 importers
imports: nx_syscalls.nxnx_tier.nx
imported by: nx_antibody.nxnx_antibody_test.nxnx_crispr.nxnx_crispr_test.nxnx_immune_test.nxnx_mimicry_compose_test.nxnx_pamp_meta.nxnx_pamp_test.nxnx_tier1_immune_compose_test.nxnx_tier2_immune_compose_test.nx
structs
| 85 | struct NxPampHit |
consts
| 61 | const NX_PAMP_NONE: nx_int = 0 |
| 62 | const NX_PAMP_TROJAN_SOURCE_HOMOGLYPH: nx_int = 1 |
| 63 | const NX_PAMP_ENTROPY_ANOMALY: nx_int = 2 |
| 64 | const NX_PAMP_BUILD_INJECTION_HINT: nx_int = 3 |
| 65 | const NX_PAMP_KNOWN_BAD_EGRESS: nx_int = 4 |
| 66 | const NX_PAMP_MICROCODE_INJECT_HINT: nx_int = 5 |
| 67 | const NX_PAMP_ROOTKIT_PERSIST_HINT: nx_int = 6 |
| 68 | const NX_PAMP_SHELLCODE_NOPSLED: nx_int = 7 |
| 69 | const NX_PAMP_DECOY_INVALID_METHYL: nx_int = 8 |
| 70 | const NX_PAMP_N_KINDS: nx_int = 9 |
| 74 | const NX_PAMP_OK: nx_int = 0 |
| 75 | const NX_PAMP_DETECTED: nx_int = 1 |
| 76 | const NX_PAMP_ERR_BAD_BUF: nx_int = 2 |
functions
| 94 | func nx_pamp_kind_is_valid(k: nx_int) -> nx_int |
| 107 | func _pamp_scan_nopsled(buf: *u8, n: nx_size, hit: *NxPampHit) -> nx_int called by 1: nx_pamp_scan |
| 140 | func _pamp_scan_homoglyph(buf: *u8, n: nx_size, hit: *NxPampHit) -> nx_int called by 1: nx_pamp_scan |
| 194 | func _pamp_scan_entropy(buf: *u8, n: nx_size, hit: *NxPampHit) -> nx_int |
| 245 | func nx_pamp_scan(buf: *u8, n: nx_size, hit: *NxPampHit) -> nx_int |