CVE-2021-23341
📋 TL;DR
This vulnerability affects PrismJS syntax highlighting library versions before 1.23.0, allowing attackers to cause denial of service through specially crafted input in prism-asciidoc, prism-rest, prism-tap, and prism-eiffel components. The regular expression patterns in these components can be exploited to cause excessive CPU consumption, potentially crashing the application. Any application using vulnerable PrismJS versions for syntax highlighting is affected.
💻 Affected Systems
- PrismJS
- Applications using PrismJS for syntax highlighting
📦 What is this software?
Prism by Prismjs
⚠️ Risk & Real-World Impact
Worst Case
Complete application unavailability due to CPU exhaustion, potentially affecting all users of the service.
Likely Case
Degraded performance or temporary service disruption for users accessing pages with maliciously crafted content.
If Mitigated
Minimal impact with proper input validation and rate limiting in place.
🎯 Exploit Status
Exploitation requires ability to submit content that gets processed by vulnerable PrismJS components
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 1.23.0 and later
Vendor Advisory: https://github.com/PrismJS/prism/security/advisories/GHSA-3949-f494-cmcc
Restart Required: No
Instructions:
1. Update PrismJS to version 1.23.0 or later using package manager (npm update prismjs) 2. Verify no vulnerable dependencies remain 3. Test syntax highlighting functionality
🔧 Temporary Workarounds
Disable vulnerable components
allRemove or disable prism-asciidoc, prism-rest, prism-tap, and prism-eiffel components if not needed
Remove component imports from your application
Input validation
allImplement strict input validation and length limits for content processed by PrismJS
🧯 If You Can't Patch
- Implement WAF rules to block suspicious patterns in user input
- Deploy rate limiting to prevent repeated exploitation attempts
🔍 How to Verify
Check if Vulnerable:
Check package.json or package-lock.json for prismjs version <1.23.0
Check Version:
npm list prismjs
Verify Fix Applied:
Verify prismjs version is 1.23.0 or higher in package.json
📡 Detection & Monitoring
Log Indicators:
- High CPU usage spikes
- Application crashes or timeouts during content processing
Network Indicators:
- Unusually large payloads to content submission endpoints
SIEM Query:
source="application_logs" AND ("CPU spike" OR "timeout" OR "prism")
🔗 References
- https://github.com/PrismJS/prism/commit/c2f6a64426f44497a675cb32dccb079b3eff1609
- https://github.com/PrismJS/prism/issues/2583
- https://github.com/PrismJS/prism/pull/2584
- https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARS-1076583
- https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-1076582
- https://snyk.io/vuln/SNYK-JS-PRISMJS-1076581
- https://github.com/PrismJS/prism/commit/c2f6a64426f44497a675cb32dccb079b3eff1609
- https://github.com/PrismJS/prism/issues/2583
- https://github.com/PrismJS/prism/pull/2584
- https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARS-1076583
- https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-1076582
- https://snyk.io/vuln/SNYK-JS-PRISMJS-1076581