Summary
Karakeep 0.30.0 contains a stored cross-site scripting (XSS) vulnerability in its Reddit metascraper integration, where HTML returned in readableContentHtml is injected into the reader view without sanitization.
If an attacker can influence the HTML content returned from Reddit, that malicious markup is rendered via dangerouslySetInnerHTML in users' browsers and can execute arbitrary JavaScript in their session.
Affected context
The issue occurs in Karakeep's crawler/reader pipeline specifically when processing content through the Reddit metascraper plugin.
Unlike other content sources, this path bypasses both Readability and DOMPurify, passing the readableContentHtml response directly into a frontend component that uses dangerouslySetInnerHTML to render the reader view.
Deployments that ingest Reddit content and present it to end users in the reader interface are affected when the application treats that HTML as trusted.
Exploit preconditions
- Attack surface: Web UI (reader view) rendering Reddit-sourced content.
- Required access: Ability to cause Karakeep to fetch or display Reddit content containing attacker-controlled HTML (e.g., by controlling or influencing a Reddit post, comment, or previewed content).
- Trigger point: A user opens a Karakeep reader view for an affected Reddit item whose
readableContentHtmlincludes malicious markup or script constructs. - Why exploitation is possible: The Reddit-specific pipeline skips the normal sanitization flow;
readableContentHtmlis not passed through Readability or DOMPurify and is rendered directly viadangerouslySetInnerHTML, allowing script-capable HTML to execute.
Why this happens
This vulnerability stems from inconsistent output sanitization in the content-processing pipeline.
Most sources in Karakeep are normalized via Readability and then sanitized by DOMPurify before being rendered, but the Reddit metascraper path bypasses these steps and treats the returned readableContentHtml as trusted.
Mapping to CWE-79: Improper Neutralization of Input During Web Page Generation (XSS), the bug class is: untrusted HTML from an external system is inserted into the DOM using dangerouslySetInnerHTML without proper sanitization or encoding, enabling execution of attacker-controlled JavaScript in the browser.
Potential impact
- Attacker-controlled JavaScript may run in the context of the Karakeep web application.
- Session data and in-app sensitive information could be read or exfiltrated from the browser.
- User actions might be spoofed, such as adding, modifying, or deleting bookmarks or configuration via scripted requests.
- Content displayed in the UI could be altered to perform phishing or drive-by attacks against users.
- If the app is integrated with other services or APIs, tokens or API keys accessible from the frontend could be at risk.
General mitigation guidance
Mitigation focuses on enforcing a consistent HTML sanitization strategy for all content sources and avoiding unsafe DOM APIs where possible.
Recommended patterns include:
- Ensuring every ingestion path that can produce HTML passes through a robust, allowlist-based HTML sanitizer (e.g., DOMPurify or equivalent) before rendering.
- Normalizing content from third-party sources through a common processing pipeline (such as Readability + sanitization) rather than maintaining special-case bypasses.
- Minimizing or eliminating usage of
dangerouslySetInnerHTML; where it is unavoidable, restrict it to sanitized, application-controlled HTML only. - Adopting a strict Content Security Policy (CSP) to limit the impact of potential future XSS issues (e.g., disallow inline scripts and unsafe eval).
- Treating all external or third-party content as untrusted, regardless of perceived reputation of the source, and applying the same sanitization guarantees across the board.
How teams detect issues like this
Detection typically involves reviewing both the frontend rendering code and the content ingestion pipeline:
- Static analysis and linting:
- Search for
dangerouslySetInnerHTML,innerHTML, and similar sinks, and verify each usage is preceded by explicit sanitization. - Enforce lint rules or custom checks that flag direct injection of untrusted HTML into the DOM.
- Code review signals:
- Identify special-case logic for particular content sources (e.g., Reddit-specific branches) and verify they reuse the shared sanitization utilities.
- Examine places where HTML from external services is trusted based on origin (e.g., "it's from Reddit, so it's safe") rather than explicit sanitization.
- Automated security testing:
- Use dynamic scanners or integration tests that inject benign XSS test strings into external content and verify that they are neutralized in the UI.
- Integrate security-focused unit tests around the content-processing and rendering modules, asserting that sanitizer functions are always invoked for HTML sources.
- Policy enforcement:
- Implement CI/CD policies that require security review for any changes to HTML rendering paths, sanitizer configuration, or metascraper plugins.

