ACI Technical Deep Dive
This deep dive documents ACI@2.0 (ACIV2Pass) and ACI@3.0 (ACIV3Pass) internals end to end: DuckDB SQL join enrichment, normalized scanner_sig token matching parity, ACIModel (aci_v3_core) ML overlay inference, Track B integration, confidence and uplift math, ledger persistence, and validation boundaries.
Scope and Implementation Map
Primary implementation files:
src/vulnparse_pin/core/passes/ACI/aci_pass.py(ACIV2Pass/ACI@2.0,ACIV3Pass/ACI@3.0,AttackCapabilityInferencePass/ACI@1.0)src/vulnparse_pin/ml/aci_model.py(ACIModel,ACI_ML_LABELS,OFFENSIVE_ACI_LABELS,build_aci_text_and_features)src/vulnparse_pin/core/passes/__init__.py(run_v2_duckdb_pipeline)src/vulnparse_pin/storage/schema.sql(aci_signalstable)src/vulnparse_pin/core/passes/Scoring/scoringPass.py(ScoringV3PassTrack A & Track B consumers)src/vulnparse_pin/core/passes/Triage/triage_pass.py(TriageDecisionPassSSVC & SAST corroboration consumers)src/vulnparse_pin/core/passes/Remediation/remediation_pass.py(RemediationPass/Remediation@1.0)src/vulnparse_pin/core/passes/TopN/topn_pass.py(TopNV2Passtie-break consumer)src/vulnparse_pin/core/passes/TopN/TN_triage_semantics.py&src/vulnparse_pin/core/schemas/topN.schema.jsonsrc/vulnparse_pin/reporting/renderer.py&src/vulnparse_pin/ui/app.py
Pass Lifecycle & DAG Position
In run_v2_duckdb_pipeline(), ACI@2.0 runs ahead of scoring and triage:
NmapAdapter@1.0(optional)ACI@2.0(ACIV2Pass,requires_passes = ())Scoring@3.0(ScoringV3Pass)Triage@2.0(TriageDecisionPass,requires_passes = ("Scoring@3.0", "ACI@2.0"))Remediation@1.0(RemediationPass,requires_passes = ("Triage@2.0",))TopN@2.0(TopNV2Pass,requires_passes = ("Triage@2.0",))Summary@2.0(SummaryV2Pass)
This ordering allows Scoring@3.0 Track B (exposure_weakness) to incorporate aci_signals directly into raw_risk_score and operational_score without a second scoring pass. ACIV3Pass (ACI@3.0) inherits from AttackCapabilityInferencePass with version = "3.0" for callers explicitly invoking the versioned ACI@3.0 pass identifier, while ACIV2Pass._run_duckdb() already executes ACIModel (aci_v3_core) inference directly when ml_pol.mode != "off".
DuckDB Storage & SQL Join Enrichment
aci_signals Table (schema.sql)
CREATE TABLE IF NOT EXISTS aci_signals (
run_id VARCHAR NOT NULL,
finding_id VARCHAR NOT NULL,
asset_id VARCHAR NOT NULL,
capabilities_json VARCHAR,
chains_json VARCHAR,
matched_tokens_json VARCHAR,
confidence DOUBLE,
uplift_score DOUBLE,
ml_capabilities_json VARCHAR DEFAULT '{}',
ml_attributions_json VARCHAR DEFAULT '[]',
ml_confidence DOUBLE,
ml_model_id VARCHAR,
PRIMARY KEY (run_id, finding_id)
);
Multi-Table SQL Join Input Query
_run_duckdb() streams findings in 25,000-row cursor chunks (fetchmany(25_000)) from a single SQL query joining:
findings f:cwes_json,title,description,plugin_output,affected_port,tags_json,exploit_evidence,references_json.enrichment_snapshots e_prim: primary CVEin_kevandverified_exploit.finding_cves fc+enrichment_snapshots e(fc_aggsubquery):BOOL_OR(COALESCE(e.in_kev, FALSE))andBOOL_OR(COALESCE(e.verified_exploit, FALSE))across all CVEs linked to the finding, ensuring secondary-CVE KEV/exploit signals are never missed.finding_evidence(fe_sigsubquery):LIST(DISTINCT scanner_sig ORDER BY scanner_sig)aggregating every contributing scanner rule/template/plugin signature across deduplicated detections.
Results are written back to aci_signals inside an explicit transaction using conn.appender("aci_signals") in 25,000-row batches.
ACIModel (aci_v3_core) ML Inference in _run_duckdb
When resolve_ml_policy(self.ml_policy, ctx=ctx) resolves ml_pol.mode != "off" ("shadow" by default, "active" opt-in), ACIV2Pass._run_duckdb() loads ACIModel.load(ml_pol.aci_model_path, provider=ml_pol.provider) (aci_v3_core signed artifact) and executes aci_ml_model.predict_finding(...) per unique finding signature memoized in ml_memo (bounded to 100,000 entries):
- Inputs:
title,description,plugin_output,tags, normalizedcwes,scanner_sigs,references,affected_port,has_exploit, andin_kev(withtop_k = ml_pol.top_k_attributions). - Persisted columns:
ml_capabilities_json(calibrated probabilities overACI_ML_LABELS: 8 offensive labels plusnegated_false_positive),ml_attributions_json(top-K signed attributions),ml_confidence, andml_model_id. - When
ml_pol.mode == "off": Skips loadingACIModeland writes"{}","[]",None,None.
Signal Extraction & scanner_sig Matching Parity
aci_pass.py preserves exact parity between its fast-path memoized DuckDB evaluator and the single-record _infer_single_record() path:
- Word-boundary short tokens (
_SHORT_BOUNDED_TOKEN_RES): Short ambiguous acronyms/protocols (rce,sqli,lfi,smb,ssh,rdp,rpc,xss) require(?<![a-z0-9])<tok>(?![a-z0-9])boundaries rather than raw substring matches. - Normalized
scanner_sigmatching (_scan_sig):- Fast-skips pure numeric
nessus:<id>,qualys:<id>,openvas:<id>signatures unlessscanner_prefix_or_digit_tokensmatch. - Otherwise lowercases
scanner_sig, normalizes separators ([/._:-]+→" "), and checks both_STRUCTURED_TAG_SIGNALS(excluding broad prose-only keysexposure,secret,secretsfrom signature matching) and_effective_text_tokens(cfg).
- Fast-skips pure numeric
- Structured tags & CWEs (
_scan_tags,_scan_cwes): Extracts normalized CWEs (CWE-<int>) fromcwes_jsonandCWE-\d+inside tags, mapping them via_CWE_SIGNAL_MAP(e.g.,CWE-78,CWE-89,CWE-94,CWE-287,CWE-306,CWE-502,CWE-798,CWE-918). - Remote port & threat-intel signals: Adds
remote_servicewhenaffected_portis in_REMOTE_PORT_SIGNALS,exploitwhenexploit_evidenceorverified_exploitis true, andkevwhenin_kevis true. - Memoization caches: Uses bounded memo dictionaries (
text_field_memo,cwes_memo,tags_memo,sig_memo,refs_memo,eval_memo) so 500k+ finding runs avoid redundant regex/substring scans on repeated plugin descriptions.
Rule Evaluation, Guardrails, & Uplift Math
_evaluate_aci_signals_to_result() executes deterministically:
- Capability matching & guardrails:
- Iterates enabled
cfg.capability_rules, retaining the maximum rule weight per matched capability. - Remote-service guardrail:
remote_executionandinitial_accessare suppressed if the only matched signal isremote_service. - Lateral-movement guardrail:
lateral_movementfrom protocol-only signals (smb,ssh,rdp,rpc) is suppressed unlesshas_exploit,in_kev,_LATERAL_CONTEXT_SIGNALS, or_LATERAL_CONTEXT_KEYWORDSare present. - In
mergemode,_EXTRA_CAPABILITY_SIGNALSadditionally scoresdeserialization(0.80),ssrf(0.70),initial_accessviassrf/deserialization(0.70),panel/misconfig/exposure(0.50), andxss(0.55).
- Iterates enabled
- Confidence & exploit boost:
confidence_base = min(1.0, sum(capability_weight_max.values()))- If
exploit_boost.enabledandhas_exploit:exploit_bonus = min(max_bonus, weight * confidence_base) confidence = min(1.0, confidence_base + exploit_bonus)- Buckets:
high >= 0.8,medium >= 0.5, elselow.
- Chain inference: Matches enabled
cfg.chain_ruleswhereset(rule.requires_all).issubset(matched_capabilities). - Rank uplift:
- If
confidence >= min_confidence:uplift = clamp(max_uplift * ((confidence - min_confidence) / (1.0 - min_confidence)), 0.0, max_uplift) - Else
0.0.
- If
Downstream Integration (Track B, Triage, TopN, Ledger, UI/Dossier)
Scoring@3.0Track B (exposure_weakness): Non-CVE findings gain+3.5for high-impact ACI capabilities (or+2.0for general capabilities) and+1.0foraci_chainsbeforesignal_reliabilityweighting;score_tracerecordsaci_capabilitiesandaci_chains.Triage@2.0: Consumesaci_signalsforbod-26-04SSVCexploitation=active(reliable Track B active exposure),automatable,technical_impact=total,P2chain elevation, andstatic_sastP1-cap corroboration.TopN@2.0: Usesaci.uplift_score DESCas a deterministic tie-breaker in SQLORDER BY/ROW_NUMBER()windows.- Decision Ledger (
ledger_events):_emit_ledger()appendsACI_INFERENCE_SUMMARYand up to 10ACI_FINDING_INFERREDsample events whenfinding_semanticsis populated (<= 10,000findings). vpp ui& Reporting:repositories.get_finding_detail()andreporting/renderer.pyexposecapabilities,chains,matched_tokens,aci_confidence, andaci_uplift_scoreto the TUI finding inspector and Decision Defense Dossier templates.
Validation Boundaries
- JSON Schema:
topN.schema.jsonenforces structure and numeric bounds onaci.*. - Semantic validation (
TN_triage_semantics._parse_aci): Enforces unique rule IDs, non-empty normalized signals, validtoken_mode(mergeorreplace), valid capability references inchain_rules, and0.0 <= min_confidence <= 1.0. - Testing: Covered by
tests/test_aci_pass.pyandtests/test_aci_v2.py(parity across DuckDB andScanResult, non-CVE Nuclei/SAST Track B uplift,scanner_sigmatching, and guardrail enforcement).