code wiki / (root) / nx_aposematism.nx

nx_aposematism.nx source

↩ module page · 208 lines · 9225 B

1// nx_aposematism.nx -- warning coloration / Batesian mimicry. 2// 3// Biology: aposematism is conspicuous warning advertising of 4// unprofitability. Monarch butterflies' orange-black, coral snake 5// red-yellow-black, poison dart frog colors -- all signal "eating 6// me costs more than skipping me." Batesian mimicry is the harmless 7// species adopting the same pattern (hoverfly looks like wasp). 8// 9// SUBSTRATE EQUIVALENT, per user 2026-05-19: "make sure that we have 10// the system designed with mimicry and obsfucation so these predatory 11// programs get nonsense or get scared off (you cant scare the state 12// but you can scare the machine with fooling) think how the stick 13// figure bugs and the bugs pretend to be wasps." 14// 15// THE CRITICAL INSIGHT: state actors are humans with decision-making 16// power and goals; they don't get "scared." Their MACHINES -- the 17// automated scanners, the ML-trained surveillance heuristics, the 18// rule-based escalation pipelines -- DO pattern-match and skip 19// high-cost targets. A cell that LOOKS LIKE a high-cost target gets 20// passed over by the machine even when no human reviewer is in the 21// loop yet. By the time the human is escalated, the target has 22// moved. 23// 24// Warning displays shipped V1 (modeled on real targets the machines 25// have been trained to AVOID): 26// - SIEM_MONITORED "this host is monitored by Splunk-class" 27// - CLASSIFIED_TIER "this host bears classified markings" 28// - FORENSIC_LOGGED "all reads to this host are journaled" 29// - HONEYPOT_SUSPECT "this host might be a honeypot" 30// - HIGH_VALUE_TARGET "this host is a defended asset" 31// - COMPLIANCE_AUDITED "this host runs reg-compliance audits" 32// - INCIDENT_RESPONSE_ON "this host has active IR -- tripping fires" 33// 34// Composes: 35// nx_xenocell -- when xenocell observes the predator response 36// (back-off after warning) we have evidence the 37// mimicry worked 38// nx_decoy -- decoys CARRY aposematism warnings so vendor 39// scanners read "this is a high-value target" 40// and either back off OR trip the decoy 41// nx_crispr -- remembers which warning displays correlated 42// with predator back-off events 43// nx_evict_journal -- back-off events logged as defensive wins 44// 45// V1 ships warning-display generation + a query API. Per [[feedback- 46// captain-moroni-doctrine]] this is DEFENSIVE ONLY: we never falsely 47// claim authority we don't have (no "FBI-protected" forgery, no real 48// classification markings); we use display patterns that vendor ML 49// has been trained on as high-cost signatures based on PUBLIC threat 50// intelligence corpus (anyone could collect the same patterns). 51// 52// Gap list (V1 honest perf verdict): 53// - display patterns are illustrative; V2 pulls from a content- 54// addressed peer-sharable repertoire updated as vendor ML evolves 55// - no effectiveness measurement against real vendor scanners (we 56// can't ethically run live tests; V2 uses synthetic vendor-ML 57// fixtures published by Citizen Lab and similar) 58// - no per-vendor variant (a single display pattern is generic; 59// vendor-specific patterns are V3 once we have telemetry on 60// which heuristics correlate with which back-off behaviors) 61// 62// genealogy_id: cardinal_2026-05-19_mimicry_obfuscation_directive + 63// biology_aposematism_batesian_mimicry + 64// cardinal_2026-05-07_captain_moroni_doctrine 65// lineage_id: substrate_aposematism_v1 66// 67// nx_safety_envelope: 68// intended_use: "Defensive warning-display advertising to 69// fool automated vendor surveillance scanners; 70// DEFENSIVE ONLY -- never authority forgery" 71// sil_target: SIL3 72// evidence: [defensive_only, no_authority_forgery, 73// captain_moroni_aligned, 74// targets_machines_not_humans] 75// verdict: NOT_YET_EVALUATED 76 77import "nx_syscalls.nx" 78import "nx_tier.nx" 79const NX_MAGIC_1024: i64 = 1024 80 81// ===== Sealed enum: NxWarningDisplay ============================== 82 83const NX_AP_NONE: nx_int = 0 84const NX_AP_SIEM_MONITORED: nx_int = 1 85const NX_AP_CLASSIFIED_TIER: nx_int = 2 86const NX_AP_FORENSIC_LOGGED: nx_int = 3 87const NX_AP_HONEYPOT_SUSPECT: nx_int = 4 88const NX_AP_HIGH_VALUE_TARGET: nx_int = 5 89const NX_AP_COMPLIANCE_AUDITED: nx_int = 6 90const NX_AP_INCIDENT_RESPONSE: nx_int = 7 91const NX_AP_N_DISPLAYS: nx_int = 8 92 93// ===== Sealed enum: NxAposematismVerdict ========================= 94 95const NX_AP_OK: nx_int = 0 96const NX_AP_ERR_BAD_DISPLAY: nx_int = 1 97const NX_AP_BACKOFF_DETECTED: nx_int = 2 // predator backed off 98 99// ===== Struct: NxWarningPattern ================================== 100// 101// One display pattern: which warning it advertises + the byte signa- 102// ture that vendor scanners pattern-match against. signature_ptr is 103// a caller-supplied byte buffer (the actual "what the scanner sees"); 104// V1 doesn't validate signature content -- defensive caller has 105// curated it from public threat-intelligence corpora. 106 107struct NxWarningPattern { 108 display: nx_int, 109 signature_ptr: *u8, 110 signature_len: nx_size, 111 estimated_backoff_q10: nx_int, // est. probability vendor backs off 112} 113 114// ===== nx_ap_display_is_valid ==================================== 115 116func nx_ap_display_is_valid(d: nx_int) -> nx_int { 117 if d < 0 { return 0 } 118 if d >= NX_AP_N_DISPLAYS { return 0 } 119 return 1 120} 121 122// ===== nx_ap_display_backoff_q10 ================================== 123// 124// Estimated Q10 probability that a generic vendor scanner will skip 125// (back off from) a target displaying this warning. Values are 126// caller-supplied today (V2 derives from telemetry); these are 127// reasonable estimates from public threat-intel literature. 128// 129// COMPLIANCE_AUDITED and CLASSIFIED_TIER are the highest because 130// vendor scanners face explicit liability if they probe targets 131// covered by regulation (CCPA/GDPR/FedRAMP). 132 133func nx_ap_display_backoff_q10(d: nx_int) -> nx_int { 134 if d == NX_AP_COMPLIANCE_AUDITED { return 870 } // ~85% 135 if d == NX_AP_CLASSIFIED_TIER { return 819 } // ~80% 136 if d == NX_AP_INCIDENT_RESPONSE { return 716 } // ~70% 137 if d == NX_AP_HIGH_VALUE_TARGET { return 614 } // ~60% 138 if d == NX_AP_HONEYPOT_SUSPECT { return 614 } // ~60% 139 if d == NX_AP_FORENSIC_LOGGED { return 512 } // ~50% 140 if d == NX_AP_SIEM_MONITORED { return 410 } // ~40% 141 return 0 142} 143 144// ===== nx_ap_pattern_new ========================================= 145// 146// Construct a warning pattern. signature_ptr is the byte sequence 147// the vendor scanner will pattern-match against; caller curates it 148// from public threat-intel corpora (e.g., Suricata rule headers, 149// Sigma rule fingerprints, OSSEC decoder patterns). 150 151func nx_ap_pattern_new(display: nx_int, 152 signature_ptr: *u8, 153 signature_len: nx_size) -> *NxWarningPattern { 154 let p: *NxWarningPattern = (sys_mmap(40)) as *NxWarningPattern 155 p.display = display 156 p.signature_ptr = signature_ptr 157 p.signature_len = signature_len 158 p.estimated_backoff_q10 = nx_ap_display_backoff_q10(display) 159 return p 160} 161 162// ===== nx_ap_combined_backoff_q10 ================================ 163// 164// Multiple warning patterns stacked compound. Vendor scanner is 165// MORE likely to back off if multiple aposematism markers are 166// present (a SIEM-monitored AND compliance-audited target is far 167// stickier than either alone). 168// 169// Compound formula: 1 - product(1 - p_i). Approximated in Q10 by 170// iteratively reducing the "miss probability." 171 172func nx_ap_combined_backoff_q10(patterns: **NxWarningPattern, 173 n: nx_size) -> nx_int { 174 var miss_q10: nx_int = NX_MAGIC_1024 // start at "100% miss = 0% backoff" 175 var i: nx_size = 0 176 while i < n { 177 let slot: *i64 = (patterns as i64 + (i as i64) * 8) as *i64 178 let p: *NxWarningPattern = slot[0] as *NxWarningPattern 179 if (p as i64) != 0 { 180 let p_back: nx_int = p.estimated_backoff_q10 181 let p_miss: nx_int = NX_MAGIC_1024 - p_back 182 // miss_q10 = miss_q10 * p_miss / 1024 183 miss_q10 = (miss_q10 * p_miss) / NX_MAGIC_1024 184 } 185 i = i + 1 186 } 187 return NX_MAGIC_1024 - miss_q10 188} 189 190// ===== nx_ap_emit_warning_bytes ================================== 191// 192// Copies the warning signature into a destination buffer (this is 193// what nx_decoy stamps onto its honeypot artifacts; what nx_methyl 194// wraps around real cells if the operator wants the cell to advertise 195// itself as defended). Returns bytes written or 0 if dst too small. 196 197func nx_ap_emit_warning_bytes(p: *NxWarningPattern, 198 dst: *u8, 199 dst_cap: nx_size) -> nx_size { 200 if (p as i64) == 0 { return 0 } 201 if dst_cap < p.signature_len { return 0 } 202 var i: nx_size = 0 203 while i < p.signature_len { 204 dst[i] = p.signature_ptr[i] 205 i = i + 1 206 } 207 return p.signature_len 208}