supply-chain-dependency-risks-ai-code
Understand supply chain vulnerabilities and dependency risks in AI-generated code including outdated packages, malicious packages, and dependency confusion attacks. Use this skill when you need to learn about vulnerable dependencies in AI code, understand supply chain attacks, recognize typosquatting, or identify outdated package suggestions. Triggers include "supply chain attacks", "dependency vulnerabilities", "outdated packages", "malicious npm packages", "typosquatting", "dependency confusion", "vulnerable dependencies AI", "npm security".
What this skill does
# Insecure Dependencies and Supply Chain Risks in AI-Generated Code
## The Hidden Danger of Outdated Packages
Research from the Center for Security and Emerging Technology identifies supply chain vulnerabilities as **one of three main categories** of AI code generation risks, noting:
> "Models generating code often suggest outdated or vulnerable dependencies, creating a cascading effect of security issues."
## 1.4.1 Using Vulnerable Dependencies
### The Problem
A 2025 analysis by KDnuggets found:
> "AI models frequently suggest packages that haven't been updated in years, with **67% of suggested dependencies containing at least one known vulnerability**."
### Why This Happens
**1. Training Data Lag:**
- AI trained on code from 2020-2023
- Suggests package versions from that era
- Doesn't know about vulnerabilities discovered since
**2. Example Code Bias:**
- Tutorial code uses older, stable versions
- AI learns these as "recommended"
- Perpetuates outdated patterns
**3. No Vulnerability Awareness:**
- AI can't check CVE databases
- Doesn't know which versions are vulnerable
- Can't reason about security patches
### AI-Generated Vulnerable Code
#### Vulnerable package.json
```json
// package.json generated by AI
{
"name": "ai-generated-app",
"dependencies": {
"express": "3.0.0", // ❌ VULNERABLE: 66 known vulnerabilities
"mongoose": "4.0.0", // ❌ VULNERABLE: Multiple injection vulnerabilities
"jsonwebtoken": "5.0.0", // ❌ VULNERABLE: Algorithm confusion vulnerability
"request": "2.88.0", // ❌ DEPRECATED: No longer maintained
"node-uuid": "1.4.8", // ❌ DEPRECATED: Should use 'uuid' instead
"body-parser": "1.9.0", // ❌ VULNERABLE: DoS vulnerability
"bcrypt": "0.8.7", // ❌ OUTDATED: Missing critical security fixes
"moment": "2.19.3", // ❌ VULNERABLE: ReDoS and path traversal
"lodash": "4.17.4", // ❌ VULNERABLE: Prototype pollution
"axios": "0.18.0" // ❌ VULNERABLE: SSRF vulnerability
}
}
```
#### Vulnerable requirements.txt
```python
# requirements.txt generated by AI
Flask==0.12.0 # ❌ VULNERABLE: Multiple security issues
Django==1.8.0 # ❌ EOL: No longer receives security updates
requests==2.6.0 # ❌ VULNERABLE: Multiple CVEs
PyYAML==3.11 # ❌ VULNERABLE: Arbitrary code execution
Pillow==3.3.2 # ❌ VULNERABLE: Multiple security issues
cryptography==2.1.4 # ❌ OUTDATED: Missing important fixes
paramiko==1.15.0 # ❌ VULNERABLE: Authentication bypass
sqlalchemy==0.9.0 # ❌ VULNERABLE: SQL injection possibilities
jinja2==2.7.0 # ❌ VULNERABLE: XSS vulnerabilities
urllib3==1.22 # ❌ VULNERABLE: Multiple security issues
```
### What's Wrong With These Versions
**Express 3.0.0:**
- Released: **2012** (13 years old)
- Known vulnerabilities: **66**
- Current version: 4.19.0
- Missing: Security middleware, vulnerability fixes
**jsonwebtoken 5.0.0:**
- **Algorithm confusion vulnerability**
- Allows attackers to forge tokens
- Change algorithm from RS256 to none
- Bypass authentication entirely
**PyYAML 3.11:**
- **Arbitrary code execution** vulnerability
- Unsafe YAML parsing
- Attacker can execute Python code
- CVE-2017-18342
**Django 1.8.0:**
- **End of Life** (no security updates)
- Multiple known CVEs
- Current version: 5.0+
- Missing years of security fixes
### Secure Implementation
#### Secure package.json
```json
// package.json with security considerations
{
"name": "secure-app",
"dependencies": {
"express": "^4.19.0", // ✅ Latest stable version
"mongoose": "^8.0.3", // ✅ Current version with security fixes
"jsonwebtoken": "^9.0.2", // ✅ Latest with improved security
"axios": "^1.6.5", // ✅ Maintained alternative to 'request'
"uuid": "^9.0.1", // ✅ Current uuid package
"bcrypt": "^5.1.1", // ✅ Latest with security improvements
"dayjs": "^1.11.10", // ✅ Lightweight alternative to moment
"lodash": "^4.17.21", // ✅ Patched version
"helmet": "^7.1.0", // ✅ Security middleware
"express-rate-limit": "^7.1.5" // ✅ Rate limiting for DoS protection
},
"devDependencies": {
"npm-audit-resolver": "^3.0.0", // ✅ Tool for managing vulnerabilities
"snyk": "^1.1266.0", // ✅ Vulnerability scanning
"eslint-plugin-security": "^2.1.0" // ✅ Security linting
},
"scripts": {
"audit": "npm audit --production",
"audit:fix": "npm audit fix",
"snyk:test": "snyk test",
"snyk:monitor": "snyk monitor",
"security:check": "npm run audit && npm run snyk:test",
"preinstall": "npm run security:check"
},
"engines": {
"node": ">=18.0.0", // ✅ Require LTS version
"npm": ">=9.0.0"
}
}
```
#### Secure requirements.txt
```python
# requirements.txt with version pinning and comments
# Last security review: 2025-01-15
# Web Framework
Flask==3.0.0 # ✅ Latest stable with security patches
flask-cors==4.0.0 # ✅ CORS handling with security defaults
flask-limiter==3.5.0 # ✅ Rate limiting
# Database
SQLAlchemy==2.0.25 # ✅ Latest stable version
psycopg2-binary==2.9.9 # ✅ PostgreSQL adapter
# Authentication & Security
PyJWT==2.8.0 # ✅ JWT implementation
bcrypt==4.1.2 # ✅ Password hashing
cryptography==41.0.7 # ✅ Cryptographic recipes
# HTTP Requests
requests==2.31.0 # ✅ Latest stable
urllib3==2.1.0 # ✅ HTTP library with security fixes
# Data Processing
pandas==2.1.4 # ✅ Data analysis (if needed)
pyyaml==6.0.1 # ✅ YAML parser with security fixes
# Image Processing
Pillow==10.2.0 # ✅ Latest with security patches
# Development & Security Tools
python-dotenv==1.0.0 # ✅ Environment variable management
python-jose==3.3.0 # ✅ JOSE implementation
email-validator==2.1.0 # ✅ Email validation
# Security Scanning (dev dependencies)
safety==3.0.1 # ✅ Check for known security issues
bandit==1.7.6 # ✅ Security linter for Python
```
### Real-World Supply Chain Attacks
**event-stream Incident (2018):**
- Popular npm package (**2 million downloads/week**)
- Maintainer transferred to malicious actor
- Code added that **stole cryptocurrency wallet keys**
- Thousands of applications affected
- Discovered only after user reported suspicious behavior
**ua-parser-js Incident (2021):**
- Package with **8 million weekly downloads**
- Compromised by attacker
- Added **cryptocurrency mining** code
- Added **password-stealing** functionality
- Affected thousands of companies
**colors.js / faker.js Incident (2022):**
- Maintainer intentionally corrupted packages (protest)
- **Millions of applications broke** simultaneously
- Demonstrated single-point-of-failure risk
- Showed supply chain fragility
### Supply Chain Attack Statistics
According to Sonatype's 2024 State of the Software Supply Chain Report:
- **245,000 malicious packages** published to npm (2023)
- **700% increase** in supply chain attacks (vs 2022)
- Average application has **200+ dependencies**
- Each dependency averages **5 transitive dependencies** (dependencies of dependencies)
**Attack Growth:**
- 2020: 929 supply chain attacks
- 2021: 12,000+ attacks
- 2022: 88,000+ attacks
- 2023: 245,000+ attacks
- **Growth trend: 3-4x per year**
---
## 1.4.2 Dependency Confusion Attacks
### The Problem
AI frequently generates typos or wrong package names, which can lead to installing malicious packages designed to exploit common mistakes.
### AI-Generated Vulnerable Code
```python
# AI might generate typos or wrong package names
pip install reqeusts # ❌ TYPO: Could install malicious package
pip install python-sqlite # ❌ WRONG: Should use built-in sqlite3
pip install dateutils # ❌ WRONG: Should be python-dateutil
pip install crypto # ❌ WRONG: Should be pycryptodome
pip install yaml # ❌ WRONG: Should be pyyaml
```
### Real Typosquatting Examples
**Documented malicious pacRelated in Security
mac-ops
IncludedComprehensive macOS workstation operations — diagnose kernel panics, identify failing drives, audit launchd startup items, decode wake reasons, triage TCC permission denials, manage APFS snapshots, recover from no-boot. Use for: Mac is slow, slow bootup, won't boot, kernel panic, kernel_task hot, mds_stores CPU, photoanalysisd, cloudd, login loop, gray screen, sleep wake failure, drive failing, IO errors, APFS snapshots eating space, Time Machine local snapshots, Spotlight indexing, launchd, LaunchAgent, LaunchDaemon, login items, TCC permissions, Full Disk Access, Screen Recording denied, Gatekeeper, quarantine, com.apple.quarantine, app is damaged, helper tool, /Library/PrivilegedHelperTools, pmset, wake reasons, dark wake, sysdiagnose, panic.ips, DiagnosticReports, configuration profile, MDM profile, remote diagnostics over SSH.
a11y-audit
IncludedRun accessibility audits on web projects combining automated scanning (axe-core, Lighthouse) with WCAG 2.1 AA compliance mapping, manual check guidance, and structured reporting. Output is configurable: markdown report only, markdown plus machine-readable JSON, or markdown plus issue tracker integration. Use this skill whenever the user mentions "accessibility audit", "a11y audit", "WCAG audit", "accessibility check", "compliance scan", or asks to check a web project for accessibility issues. Also trigger when the user wants to verify WCAG conformance or map findings to a specific standard (CAN-ASC-6.2, EN 301 549, ADA/AODA).
erpclaw
IncludedAI-native ERP system with self-extending OS. Full accounting, invoicing, inventory, purchasing, tax, billing, HR, payroll, advanced accounting (ASC 606/842, intercompany, consolidation), and financial reporting. 413 actions across 14 domains, 43 expansion modules. Constitutional guardrails, adversarial audit, schema migration. Double-entry GL, immutable audit trail, US GAAP.
assess
IncludedAssesses and rates quality 0-10 across multiple dimensions (correctness, maintainability, security, performance, testability, simplicity) with pros/cons analysis. Compares against project conventions and prior decisions from memory. Produces structured evaluation reports with actionable improvement suggestions. Use when evaluating code, designs, architectures, or comparing alternative approaches.
spring-boot-security-jwt
IncludedProvides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based access control using Spring Security 6.x. Use when implementing authentication or authorization in Spring Boot applications.
code-hardcode-audit
IncludedDetect hardcoded values, magic numbers, and leaked secrets. TRIGGERS - hardcode audit, magic numbers, PLR2004, secret scanning.