Architecture Note · Security & Compliance
Email Security, Phishing & Wire-Fraud (BEC) Defense: Deterministic Forensics, ERP Bank Diffs, and Human SOC Gates
How deterministic header forensics, ERP vendor-master bank diffs, human-gated SOC purges, and SHA-256 hash-chained audit logs stop wire-fraud BEC and quishing.
The Operational Problem: High-Value Wire Fraud Inside Trusted Mail Threads
Treasury, accounts payable, and security operations teams face attacks that carry no malware payload at all. A Business Email Compromise (BEC) lure arrives disguised as a routine vendor settlement update—swapping a German DE89 SEPA IBAN for an external LT60 account on a EUR 485,000 retainer, altering a US ACH routing number, or using secrecy cues to bypass procurement portals. Simultaneously, QR-code phishing (quishing) lures embedded in images or PDFs evade traditional gateway URL rewriters and harvest session tokens across distributed regional offices.
Why Naive AI Wrappers Fail
Prompting a general-purpose cloud language model to flag suspicious emails introduces four structural weaknesses in high-stakes financial and SOC workflows:
- Nondeterministic header and lookalike math: General LLM classifiers miss subtle structural spoofing—such as
Fromvs.Reply-ToorReturn-Pathsplits, punycode (xn--) labels, Cyrillic or Greek confusables, and ASCII substitutions likernform—while producing inconsistent risk scores on identical message inputs. - Raw message egress: Forwarding full
.emlfiles, vendor banking coordinates, and executive correspondence to external model APIs pushes sensitive financial metadata outside the enterprise boundary with unclear retention guarantees. - No grounding against ERP truth: An isolated email prompt cannot verify whether a requested IBAN, SWIFT-BIC, ABA routing number, UK sort code, or Australian BSB matches the firm’s verified vendor master, nor prevent staff from dialing a fraudulent callback number embedded in the attacker’s email signature.
- Missing blast-radius and remediation controls: Unbounded automation cannot safely retract messages across dozens of global mailboxes or upgrade subsidiary DMARC policies without explicit human accountability and tamper-evident audit logs.
The Deterministic Architecture That Fixes It
A production BEC and phishing defense stack separates deterministic protocol checks, authoritative ERP comparisons, and human-gated containment into an auditable pipeline backed by SQLite in WAL mode and scoped invite authentication:
- Header, homoglyph, and quishing inspection (
POST /api/mail/inspect): Accepts JSON headers/bodies or multipart.emluploads parsed with Python’s standard-library email parser. The engine checks SPF, DKIM, and DMARCAuthentication-Results, flagsFrom/Reply-To/Return-Pathmismatches, decodes punycode and Unicode confusables alongside ASCII folding and Levenshtein edit distance against protected domains, and inspects URL shorteners and QR/quishing cues. A provider-agnosticBaseBECAdapterdefaults toOfflineDeterministicAdapter(offline-deterministic-v1) for zero-key local execution, while temporary.emlfiles are automatically purged after one hour (purge_expired_uploads). - ERP vendor master diff and out-of-band callback gate (
POST /api/bec/bank-verify): Normalizes and compares requested IBAN, routing, SWIFT, and account last-4 tokens against verifiedvendor_masterrecords, alongside lookalike checks on the sender domain. Any discrepancy triggersHOLD_BANK_MISMATCH(orHOLD_UNVERIFIED_VENDOR) and emits a structured callback checklist pinned strictly to the master record’s pre-verified phone number—explicitly rejecting phone numbers supplied inside the email and requiring dual-control Analyst plus Controller sign-off before releasing held wires. - DMARC posture monitoring and human-gated SOC actions (
GET /api/dmarc/posture,POST /api/incidents/{id}/action): Aggregates subsidiary domain alignment rates, policy states (p=none,p=quarantine,p=reject), SPF 10-lookup limits, and unauthorized sender geolocations. High-impact containment actions—org_wide_purge,retract_all, andrelease_quarantine—enforce a strict human SOC confirmation gate, returning HTTP409 Conflictunlesshuman_confirmed=true,analyst_id, and a non-emptyconfirmation_noteare supplied. - SHA-256 hash-chained audit trail and safe exports: Every analyst and controller decision appends to an immutable SHA-256 hash-chained
incident_actionsledger, covered bypytestsuites on header/spoof parsing and exported viaGET /api/incidents/export.csvas RFC 4180 CSV with spreadsheet formula-injection neutralization.
Operational Takeaway
Stopping wire-fraud BEC and quishing requires deterministic inspection, not probabilistic guesswork. By pairing zero-key header and homoglyph forensics with 1-hour ephemeral .eml cleanup, ERP vendor-master bank diffs, pre-verified callback gates, HTTP 409 human SOC purge enforcement, and SHA-256 chained audit logs, security and finance teams defend multi-currency approvals without surrendering custody or control.