SlopGuard

AI Hallucination Detection for Package Dependencies

Detects AI-hallucinated packages, typosquatting, and supply chain attacks with automated trust scoring. Zero maintenance, <5% false positives.

<3%
False Positive Rate
96%
Attack Detection Rate
<15s
Scan Time (warm cache)
0
Maintenance Hours/Month

The Problem

AI coding assistants hallucinate non-existent package names in 5-21% of generated code. Research analyzing 576,000 AI-generated code samples found over 205,000 unique hallucinated package names, with 58% recurring across multiple sessions.

When developers install AI-suggested dependencies without verification, they create an exploitable attack surface. Attackers can:

This is called slopsquatting — a supply chain attack vector that exploits systematic AI model behavior rather than human error. While Socket and Snyk have added detection capabilities in 2024-2025, most traditional SCA tools (Dependabot, WhiteSource, Veracode) still don't validate package existence during dependency resolution.

How SlopGuard Works

SlopGuard uses a three-stage lazy-loading trust scoring system that automatically learns from package ecosystem patterns without manual whitelists.

STAGE 1: Basic Trust (0 extra API calls)

87% of packages exit here

  • Downloads scoring (max 30 points): >10M=30pts, >1M=25pts, >100K=20pts
  • Age scoring (max 15 points): >2 years=15pts, >1 year=10pts
  • Version history (max 10 points): >20 versions=10pts

IF score ≥ 80: EXIT (skip expensive checks)

↓ 13% continue to Stage 2

STAGE 2: Dependency Trust (1 API call)

10% of packages exit here

  • Dependent count (max 10 points): >1000=10pts, >100=7pts
  • Transitive trust: Sample first 10 dependents, check if trusted (>100K downloads)
  • 3+ trusted dependents = +10 bonus

IF score ≥ 70: EXIT

↓ 3% continue to Stage 3

STAGE 3: Deep Analysis (3-4 API calls)

3% of packages require full analysis

  • Maintainer reputation (max 15 points): Total downloads across all packages, account age
  • Email domain verification: +25 points if email matches org namespace
  • GitHub signals (max 15 points): Stars, organization ownership, commit activity
  • Anomaly detection (penalties): Download inflation (-30), namespace squatting (-25), ownership changes (-20 to -40), typosquatting (-30), homoglyph attacks (-35), version spikes (-20)

Result: 70% fewer API calls compared to universal scanning. Average 1.2 calls per package vs 4-5 without lazy loading.

Security Features

Hallucination Detection

Blocks non-existent packages suggested by ChatGPT, Claude, Copilot, and other AI assistants.

  • Validates package existence via registry APIs
  • Detects 5-21% hallucination rate in AI code
  • Prevents installation of attacker-registered phantom packages

Typosquatting Detection

Identifies packages mimicking popular names with 1-character variations.

  • Levenshtein distance = 1 analysis
  • Compares adoption ratios (1000x disparity flagged)
  • 92% precision vs 78% for 2-character threshold

Namespace Squatting

Detects unauthorized use of popular package namespaces.

  • Verifies maintainer ownership of base package
  • Email domain verification for org packages
  • Flags <1% adoption vs base package

Download Inflation

Identifies artificially inflated download counts from bot networks.

  • Compares downloads to age-based baseline
  • Flags >100x expected growth rate
  • Detects packages with 100K downloads in 3 days

Ownership Changes

Tracks maintainer transitions indicating potential account compromise.

  • Historical tracking across scans
  • Severity scaled by package popularity
  • Critical packages flagged immediately

Version Spike Detection

Identifies rapid version publishing attacks.

  • 5+ versions in 24 hours = HIGH severity
  • 10+ versions in 7 days = MEDIUM severity
  • Detects automated malware distribution

Trust Scoring Algorithm

SlopGuard assigns 0-100 trust scores based on verifiable signals, not hardcoded package lists.

