Repository navigation
Closed
Labels
bugBug report.Bug report.confirmedConfirmed bug report or approved feature request.Confirmed bug report or approved feature request.coreRelated to the core parser code.Related to the core parser code.
Description
Description
While fuzz-testing the Python-Markdown library (version 3.8) with the extra extension enabled, I found that certain malformed inputs containing <![ sequences cause the parser to throw uncaught exceptions and crash. These inputs appear to break the parser's handling of XML-style marked sections, leading to errors like "expected name token" or "unknown status keyword."
Steps to Reproduce
- Run the following test script (using Python-Markdown 3.8 with
extraextension):
import markdown
print(markdown.__version__)
crash_inputs = [
"<![",
"<![>og))/uw_ f{tv+pAr$Ss+[6;^{=<:>g2oV|.pdTMu(Q-E#",
"<![ g'\"7z5r7cojSO;2LAo0(1Vv5G>,-P",
]
for i, crash_input in enumerate(crash_inputs, 1):
print(f"\nTesting crash input #{i}:\n{repr(crash_input)}")
try:
output = markdown.markdown(crash_input, extensions=["extra"])
print("No crash, output:")
print(output)
except Exception as e:
print(f"Crash confirmed! Exception:\n{e}")- Observe that the first three inputs cause exceptions, crashing the parser.
Expected Behavior
The parser should gracefully handle or sanitize malformed <![ marked sections without raising uncaught exceptions.
Actual Behavior
Uncaught exceptions are raised, such as:
3.8
Testing crash input #1:
'<!['
Crash confirmed! Exception:
expected name token at '<![\n\n'
Testing crash input #2:
'<![>og))/uw_ f{tv+pAr$Ss+[6;^{=<:>g2oV|.pdTMu(Q-E#'
Crash confirmed! Exception:
expected name token at '<![>og))/uw_ f{t'
Testing crash input #3:
'<![ g\'"7z5r7cojSO;2LAo0(1Vv5G>,-P'
Crash confirmed! Exception:
expected name token at '<![ g\'"7z5r7cojSO;2L'expected name token at '<![\n\n'expected name token at '<![>og))/uw_ f{t'expected name token at '<![ g\'"7z5r7cojSO;2L'
Impact
- Potential Denial of Service by crashing apps parsing untrusted Markdown.
- Stability risk in applications relying on Python-Markdown.
- Possible information leakage via stack traces if errors are exposed.
Environment
- Python-Markdown version: 3.8
- Python version: 3.11
- OS: Linux and Windows 11
Additional Notes
I performed fuzz testing and isolated these inputs causing crashes. I'm happy to provide more test cases or logs if needed.
Thank you for your attention to this issue!
Metadata
Metadata
Assignees
Labels
bugBug report.Bug report.confirmedConfirmed bug report or approved feature request.Confirmed bug report or approved feature request.coreRelated to the core parser code.Related to the core parser code.
Activity
waylan commentedon Jun 18, 2025
I can confirm the behavior. Thanks for the report. However, there is no need for
extrato get the reported behavior.Looks like we need to catch the
AssertionErrorinparse_html_declarationand handle it somehow.This is a high priority issue as crashes from Markdown input are unacceptable.
keshavgoyal1744 commentedon Jun 18, 2025
Thank you for confirming the issue and prioritizing it; I appreciate the quick analysis and detailed breakdown!
Given the potential impact (especially for apps processing untrusted Markdown), I wanted to ask if you plan to file a CVE for this vulnerability. If not, would you be open to me submitting one on behalf of the project? I’ll be happy to share all relevant details and credit the project appropriately.
Let me know what works best - happy to help however I can.
keshavgoyal1744 commentedon Jun 18, 2025
Also, I had actually noticed that the crash occurs even without the extra extension after I submitted the report, and didnt wanna make changes to the current report and thought of submitting another one. Appreciate you confirming it as well!
waylan commentedon Jun 18, 2025
Turns out this is a bug in the standard lib's
HTMLParserwhich was just fixed last month (see cpython#77057). We'll need to provide a workaround until we drop support for all older Python versions.keshavgoyal1744 commentedon Jun 18, 2025
Thanks for the clarification! That makes sense, I wasn’t aware it had been fixed recently in the standard library. Appreciate you confirming the root cause.
Would it be alright if I still requested a CVE for this issue, considering that many downstream projects using markdown are still on older Python versions and could be affected by the crash? I’d be happy to reference this upstream dependency and note that a workaround is being planned. Let me know if filing a CVE sounds appropriate in this context.
Best regards,
Keshav Goyal
Ensure incomplete markup declaration in raw HTML doesn't crash parser.
waylan commentedon Jun 18, 2025
You are welcome to file a CVE if you want.
I have a fix which should be ready to go in #1535. Feel free to verify it works for you. I expect to do a release (3.8.1) today with the fix.
keshavgoyal1744 commentedon Jun 18, 2025
I went through and verified the fix and it seems good to go. Thanks for your help!
Ensure incomplete markup declaration in raw HTML doesn't crash parser.
waylan commentedon Jun 18, 2025
Version 3.8.1 has been released with the fix. Thanks again for making the report.
chore(deps): update dependency markdown to v3.10 (#88)
[-]Uncaught exceptions/crashes when parsing malformed <![ marked sections in Python-Markdown 3.8 with extra extension[/-][+]Security: CVE-2025-69534 – Remote DoS via malformed <![ sequence in Python-Markdown 3.8[/+]keshavgoyal1744 commentedon Mar 4, 2026
CVE Assignment
This vulnerability has been assigned CVE-2025-69534.
Summary
A malformed HTML-like sequence
<![causes Python-Markdown 3.8 and earlier to trigger an unhandled AssertionError insidehtml.parser.HTMLParser.Because the exception is not caught by Python-Markdown, the process crashes, enabling remote unauthenticated Denial of Service when attacker-controlled Markdown is rendered.
Affected Versions
Python-Markdown <= 3.8
Fixed Version
Python-Markdown 3.8.1
Discoverer
Keshav Goyal
kohtala commentedon Mar 9, 2026
@keshavgoyal1744, the CVE-2025-69534 does not seem to specify which product it affects. Trivy somehow raised the CVE on Python itself. Please check the CVE assignment.
fix(ci): suppress un-fixable markdown DoS advisory PYSEC-2026-89