Skip to content

Commit 204fdfb

Browse files
Security Auditclaude
andcommitted
security: use safeJsonParse in WAC ACL parser for DoS protection
Replace raw JSON.parse() with safeJsonParse() which enforces a 10MB size limit before parsing. This prevents memory exhaustion attacks via maliciously large ACL documents. The safeJsonParse utility was already available in utils/url.js but wasn't being used consistently across the codebase. This addresses the audit finding about inconsistent JSON parsing protection. CVSS: 5.3 (Medium) - DoS via large JSON payloads 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2569811 commit 204fdfb

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/wac/parser.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55

66
import { turtleToJsonLd } from '../rdf/turtle.js';
7+
import { safeJsonParse } from '../utils/url.js';
78

89
const ACL = 'http://www.w3.org/ns/auth/acl#';
910
const FOAF = 'http://xmlns.com/foaf/0.1/';
@@ -35,9 +36,9 @@ export async function parseAcl(content, aclUrl) {
3536
if (typeof content === 'object' && content !== null) {
3637
doc = content;
3738
} else if (typeof content === 'string') {
38-
// Try JSON-LD first
39+
// Try JSON-LD first (with size limit for DoS protection)
3940
try {
40-
doc = JSON.parse(content);
41+
doc = safeJsonParse(content);
4142
} catch {
4243
// Not JSON, try Turtle
4344
try {

0 commit comments

Comments
 (0)