|
| 1 | +# JSS Security Audit Report |
| 2 | + |
| 3 | +**Date:** 2026-01-03 |
| 4 | +**Auditor:** Security Review |
| 5 | +**Version Audited:** 0.0.48 |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Executive Summary |
| 10 | + |
| 11 | +A security audit of JavaScriptSolidServer revealed **2 critical**, **2 high**, and **2 medium** severity vulnerabilities. The most severe allows unauthenticated users to read and write ACL (Access Control List) files, effectively bypassing all authorization. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## Critical Vulnerabilities |
| 16 | + |
| 17 | +### 1. ACL Files Bypass Authorization (CRITICAL) ⚠️ |
| 18 | + |
| 19 | +**Location:** `src/auth/middleware.js:24-28` |
| 20 | + |
| 21 | +```javascript |
| 22 | +if (urlPath.endsWith('.acl') || method === 'OPTIONS') { |
| 23 | + return { authorized: true, webId: null, wacAllow: '...', authError: null }; |
| 24 | +} |
| 25 | +``` |
| 26 | + |
| 27 | +**Description:** The authorization middleware explicitly skips authentication and authorization checks for all requests to `.acl` files. This allows any unauthenticated user to: |
| 28 | + |
| 29 | +1. **Read any ACL file** - Discover permission structures |
| 30 | +2. **Write/Create any ACL file** - Grant themselves access to any resource |
| 31 | +3. **Modify existing ACL files** - Lock out legitimate owners |
| 32 | + |
| 33 | +**Proof of Concept:** |
| 34 | +```bash |
| 35 | +# Read root ACL without authentication |
| 36 | +curl https://example.com/.acl |
| 37 | + |
| 38 | +# Create malicious ACL without authentication |
| 39 | +curl -X PUT https://example.com/victim/.acl \ |
| 40 | + -H "Content-Type: application/ld+json" \ |
| 41 | + -d '{"@graph":[{"@id":"#attacker","@type":"acl:Authorization","acl:agent":{"@id":"https://attacker.com/card#me"},"acl:accessTo":{"@id":"https://example.com/victim/"},"acl:mode":[{"@id":"acl:Read"},{"@id":"acl:Write"},{"@id":"acl:Control"}]}]}' |
| 42 | +``` |
| 43 | + |
| 44 | +**Impact:** Complete authorization bypass. Attacker can gain full control of any resource. |
| 45 | + |
| 46 | +**CVSS Score:** 9.8 (Critical) |
| 47 | + |
| 48 | +**Fix Required:** ACL files should require `acl:Control` permission on the resource they protect. |
| 49 | + |
| 50 | +--- |
| 51 | + |
| 52 | +### 2. JWT Token Signature Not Verified (CRITICAL) ⚠️ |
| 53 | + |
| 54 | +**Location:** `src/auth/token.js:93-122` |
| 55 | + |
| 56 | +```javascript |
| 57 | +function verifyJwtToken(token) { |
| 58 | + const parts = token.split('.'); |
| 59 | + if (parts.length !== 3) return null; |
| 60 | + |
| 61 | + // Decode the payload (middle part) - NO SIGNATURE VERIFICATION! |
| 62 | + const payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString()); |
| 63 | + |
| 64 | + if (payload.exp && payload.exp < Math.floor(Date.now() / 1000)) { |
| 65 | + return null; |
| 66 | + } |
| 67 | + |
| 68 | + if (payload.webid) { |
| 69 | + return { webId: payload.webid, iat: payload.iat, exp: payload.exp }; |
| 70 | + } |
| 71 | + // ... |
| 72 | +} |
| 73 | +``` |
| 74 | + |
| 75 | +**Description:** The `verifyJwtToken` function decodes JWT tokens but **never verifies the cryptographic signature**. An attacker can craft arbitrary JWT tokens with any WebID. |
| 76 | + |
| 77 | +**Proof of Concept:** |
| 78 | +```bash |
| 79 | +# Forge a JWT token with attacker's WebID (signature is ignored) |
| 80 | +# Header: {"alg":"RS256","typ":"JWT"} |
| 81 | +# Payload: {"webid":"https://attacker.com/card#me","exp":9999999999} |
| 82 | +curl https://example.com/private/ \ |
| 83 | + -H "Authorization: Bearer eyJhbGciOiJSUzI1NiJ9.eyJ3ZWJpZCI6Imh0dHBzOi8vYXR0YWNrZXIuY29tL2NhcmQjbWUiLCJleHAiOjk5OTk5OTk5OTl9.fakesig" |
| 84 | +``` |
| 85 | + |
| 86 | +**Impact:** Complete authentication bypass. Attacker can impersonate any user. |
| 87 | + |
| 88 | +**CVSS Score:** 9.8 (Critical) |
| 89 | + |
| 90 | +**Fix Required:** Verify JWT signatures against the issuer's JWKS before accepting tokens. |
| 91 | + |
| 92 | +--- |
| 93 | + |
| 94 | +## High Severity Vulnerabilities |
| 95 | + |
| 96 | +### 3. Pod Creation Without Authentication (HIGH) |
| 97 | + |
| 98 | +**Location:** `src/server.js:203,228` |
| 99 | + |
| 100 | +```javascript |
| 101 | +// Auth bypass list includes /.pods |
| 102 | +if (request.url === '/.pods' || ...) { |
| 103 | + return; // Skip auth |
| 104 | +} |
| 105 | + |
| 106 | +// Anyone can create pods |
| 107 | +fastify.post('/.pods', handleCreatePod); |
| 108 | +``` |
| 109 | + |
| 110 | +**Description:** The `/.pods` endpoint allows anyone to create new pods without authentication. |
| 111 | + |
| 112 | +**Impact:** |
| 113 | +- Resource exhaustion (DoS) |
| 114 | +- Username/namespace squatting |
| 115 | +- Disk space exhaustion |
| 116 | + |
| 117 | +**CVSS Score:** 7.5 (High) |
| 118 | + |
| 119 | +**Fix Required:** Require authentication or implement rate limiting and CAPTCHA. |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +### 4. Default Token Secret in Production (HIGH) |
| 124 | + |
| 125 | +**Location:** `src/auth/token.js:15` |
| 126 | + |
| 127 | +```javascript |
| 128 | +const SECRET = process.env.TOKEN_SECRET || 'dev-secret-change-in-production'; |
| 129 | +``` |
| 130 | + |
| 131 | +**Description:** If `TOKEN_SECRET` environment variable is not set, a hardcoded default secret is used. |
| 132 | + |
| 133 | +**Impact:** Tokens can be forged by anyone who knows the default secret. |
| 134 | + |
| 135 | +**CVSS Score:** 8.1 (High) |
| 136 | + |
| 137 | +**Fix Required:** Fail to start if TOKEN_SECRET is not set in production, or generate a random secret on first run. |
| 138 | + |
| 139 | +--- |
| 140 | + |
| 141 | +## Medium Severity Vulnerabilities |
| 142 | + |
| 143 | +### 5. No Rate Limiting on Authentication Endpoints (MEDIUM) |
| 144 | + |
| 145 | +**Location:** `src/idp/interactions.js`, `src/idp/credentials.js` |
| 146 | + |
| 147 | +**Description:** Login, registration, and credential endpoints have no rate limiting, allowing brute force attacks. |
| 148 | + |
| 149 | +**Impact:** Account takeover through credential stuffing or brute force. |
| 150 | + |
| 151 | +**CVSS Score:** 5.3 (Medium) |
| 152 | + |
| 153 | +**Fix Required:** Implement rate limiting (e.g., 5 attempts per minute per IP). |
| 154 | + |
| 155 | +--- |
| 156 | + |
| 157 | +### 6. Information Disclosure via Error Messages (MEDIUM) |
| 158 | + |
| 159 | +**Location:** Various handlers |
| 160 | + |
| 161 | +**Description:** Error messages may reveal internal paths or stack traces. |
| 162 | + |
| 163 | +**Impact:** Information leakage useful for further attacks. |
| 164 | + |
| 165 | +**CVSS Score:** 4.3 (Medium) |
| 166 | + |
| 167 | +--- |
| 168 | + |
| 169 | +## Recommendations |
| 170 | + |
| 171 | +### Immediate Actions (Critical) |
| 172 | + |
| 173 | +1. **Fix ACL bypass** - Require `acl:Control` permission to modify ACL files |
| 174 | +2. **Verify JWT signatures** - Use `jose` library to verify against issuer JWKS |
| 175 | + |
| 176 | +### Short-term Actions (High) |
| 177 | + |
| 178 | +3. **Protect pod creation** - Add authentication or rate limiting |
| 179 | +4. **Enforce TOKEN_SECRET** - Fail startup if not configured |
| 180 | + |
| 181 | +### Medium-term Actions |
| 182 | + |
| 183 | +5. **Add rate limiting** - Use `@fastify/rate-limit` plugin |
| 184 | +6. **Sanitize error messages** - Remove internal details from user-facing errors |
| 185 | + |
| 186 | +--- |
| 187 | + |
| 188 | +## Remediation Status |
| 189 | + |
| 190 | +| Issue | Severity | Status | Fixed In | |
| 191 | +|-------|----------|--------|----------| |
| 192 | +| ACL bypass | Critical | 🟢 Fixed | v0.0.49 | |
| 193 | +| JWT signature bypass | Critical | 🟢 Fixed | v0.0.49 | |
| 194 | +| Unauthenticated pod creation | High | 🔴 Open | - | |
| 195 | +| Default token secret | High | 🔴 Open | - | |
| 196 | +| No rate limiting | Medium | 🔴 Open | - | |
| 197 | +| Information disclosure | Medium | 🔴 Open | - | |
| 198 | + |
| 199 | +--- |
| 200 | + |
| 201 | +## Changelog |
| 202 | + |
| 203 | +### v0.0.49 (2026-01-03) |
| 204 | +- **Fixed ACL bypass**: ACL files now require `acl:Control` permission on the protected resource |
| 205 | +- **Fixed JWT signature bypass**: JWTs are now verified against the IdP's JWKS before accepting |
| 206 | + |
| 207 | +*Report generated: 2026-01-03* |
| 208 | +*Last updated: 2026-01-03* |
0 commit comments