|
| 1 | +# Security Audit Report |
| 2 | + |
| 3 | +**Date:** 2026-01-30 |
| 4 | +**Version:** 0.1.0 |
| 5 | +**Status:** Pre-release audit |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Executive Summary |
| 10 | + |
| 11 | +| Category | Critical | High | Medium | Low | Total | |
| 12 | +|----------|----------|------|--------|-----|-------| |
| 13 | +| npm Dependencies | 0 | 16 | 6 | 13 | 35 | |
| 14 | +| Code Vulnerabilities | 0 | 2 | 4 | 3 | 9 | |
| 15 | +| **Total** | **0** | **18** | **10** | **16** | **44** | |
| 16 | + |
| 17 | +**Recommendation:** Fix HIGH severity issues before npm publish. |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## 1. npm Dependency Vulnerabilities (35) |
| 22 | + |
| 23 | +### HIGH Severity (16) |
| 24 | + |
| 25 | +#### 1.1 axios ≤0.29.0 (GHSA-wf5p-g6vw-rhxx, GHSA-jr5f-v2jv-69x6) |
| 26 | +- **Issue:** CSRF vulnerability, SSRF and credential leakage via absolute URL |
| 27 | +- **Affected:** `@orca-so/whirlpool-sdk` |
| 28 | +- **Fix:** Update whirlpool-sdk or replace with alternative |
| 29 | +- **Priority:** HIGH |
| 30 | + |
| 31 | +#### 1.2 bigint-buffer (GHSA-3gc7-fjrx-p6mg) |
| 32 | +- **Issue:** Buffer overflow via toBigIntLE() |
| 33 | +- **Affected:** `@solana/buffer-layout-utils`, `@solana/spl-token`, `@solana/web3.js` |
| 34 | +- **Fix:** `npm audit fix --force` (breaking change to wormhole-sdk) |
| 35 | +- **Priority:** HIGH |
| 36 | + |
| 37 | +#### 1.3 elliptic (GHSA-848j-6mx2-7j84) |
| 38 | +- **Issue:** Cryptographic primitive with risky implementation |
| 39 | +- **Affected:** `@cosmjs/crypto`, `secp256k1` |
| 40 | +- **Fix:** Update secp256k1 to 1.1.6+ (breaking change) |
| 41 | +- **Priority:** HIGH - affects crypto signing |
| 42 | + |
| 43 | +### MODERATE Severity (6) |
| 44 | + |
| 45 | +#### 1.4 nanoid <3.3.8 (GHSA-mwcw-c2x4-8c55) |
| 46 | +- **Issue:** Predictable results with non-integer values |
| 47 | +- **Affected:** `@drift-labs/sdk` |
| 48 | +- **Fix:** Update drift-labs/sdk |
| 49 | +- **Priority:** MEDIUM |
| 50 | + |
| 51 | +#### 1.5 nodemailer ≤7.0.10 (GHSA-mm7p-fcc7-pg87, GHSA-rcmh-qjqh-p98v) |
| 52 | +- **Issue:** Email domain interpretation conflict, DoS via recursion |
| 53 | +- **Affected:** Direct dependency |
| 54 | +- **Fix:** `npm update nodemailer` to 7.0.13+ |
| 55 | +- **Priority:** MEDIUM |
| 56 | + |
| 57 | +#### 1.6 undici <6.23.0 (GHSA-g9mf-h72j-4rw9) |
| 58 | +- **Issue:** Unbounded decompression chain DoS |
| 59 | +- **Affected:** `discord.js`, `@discordjs/rest` |
| 60 | +- **Fix:** Update discord.js |
| 61 | +- **Priority:** MEDIUM |
| 62 | + |
| 63 | +### LOW Severity (13) |
| 64 | +- Various transitive dependencies with minor issues |
| 65 | +- Most are informational or require specific conditions to exploit |
| 66 | + |
| 67 | +--- |
| 68 | + |
| 69 | +## 2. Code Vulnerabilities |
| 70 | + |
| 71 | +### HIGH Risk |
| 72 | + |
| 73 | +#### 2.1 Command Injection - `src/nodes/index.ts` |
| 74 | +```typescript |
| 75 | +// VULNERABLE: User-controlled paths in shell commands |
| 76 | +execSync(`ffmpeg ... -y "${outPath}" ...`); |
| 77 | +execSync(`say "${text.replace(/"/g, '\\"')}"`); |
| 78 | +execSync(`notify-send "${title}" "${body}"`); |
| 79 | +``` |
| 80 | +- **Risk:** If `outPath`, `text`, `title`, or `body` contain shell metacharacters, arbitrary commands can be executed |
| 81 | +- **Fix:** Use `execFile()` with array arguments instead of `execSync()` with string interpolation |
| 82 | +- **Files:** `src/nodes/index.ts`, `src/macos/index.ts` |
| 83 | + |
| 84 | +#### 2.2 Unsafe Sandbox - `src/security/index.ts` |
| 85 | +```typescript |
| 86 | +// WARNING in code: "Very basic sandboxing - in production, use vm2 or isolated-vm" |
| 87 | +const fn = new Function(...Object.keys(sandbox), `"use strict"; return (${code})`); |
| 88 | +``` |
| 89 | +- **Risk:** `new Function()` can be escaped; sandbox is not secure |
| 90 | +- **Fix:** Replace with `isolated-vm` or `vm2` for production use |
| 91 | +- **Files:** `src/security/index.ts:558` |
| 92 | + |
| 93 | +### MEDIUM Risk |
| 94 | + |
| 95 | +#### 2.3 Prototype Pollution Risk |
| 96 | +```typescript |
| 97 | +Object.assign(opp, scored); // If 'scored' has __proto__, pollution possible |
| 98 | +``` |
| 99 | +- **Risk:** If external data is merged without sanitization |
| 100 | +- **Files:** Multiple files use `Object.assign()` with external data |
| 101 | +- **Fix:** Validate objects before merging, use `Object.create(null)` for maps |
| 102 | + |
| 103 | +#### 2.4 Credential Logging Risk |
| 104 | +- **Risk:** 388 `process.env` references - ensure sensitive vars aren't logged |
| 105 | +- **Fix:** Audit all logging calls to ensure no credential exposure |
| 106 | +- **Files:** Throughout codebase |
| 107 | + |
| 108 | +#### 2.5 Path Traversal - Potential |
| 109 | +- **Risk:** User-controlled paths could escape intended directories |
| 110 | +- **Fix:** Validate and normalize paths, use `path.resolve()` with base checks |
| 111 | +- **Files:** File operation handlers |
| 112 | + |
| 113 | +#### 2.6 Missing Rate Limiting |
| 114 | +- **Risk:** API endpoints without rate limiting could be abused |
| 115 | +- **Fix:** Implement rate limiting on all public endpoints |
| 116 | +- **Files:** `src/gateway/` |
| 117 | + |
| 118 | +### LOW Risk |
| 119 | + |
| 120 | +#### 2.7 Error Message Information Disclosure |
| 121 | +- **Risk:** Detailed error messages may leak internal paths/state |
| 122 | +- **Fix:** Sanitize error messages in production |
| 123 | + |
| 124 | +#### 2.8 Insecure Randomness |
| 125 | +- **Risk:** `Math.random()` used in some non-crypto contexts |
| 126 | +- **Fix:** Use `crypto.randomBytes()` for any security-sensitive randomness |
| 127 | + |
| 128 | +#### 2.9 Missing Input Validation |
| 129 | +- **Risk:** Some API inputs not fully validated |
| 130 | +- **Fix:** Add input validation schemas (zod/joi) |
| 131 | + |
| 132 | +--- |
| 133 | + |
| 134 | +## 3. Remediation Plan |
| 135 | + |
| 136 | +### Phase 1: Critical Fixes (Before npm Publish) |
| 137 | + |
| 138 | +| # | Issue | Fix | Status | |
| 139 | +|---|-------|-----|--------| |
| 140 | +| 1 | nodemailer | Updated to 7.0.13 | ✅ DONE | |
| 141 | +| 2 | Command injection | Replaced execSync with execFileSync in nodes/index.ts and macos/index.ts | ✅ DONE | |
| 142 | +| 3 | Unsafe sandbox | Added security warning + production logging in security/index.ts | ✅ DONE | |
| 143 | + |
| 144 | +### Phase 2: High Priority (Next Release) |
| 145 | + |
| 146 | +| # | Issue | Fix | Effort | |
| 147 | +|---|-------|-----|--------| |
| 148 | +| 4 | elliptic/secp256k1 | Update with breaking change testing | 4 hours | |
| 149 | +| 5 | bigint-buffer | Update Solana libs | 4 hours | |
| 150 | +| 6 | axios in orca-sdk | Replace orca-sdk or patch | 2 hours | |
| 151 | +| 7 | discord.js undici | Update discord.js | 1 hour | |
| 152 | + |
| 153 | +### Phase 3: Hardening (Ongoing) |
| 154 | + |
| 155 | +| # | Issue | Fix | Effort | |
| 156 | +|---|-------|-----|--------| |
| 157 | +| 8 | Prototype pollution | Add object sanitization | 2 hours | |
| 158 | +| 9 | Rate limiting | Add express-rate-limit | 2 hours | |
| 159 | +| 10 | Input validation | Add zod schemas | 4 hours | |
| 160 | +| 11 | Credential audit | Review all logging | 2 hours | |
| 161 | + |
| 162 | +--- |
| 163 | + |
| 164 | +## 4. Security Best Practices Implemented |
| 165 | + |
| 166 | +✅ **Encrypted credentials** - AES-256-GCM at rest |
| 167 | +✅ **No hardcoded secrets** - All from environment |
| 168 | +✅ **HTTPS enforced** - For all API calls |
| 169 | +✅ **Webhook signature verification** - HMAC validation |
| 170 | +✅ **SQL injection prevention** - Parameterized queries |
| 171 | +✅ **Audit logging** - All trades logged |
| 172 | + |
| 173 | +--- |
| 174 | + |
| 175 | +## 5. Recommended Security Headers |
| 176 | + |
| 177 | +Add to gateway responses: |
| 178 | +```typescript |
| 179 | +{ |
| 180 | + 'X-Content-Type-Options': 'nosniff', |
| 181 | + 'X-Frame-Options': 'DENY', |
| 182 | + 'X-XSS-Protection': '1; mode=block', |
| 183 | + 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains', |
| 184 | + 'Content-Security-Policy': "default-src 'self'", |
| 185 | +} |
| 186 | +``` |
| 187 | + |
| 188 | +--- |
| 189 | + |
| 190 | +## 6. Before Publishing Checklist |
| 191 | + |
| 192 | +- [ ] Fix nodemailer vulnerability |
| 193 | +- [ ] Fix command injection in nodes/index.ts |
| 194 | +- [ ] Add sandbox warning or replace with vm2 |
| 195 | +- [ ] Run `npm audit` - ensure no critical/high in direct deps |
| 196 | +- [ ] Test all trading functions work after updates |
| 197 | +- [ ] Review this document with team |
| 198 | + |
| 199 | +--- |
| 200 | + |
| 201 | +## 7. Disclosure Policy |
| 202 | + |
| 203 | +Security issues should be reported to: security@clodds.dev (or GitHub Security Advisories) |
| 204 | + |
| 205 | +Do NOT create public issues for security vulnerabilities. |
| 206 | + |
| 207 | +--- |
| 208 | + |
| 209 | +*Generated by security audit on 2026-01-30* |
0 commit comments