Backdoor & Malicious Pattern Detection with Deterministic Supply Chain Validation
Summary
Add a dedicated Backdoor & Malicious Pattern Detection provider to ai-slop-gate to identify both unintentional hallucinated dependencies and intentionally harmful patterns, and to verify third-party dependencies against official registries. This addresses risks from AI-native hallucination, slopsquatting, prompt injection attacks, and supply chain poisoning.
Background
As AI coding agents become part of standard CI/CD workflows, two distinct classes of supply chain risk emerge:
- Unintentional Hallucination — the most common and highest-frequency failure mode. The AI generates imports for packages that simply don't exist. No malicious actor required; vanilla code generation does this routinely.
- Intentional Slopsquatting & Backdoor Injection — a weaponized variant where attackers exploit the hallucination pattern deliberately, or manipulate agent sessions to insert malicious logic.
This issue tracks both categories, with different detection strategies for each: deterministic registry validation for the first, heuristics and semantic analysis for the second.
Current providers focus on unintentional "AI slop" quality. This issue extends coverage to supply chain identity verification and malicious pattern detection.
Attack Scenarios
-
Scenario 0 - Unintentional Hallucination (Most Common): The AI generates an import for @stripe/react-v3 or lodash-extended — packages that sound plausible but simply don't exist in the registry. No malicious intent; the code compiles (TypeScript validates structure, not registry existence), tests pass (the import path is never exercised), and it crashes in production. Deterministic registry validation at CI time catches this category reliably without pattern matching or heuristics.
-
Scenario 1 - Intentional Slopsquatting (The Raye-Deng Case): An attacker registers a package like strpie or lodassh in the official npm/PyPI registry, knowing an LLM might hallucinate these names. The package does exist — it's just not the one the developer intended. Harder to detect than Scenario 0 because existence checks alone are insufficient; metadata anomalies (age, popularity) become the primary signal.
-
Scenario 2 - Subtle Version/Export Mismatch: An agent hallucinates a specific method or API signature from a different major version than what's installed. An attacker provides a malicious "compatibility" package that matches this hallucinated signature to intercept data. Detection requires verifying not just that a package exists, but that the specific version and specific exports referenced in the code actually match the published package.
-
Scenario 3 - Prompt Injection via PR diff: An attacker hides instructions in a file (e.g., in a comment or data fixture). The agent reads this during a review/edit session and inserts a reverse shell or logic bomb in a subsequent generation.
Proposed Detection Signals
1. Deterministic Supply Chain Validation
Catches Scenario 0 reliably; provides complementary signals for Scenarios 1–2.
- Registry Existence Check: Cross-reference every new
import/require against official registry APIs (npm, PyPI). 100% block if the package does not exist.
- Package Metadata Anomalies:
- Age: Flag packages created/updated in the last 72 hours (typical for volatility attacks).
- Popularity: Flag "standard-looking" packages with suspiciously low download counts (<100/week).
- Export Integrity: Verify that the specific methods or classes referenced in the code actually exist in the published package metadata for the installed version.
2. Obfuscation & Logic Bombs
Complementary heuristic layer for Scenarios 1–3 where deterministic checks are insufficient.
- Runtime Decoding: Base64 or Hex-encoded strings decoded and executed via
eval(), exec(), or Function().
- Hidden Network Calls: Outbound requests to non-whitelisted domains or HTTP calls inside non-networking modules (e.g., inside a data model).
- Conditional Triggers: Logic bombs checking for specific environment variables (e.g.,
if os.environ.get("PROD")) or time-based triggers.
Proposed Implementation
- Module:
ai_slop_gate/providers/static/supply_chain_provider.py (deterministic registry validation for Scenarios 0–2)
- Module:
ai_slop_gate/providers/static/backdoor_detector.py (heuristic analysis for Scenario 3)
- Registry Client:
ai_slop_gate/providers/static/registry_client.py (handles cached API calls to npm/PyPI)
Updated Provider Matrix
| Provider |
Focus |
Verification Method |
| StaticSecurityProvider |
Common vulnerabilities (CVEs), hardcoded secrets. |
Pattern matching against known vulnerability signatures. |
| SupplyChainProvider |
Identity & Provenance. Catches hallucinated packages (Scenario 0) and detects slopsquatting (Scenario 1) via metadata anomalies. |
Deterministic Registry API Calls (npm, PyPI) to verify existence, age, popularity, and export integrity. |
| BackdoorDetectorProvider |
Intentional Malicious Logic. Detects reverse shells and logic bombs (Scenarios 2–3). |
Heuristics & Semantic Analysis of code patterns and behavior signals — complementary to deterministic checks. |
Why This Matters for EU Compliance
- NIS2 Directive: Directly addresses the requirement for rigorous supply chain security.
- Cyber Resilience Act (CRA): Ensures development tooling doesn't introduce unverified or malicious dependencies.
- DORA: Enhances resilience of software delivery pipelines for the financial sector.
Acceptance Criteria
Labels
enhancement security provider supply-chain commercial-potential eu-compliance future
Backdoor & Malicious Pattern Detection with Deterministic Supply Chain Validation
Summary
Add a dedicated Backdoor & Malicious Pattern Detection provider to
ai-slop-gateto identify both unintentional hallucinated dependencies and intentionally harmful patterns, and to verify third-party dependencies against official registries. This addresses risks from AI-native hallucination, slopsquatting, prompt injection attacks, and supply chain poisoning.Background
As AI coding agents become part of standard CI/CD workflows, two distinct classes of supply chain risk emerge:
This issue tracks both categories, with different detection strategies for each: deterministic registry validation for the first, heuristics and semantic analysis for the second.
Current providers focus on unintentional "AI slop" quality. This issue extends coverage to supply chain identity verification and malicious pattern detection.
Attack Scenarios
Scenario 0 - Unintentional Hallucination (Most Common): The AI generates an import for
@stripe/react-v3orlodash-extended— packages that sound plausible but simply don't exist in the registry. No malicious intent; the code compiles (TypeScript validates structure, not registry existence), tests pass (the import path is never exercised), and it crashes in production. Deterministic registry validation at CI time catches this category reliably without pattern matching or heuristics.Scenario 1 - Intentional Slopsquatting (The Raye-Deng Case): An attacker registers a package like
strpieorlodasshin the official npm/PyPI registry, knowing an LLM might hallucinate these names. The package does exist — it's just not the one the developer intended. Harder to detect than Scenario 0 because existence checks alone are insufficient; metadata anomalies (age, popularity) become the primary signal.Scenario 2 - Subtle Version/Export Mismatch: An agent hallucinates a specific method or API signature from a different major version than what's installed. An attacker provides a malicious "compatibility" package that matches this hallucinated signature to intercept data. Detection requires verifying not just that a package exists, but that the specific version and specific exports referenced in the code actually match the published package.
Scenario 3 - Prompt Injection via PR diff: An attacker hides instructions in a file (e.g., in a comment or data fixture). The agent reads this during a review/edit session and inserts a reverse shell or logic bomb in a subsequent generation.
Proposed Detection Signals
1. Deterministic Supply Chain Validation
Catches Scenario 0 reliably; provides complementary signals for Scenarios 1–2.
import/requireagainst official registry APIs (npm, PyPI). 100% block if the package does not exist.2. Obfuscation & Logic Bombs
Complementary heuristic layer for Scenarios 1–3 where deterministic checks are insufficient.
eval(),exec(), orFunction().if os.environ.get("PROD")) or time-based triggers.Proposed Implementation
ai_slop_gate/providers/static/supply_chain_provider.py(deterministic registry validation for Scenarios 0–2)ai_slop_gate/providers/static/backdoor_detector.py(heuristic analysis for Scenario 3)ai_slop_gate/providers/static/registry_client.py(handles cached API calls to npm/PyPI)Updated Provider Matrix
Why This Matters for EU Compliance
Acceptance Criteria
SupplyChainProviderwith deterministic registry existence checks (npm, PyPI) — catches Scenario 0 with no heuristics required.RegistryClientfor cached API calls supporting existence, age, and popularity signals.BackdoorDetectorProviderwith obfuscation detection (e.g., base64/hex eval) for Scenario 3.Labels
enhancementsecurityprovidersupply-chaincommercial-potentialeu-compliancefuture