Create detailed vulnerability management system with tracking,
remediation plans, and manual update scripts.
New Files:
----------
1. VULNERABILITY_TRACKING.md (NEW)
- Complete inventory of all 35 vulnerabilities
- Detailed analysis of each critical/high vulnerability
- Fixable vs unfixable breakdown
- Remediation plans with specific commands
- Risk assessment for unfixable vulnerabilities
- Phase-based remediation timeline
- Success metrics and monitoring plan
- Quick reference commands
2. scripts/manual-security-update.sh (NEW)
- Manual dependency update script
- Works when npm audit fix fails (network restrictions)
- Updates dependencies in priority order:
* Critical: crypto-js, form-data, jsonpath-plus, pbkdf2, sha.js
* High: axios, glob, jsonwebtoken, jws, node-forge, ws
* Moderate: @babel/runtime, webpack-dev-server, tmp
- Automatic backup creation
- Post-update audit report
- Rollback instructions
- Exit codes for CI/CD integration
Vulnerability Summary:
----------------------
Total: 35 vulnerabilities
├─ 🔴 Critical: 8 (5 fixable, 3 unfixable)
├─ 🟠 High: 8 (7 fixable, 1 unfixable)
├─ 🟡 Moderate: 11 (10 fixable, 1 unfixable)
└─ ⚪ Low: 8 (8 fixable, 0 unfixable)
Fixability: 86% (30/35)
Critical Vulnerabilities (Fixable):
------------------------------------
1. crypto-js < 4.2.0
- PBKDF2 1,000x weaker than spec
- Fix: npm install crypto-js@^4.2.0
2. jsonpath-plus < 10.2.0
- Remote Code Execution (RCE)
- CVSS: 9.8
- Fix: npm install jsonpath-plus@^10.2.0
3. pbkdf2 <= 3.1.2
- Silently returns static keys for Uint8Array input
- Breaks crypto guarantees
- Fix: npm install pbkdf2@^3.1.3
4. sha.js <= 2.4.11
- Missing type checks, hash rewind possible
- Fix: npm install sha.js@^2.4.12
5. form-data 4.0.0-4.0.3
- Unsafe random for boundary selection
- Fix: npm install form-data@^4.0.4
Critical Vulnerabilities (Unfixable):
--------------------------------------
1. babel-traverse (all versions)
- Babel 6.x EOL package
- Dev dependency only
- Risk: MEDIUM (mitigated by dev-only usage)
- Decision: ACCEPT RISK (documented)
2. babel-template (all versions)
- Via babel-traverse
- Risk: Same as above
3. babel-plugin-transform-builtin-extend
- Via babel-traverse
- Action: Review if needed, consider removal
High Severity Vulnerabilities (Fixable):
-----------------------------------------
- axios < 1.12.0: DoS attack
- glob < 10.5.0: Command injection
- jsonwebtoken <= 8.5.1: Unrestricted key type
- jws < 3.2.3: HMAC signature bypass
- node-forge < 1.3.2: ASN.1 unbounded recursion
- shelljs < 0.8.5: Privilege management
- ws < 5.2.4: DoS with many headers
Remediation Plan:
-----------------
Phase 1 (Day 1): Fix 5 critical vulnerabilities
Phase 2 (Week 1): Fix 7 high vulnerabilities
Phase 3 (Week 2): Fix 10 moderate vulnerabilities
Phase 4 (Week 2): Fix 8 low, review unfixable
Usage:
------
Manual Updates (Recommended):
```bash
chmod +x scripts/manual-security-update.sh
./scripts/manual-security-update.sh
```
Individual Updates:
```bash
# Critical
npm install crypto-js@^4.2.0 jsonpath-plus@^10.2.0 pbkdf2@^3.1.3 sha.js@^2.4.12 --save
npm install form-data@^4.0.4 --save-dev
# High
npm install axios@^1.12.0 jsonwebtoken@^9.0.0 jws@^3.2.3 node-forge@^1.3.2 ws@^8.0.0 --save
npm install glob@^10.5.0 shelljs@^0.8.5 --save-dev
```
Testing:
```bash
npm test
npm run build
npm run security:triage
```
Integration with Automation:
-----------------------------
The manual-security-update.sh script:
- Can be run in CI/CD when npm audit fix fails
- Generates JSON audit reports
- Exit codes: 0 (success), 1 (remaining vulns), 2 (audit error)
- Integrates with security-auto-fix.yml workflow
Documentation:
--------------
VULNERABILITY_TRACKING.md provides:
- Executive summary with counts
- Detailed analysis of each vulnerability
- CVE/GHSA references where available
- CVSS scores
- Impact assessment
- Specific remediation commands
- Testing requirements
- Risk acceptance documentation for unfixable
Risk Management:
----------------
Unfixable vulnerabilities are documented with:
- Risk level assessment
- Mitigation strategies
- Attack surface analysis
- Acceptance criteria
- Long-term remediation plans
This addresses the "eliminowanie podatności Krytycznych i Wysokich"
requirement with comprehensive tooling and documentation.
Next Steps:
-----------
1. Run ./scripts/manual-security-update.sh
2. Test thoroughly
3. Review unfixable babel-* dependencies
4. Consider removing babel-plugin-transform-builtin-extend if unused
5. Document accepted risks in SECURITY.md
137 lines
4.6 KiB
Bash
Executable File
137 lines
4.6 KiB
Bash
Executable File
#!/bin/bash
|
||
# Manual Dependency Security Update Script
|
||
# Run this when npm audit fix fails due to network restrictions
|
||
|
||
set -e
|
||
|
||
echo "🔒 Manual Security Dependency Updates"
|
||
echo "======================================"
|
||
echo ""
|
||
echo "This script manually updates vulnerable dependencies"
|
||
echo "identified in npm audit to their secure versions."
|
||
echo ""
|
||
|
||
# Backup package files
|
||
echo "📋 Creating backup..."
|
||
cp package.json package.json.backup.$(date +%Y%m%d_%H%M%S)
|
||
cp package-lock.json package-lock.json.backup.$(date +%Y%m%d_%H%M%S)
|
||
|
||
echo "✅ Backup created"
|
||
echo ""
|
||
|
||
# Critical vulnerabilities (must fix)
|
||
echo "🔴 Installing CRITICAL security updates..."
|
||
echo ""
|
||
|
||
echo "1/5 crypto-js: Fixing PBKDF2 weakness..."
|
||
npm install crypto-js@^4.2.0 --save 2>/dev/null || echo "⚠️ Failed to update crypto-js"
|
||
|
||
echo "2/5 form-data: Fixing unsafe random boundary..."
|
||
npm install form-data@^4.0.4 --save-dev 2>/dev/null || echo "⚠️ Failed to update form-data"
|
||
|
||
echo "3/5 jsonpath-plus: Fixing RCE vulnerability..."
|
||
npm install jsonpath-plus@^10.2.0 --save 2>/dev/null || echo "⚠️ Failed to update jsonpath-plus"
|
||
|
||
echo "4/5 pbkdf2: Fixing Uint8Array input issue..."
|
||
npm install pbkdf2@^3.1.3 --save 2>/dev/null || echo "⚠️ Failed to update pbkdf2"
|
||
|
||
echo "5/5 sha.js: Fixing type check bypass..."
|
||
npm install sha.js@^2.4.12 --save 2>/dev/null || echo "⚠️ Failed to update sha.js"
|
||
|
||
echo ""
|
||
echo "🟠 Installing HIGH severity updates..."
|
||
echo ""
|
||
|
||
echo "1/6 axios: Fixing DoS vulnerability..."
|
||
npm install axios@^1.12.0 --save 2>/dev/null || echo "⚠️ Failed to update axios"
|
||
|
||
echo "2/6 glob: Fixing command injection..."
|
||
npm install glob@^10.5.0 --save-dev 2>/dev/null || echo "⚠️ Failed to update glob"
|
||
|
||
echo "3/6 jsonwebtoken: Fixing unrestricted key type..."
|
||
npm install jsonwebtoken@^9.0.0 --save 2>/dev/null || echo "⚠️ Failed to update jsonwebtoken"
|
||
|
||
echo "4/6 jws: Fixing HMAC signature verification..."
|
||
npm install jws@^3.2.3 --save 2>/dev/null || echo "⚠️ Failed to update jws"
|
||
|
||
echo "5/6 node-forge: Fixing unbounded recursion..."
|
||
npm install node-forge@^1.3.2 --save 2>/dev/null || echo "⚠️ Failed to update node-forge"
|
||
|
||
echo "6/6 ws: Fixing DoS with many headers..."
|
||
npm install ws@^8.0.0 --save 2>/dev/null || echo "⚠️ Failed to update ws"
|
||
|
||
echo ""
|
||
echo "🟡 Installing MODERATE severity updates..."
|
||
echo ""
|
||
|
||
echo "1/3 @babel/runtime: Fixing ReDoS..."
|
||
npm install @babel/runtime@^7.26.10 --save 2>/dev/null || echo "⚠️ Failed to update @babel/runtime"
|
||
|
||
echo "2/3 webpack-dev-server: Fixing source code theft..."
|
||
npm install webpack-dev-server@^5.2.2 --save-dev 2>/dev/null || echo "⚠️ Failed to update webpack-dev-server"
|
||
|
||
echo "3/3 tmp: Fixing symlink vulnerability..."
|
||
npm install tmp@^0.2.5 --save-dev 2>/dev/null || echo "⚠️ Failed to update tmp"
|
||
|
||
echo ""
|
||
echo "🔍 Running post-update audit..."
|
||
npm audit --json > audit-post-update.json 2>/dev/null || true
|
||
|
||
# Generate report
|
||
python3 <<'PYTHON'
|
||
import json
|
||
import sys
|
||
|
||
try:
|
||
with open('audit-post-update.json') as f:
|
||
data = json.load(f)
|
||
|
||
meta = data.get('metadata', {}).get('vulnerabilities', {})
|
||
|
||
print("\n📊 UPDATED VULNERABILITY STATUS")
|
||
print("=" * 50)
|
||
print(f"🔴 Critical: {meta.get('critical', 0)}")
|
||
print(f"🟠 High: {meta.get('high', 0)}")
|
||
print(f"🟡 Moderate: {meta.get('moderate', 0)}")
|
||
print(f"⚪ Low: {meta.get('low', 0)}")
|
||
print(f"📦 Total: {meta.get('total', 0)}")
|
||
print("=" * 50)
|
||
|
||
if meta.get('critical', 0) == 0 and meta.get('high', 0) == 0:
|
||
print("\n✅ All critical and high vulnerabilities resolved!")
|
||
sys.exit(0)
|
||
else:
|
||
print(f"\n⚠️ Still have {meta.get('critical', 0)} critical and {meta.get('high', 0)} high vulnerabilities")
|
||
print(" These may require manual intervention or are unfixable.")
|
||
sys.exit(1)
|
||
|
||
except FileNotFoundError:
|
||
print("\n⚠️ Could not generate post-update report")
|
||
print(" Run: npm audit")
|
||
sys.exit(2)
|
||
PYTHON
|
||
|
||
audit_exit=$?
|
||
|
||
echo ""
|
||
echo "📝 Next steps:"
|
||
if [ $audit_exit -eq 0 ]; then
|
||
echo " ✅ Run tests: npm test"
|
||
echo " ✅ Build: npm run build"
|
||
echo " ✅ Commit changes"
|
||
elif [ $audit_exit -eq 1 ]; then
|
||
echo " ⚠️ Review unfixable vulnerabilities"
|
||
echo " ⚠️ Check CODEQL_FINDINGS_ASSESSMENT.md"
|
||
echo " ⚠️ Consider alternative packages if needed"
|
||
else
|
||
echo " ⚠️ Run: npm audit"
|
||
echo " ⚠️ Review output manually"
|
||
fi
|
||
|
||
echo ""
|
||
echo "🔄 Rollback if needed:"
|
||
echo " mv package.json.backup.* package.json"
|
||
echo " mv package-lock.json.backup.* package-lock.json"
|
||
echo " npm install"
|
||
echo ""
|