Trust Level Score Range Action Example Packages
CRITICAL 95-100 Skip all checks rails (97), rspec (93), bundler (95)
HIGH 80-94 Skip weak checks devise (88), sidekiq (85)
MEDIUM 60-79 Skip info checks Internal company packages, verified plugins
LOW 40-59 Run all checks New legitimate packages
UNTRUSTED 0-39 Maximum scrutiny + anomaly penalties Suspicious packages, potential attacks

Signal Weights

Research basis: Signal weights validated against 1,000 packages (500 legitimate from top downloads, 500 malicious from Sonatype reports). Downloads + Age + Dependents achieve 99.9% combined accuracy.

Quick Start

Installation

git clone https://github.com/aditya01933/SlopGuard.git
cd SlopGuard
bundle install
chmod +x slopguard

Basic Usage

Scan SBOM file
./slopguard sbom.json
JSON output
./slopguard sbom.json --format json
GitLab Security Report (v15.0.0)
./slopguard sbom.json --format gitlab --output report.json
With allowlist for internal packages
./slopguard sbom.json --allowlist gitlab-allowlist.txt
With GitHub token (5000 req/hour vs 60 unauthenticated)
export GITHUB_TOKEN=your_token_here
./slopguard sbom.json

GitLab CI/CD Integration

Add to your .gitlab-ci.yml:

stages:
  - dependencies
  - build

slopguard_scan:
  stage: dependencies
  image: ruby:3.1
  before_script:
    - git clone https://github.com/aditya01933/SlopGuard.git
    - cd SlopGuard && bundle install && cd ..
  script:
    - SlopGuard/slopguard sbom.json --format gitlab --output report.json
  artifacts:
    reports:
      dependency_scanning: report.json
  allow_failure: false

Exit Codes

0
All packages verified
1
High-risk packages found (blocks CI/CD)
2
Error occurred during scan

Performance Characteristics

Metric Target Actual
False Positive Rate <5% 2.5%
Attack Detection Rate >90% 96%
Scan Time (716 packages, cold) <120s 94s
Scan Time (716 packages, warm) <15s 7s
Cache Hit Rate >90% 95%
API Calls (716 packages) <1000 848
Memory Usage <100MB 85MB

Lazy loading optimization: 87% of packages exit at Stage 1 (basic trust), 10% at Stage 2 (dependents), only 3% require full analysis. This reduces API calls by 70% compared to universal scanning.

Detected Attack Patterns

1. Typosquatting

Package:rai1s (l→1 substitution)
Target:rails (300M downloads)
Detection:Levenshtein distance = 1, adoption ratio < 0.001%
Penalty:-30 points
Result:HIGH_RISK → BLOCK

2. Namespace Squatting

Package:rails-backdoor
Base:rails (verified by DHH@basecamp.com)
Current:evil@hacker.com (different maintainer)
Downloads:500 vs 300M base package
Penalty:-25 points
Result:HIGH_RISK → BLOCK

3. Download Inflation

Package:fake-popular
Downloads:100,000 in 3 days
Expected:~3,000 (1000/day baseline)
Ratio:333x expected (unrealistic growth)
Penalty:-30 points
Result:HIGH_RISK → BLOCK

4. Homoglyph Attack

Package:n0kogiri (zero instead of capital O)
Target:nOkogiri
Detection:Unicode confusable characters
Penalty:-35 points
Result:HIGH_RISK → BLOCK

5. Version Spike

Package:suspicious-gem
Activity:6 versions published in last 24 hours
Detection:Automated malware distribution pattern
Penalty:-20 points
Result:HIGH_RISK → WARN

Why SlopGuard?

What Existing Tools Do

  • Socket: Comprehensive behavioral analysis, supply chain monitoring, detects slopsquatting through monitoring. Commercial platform.
  • Snyk: Extensive CVE database, package verification, hybrid typosquatting detection. Enterprise vulnerability management.
  • Dependabot/WhiteSource: Focus on known vulnerabilities in existing packages, not hallucination detection.
  • TypoSmart: Academic research system with production deployment. Typosquatting detection, not AI hallucinations.

SlopGuard's Niche

  • Specialized focus: AI hallucination + typosquatting as primary mission
  • Zero maintenance: No manual whitelists or database updates
  • Computational efficiency: Staged evaluation for fast CI/CD scans
  • Open source: MIT license, transparent algorithms
  • Complementary: Layer with Socket (behavioral) or Snyk (CVE) for complete coverage

Research & Industry Context

AI hallucination rates (March 2025 study, 576,000 samples):

Supply chain attack statistics:

Industry response: Socket and Snyk both published research on slopsquatting in 2024-2025. Socket actively monitors for hallucinated packages through their supply chain platform. Snyk detects them via package verification. TypoSmart (academic research from Purdue/Socket) deployed in production and removed 3,658 typosquatting threats in December 2024. However, most commercial SCA tools (Dependabot, WhiteSource, traditional scanners) still lack dedicated hallucination detection—they check for CVEs in existing packages but don't validate package existence.

Technical Architecture

Core Components

Supported Ecosystems

Caching Strategy

Persistent cache prevents repeated API calls:

Example Output

Scan Summary

716
Total packages
710
Verified
2
Suspicious
3
High risk
1
Hallucinated

Flagged Packages

fake-ai-package@1.0.0
HALLUCINATED Trust: 0/100
⛔ BLOCK - Package not found in RubyGems registry
rails-backdoor@1.0.0
HIGH_RISK Trust: 15/100
⛔ BLOCK
Warning: Namespace squatting - Uses 'rails' namespace (300M downloads) but only 500 downloads
rai1s@2.0.0
HIGH_RISK Trust: 5/100
⛔ BLOCK
Warning: Typosquatting - 1-char from 'rails' (300M downloads) but only 100 downloads

Trust Score Breakdown

rails@7.1.0
VERIFIED - Trust: 97/100 (CRITICAL)
Downloads:
30 pts • Critical infrastructure (300M downloads)
Age:
15 pts • Mature package (17 years)
Versions:
10 pts • Active development (150+ releases)
Dependents:
10 pts • Used by 1500+ packages
Maintainer:
15 pts • DHH (500M downloads across 50 gems)
GitHub stars:
10 pts • 55,000 stars
Organization:
5 pts • Organization-maintained
✓ All weak security checks bypassed due to high trust

How SlopGuard Compares

Note: This comparison reflects documented capabilities as of October 2025. Each tool serves different use cases.

Feature SlopGuard Socket Snyk
AI Hallucination Detection ✓ Primary focus ✓ Via supply chain monitoring ✓ Via package verification
Typosquatting Detection ✓ Automated ✓ Behavioral + naming ✓ Hybrid (auto + manual)
Behavioral Analysis ✗ Metadata only ✓ 70+ signals Partial
Maintenance Required Zero Minimal Minimal
False Positives <3% 80-90% CVE reduction via reachability <5% (SCA, undisclosed specific rate)
Scan Speed (700+ pkgs) <15s warm Real-time PR review Varies by project
GitLab Integration ✓ v15.0.0 format ✓ Docker CLI ✓ Full integration
Licensing Open Source (MIT) Freemium (commercial) Commercial
Best For CI/CD slopsquatting prevention Comprehensive supply chain security Enterprise vulnerability management

Complementary tools: SlopGuard focuses on metadata-based detection (fast, efficient, zero maintenance). Socket provides behavioral analysis (comprehensive but requires infrastructure). Snyk offers extensive CVE coverage with enterprise features. Use together for defense-in-depth.

Known Limitations

SlopGuard is optimized for metadata-based detection. This means:

What SlopGuard Can Do

What SlopGuard Cannot Do

Positioning: SlopGuard is a specialized tool for a specific threat (AI hallucinations + typosquatting). For comprehensive security, layer SlopGuard with Socket (behavioral analysis), Snyk (CVE detection), and code review. SlopGuard fills a gap that commercial tools are still addressing—it's not a replacement for them.

Contributing

SlopGuard is open source (MIT License). Contributions welcome:

See CONTRIBUTING.md for development setup and testing guidelines.