{"id":"CVE-2026-49851","aliases":["CVE-2026-49851","GHSA-qcq2-496w-v96p","PYSEC-2026-2652"],"related":[],"kind":"vulnerability","state":"published","title":"Mistune: Potential DoS via quadratic-time parsing in parse_link_text","summary":"Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.0, Mistune is vulnerable to a CPU exhaustion DoS due to superlinear (approximately O(n²)) behavior in parse_link_text. When parsing Markdown containing many consecutive [ characters, parse_link_text repeatedly scans the input using a regex search inside a loop. Each iteration re-scans a large portion of the remaining string, resulting in quadratic-time behavior. An attacker-controlled Markdown input can therefore trigger excessive CPU usage with a very small payload. This vulnerability is fixed in 3.3.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Mistune is a Python Markdown parser with renderers and plugins. Prior to 3.3.0, Mistune is vulnerable to a CPU exhaustion DoS due to superlinear (approximately O(n²)) behavior in parse_link_text. When parsing Markdown containing many consecutive [ characters, parse_link_text repeatedly scans the input using a regex search inside a loop. Each iteration re-scans a large portion of the remaining string, resulting in quadratic-time behavior. An attacker-controlled Markdown input can therefore trigger excessive CPU usage with a very small payload. This vulnerability is fixed in 3.3.0.","source":"cvelist"},{"lang":"en","text":"### Summary\nMistune is vulnerable to a CPU exhaustion DoS due to superlinear (approximately O(n²)) behavior in parse_link_text. A relatively small input consisting of repeated [ characters causes significant parsing slowdown.\n\n### Affected component\nmistune/inline_parser.py → **parse_link_text**\n\n### Description\nWhen parsing Markdown containing many consecutive [ characters, parse_link_text repeatedly scans the input using a regex search inside a loop. Each iteration re-scans a large portion of the remaining string, resulting in quadratic-time behavior.\nAn attacker-controlled Markdown input can therefore trigger excessive CPU usage with a very small payload.\n\n### Root cause\nThe vulnerability stems from a two-loop interaction:\n- The outer loop in `InlineParser.parse()` (inline_parser.py) advances \n  only 1 character at a time when parse_link() returns None\n- Each failed attempt calls `parse_link_text()` which performs an O(n) \n  scan to the end of the string looking for a closing `]`\n- With n consecutive `[` characters, this results in O(n) × O(n) = O(n²) \n  total work\n\n### PoC\nRun below python script\n```\nimport mistune\nimport time\n\nmd = mistune.create_markdown()\n\ns = \"[\" * 6400\n\nt = time.perf_counter()\nmd(s)\nprint(time.perf_counter() - t)\n```\n<img width=\"2028\" height=\"1277\" alt=\"image\" src=\"https://github.com/user-attachments/assets/15d5bc0b-35f8-4a15-85e0-cbc314a45b06\" />\n\n**Benmark poc**\nRun below code for benchmark\n```\nimport mistune\nimport time\n\nmd = mistune.create_markdown()\n\nsizes = [100,200,400,800,1600,3200,6400]\n\nfor n in sizes:\n    s = \"[\" * n\n\n    t0 = time.perf_counter()\n    md(s)\n    dt = time.perf_counter() - t0\n\n    print(f\"{n:6d} {dt:.6f}\")\n```\n<img width=\"2503\" height=\"1341\" alt=\"image\" src=\"https://github.com/user-attachments/assets/f09a7bbb-6927-4ba2-afb1-444dd913b84e\" />\n\n\n### Observed behaviour\n```\npython3 benchmark.py \n   100 0.001609\n   200 0.003207\n   400 0.012906\n   800 0.050220\n  1600 0.197307\n  3200 0.801172\n  6400 3.190393\n```\nExecution time grows superlinearly, consistent with O(n²) complex\n\n### Impact\nThis can be used as a denial-of-service attack in any application that parses user-supplied Markdown using Mistune, including:\n\n- Web applications (comments, posts, content rendering)\n- API services processing Markdown\n- Documentation rendering systems\n- A small (~6 KB) payload can block CPU for multiple seconds.\n\n### Suggested fix\nReturn the furthest scanned position from parse_link_text even on failure, so the outer loop can skip ahead instead of advancing 1 character at a time\n\n### Security Classification\nCWE-400: Uncontrolled Resource Consumption\nDenial of Service (CPU exhaustion)","format":"markdown","source":"ghsa"},{"lang":"es","text":"Mistune es un analizador de Markdown para Python con renderizadores y complementos. Antes de la 3.3.0, Mistune es vulnerable a un DoS por agotamiento de CPU debido a un comportamiento superlineal (aproximadamente O(n²)) en parse_link_text. Al analizar Markdown que contiene muchos caracteres [ consecutivos, parse_link_text escanea repetidamente la entrada utilizando una búsqueda de expresiones regulares dentro de un bucle. Cada iteración vuelve a escanear una gran parte de la cadena restante, lo que resulta en un comportamiento de tiempo cuadrático. Una entrada de Markdown controlada por un atacante puede, por lo tanto, desencadenar un uso excesivo de la CPU con una carga útil muy pequeña. Esta vulnerabilidad se corrigió en la 3.3.0.","source":"nvd"}],"published":"2026-06-24T17:05:33.602Z","modified":"2026-10-25T22:10:00.150Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","score":8.7,"rating":"HIGH"},{"scorer":"redhat-SADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N"}],"cwes":["CWE-400","CWE-407","CWE-770","CWE-1333"],"affected":[{"ranges":[{"version":"< 3.3.0","status":"affected"}],"vendor":"lepture","product":"mistune","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073866","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-pipeline-runtime-datascience-cpu-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073936","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-pipeline-runtime-minimal-cpu-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073873","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-pipeline-runtime-pytorch-cuda-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073459","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-pipeline-runtime-pytorch-llmcompressor-cuda-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073611","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-pipeline-runtime-pytorch-rocm-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073451","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-pipeline-runtime-tensorflow-cuda-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073451","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-pipeline-runtime-tensorflow-rocm-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787076778","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-th06-cpu-torch210-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787077779","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-th06-cuda130-torch210-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787076481","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-th06-rocm64-torch291-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787074331","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-workbench-jupyter-datascience-cpu-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073913","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-workbench-jupyter-minimal-cpu-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787074078","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-workbench-jupyter-minimal-cuda-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073929","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-workbench-jupyter-minimal-rocm-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073605","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-workbench-jupyter-pytorch-cuda-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073546","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-workbench-jupyter-pytorch-rocm-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073717","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-workbench-jupyter-tensorflow-cuda-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073713","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-workbench-jupyter-tensorflow-rocm-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[{"type":"rpm","introduced":"1787073593","fixed":"*","status":"unaffected"}],"vendor":"Red Hat","product":"Red Hat OpenShift AI 3.4","package":"rhoai/odh-workbench-jupyter-trustyai-cpu-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai:3.4::el9","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Migration Toolkit for Applications 8","package":"mta/mta-solution-server-rhel9","cpe":"cpe:/a:redhat:migration_toolkit_applications:8","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift AI (RHOAI)","package":"rhoai/odh-th06-cpu-torch291-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift AI (RHOAI)","package":"rhoai/odh-th06-cuda130-torch291-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift AI (RHOAI)","package":"rhoai/odh-workbench-jupyter-pytorch-llmcompressor-cuda-py312-rhel9","cpe":"cpe:/a:redhat:openshift_ai","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat OpenShift Container Platform 4","package":"python-mistune","cpe":"cpe:/a:redhat:openshift:4","source":"cvelist"},{"ranges":[],"vendor":"Red Hat","product":"Red Hat Satellite 6","package":"satellite/iop-advisor-engine-rhel9","cpe":"cpe:/a:redhat:satellite:6","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.3.0"}],"ecosystem":"PyPI","package":"mistune","purl":"pkg:pypi/mistune","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.3.0"}],"ecosystem":"PyPI","package":"mistune","purl":"pkg:pypi/mistune","source":"pysec"}],"references":[{"url":"https://github.com/lepture/mistune/security/advisories/GHSA-qcq2-496w-v96p","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://access.redhat.com/security/cve/CVE-2026-49851","tags":["vdb-entry","web","x-refsource-redhat"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://bugzilla.redhat.com/show_bug.cgi?id=2492304","tags":["issue-tracking","web","x-refsource-redhat"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://security.access.redhat.com/data/csaf/v2/vex/2026/cve-2026-49851.json","tags":["web","x-sadp-csaf-vex"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://access.redhat.com/errata/RHSA-2026:60520","tags":["vendor-advisory","x-refsource-redhat"],"sources":["cvelist","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-49851","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/lepture/mistune","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/mistune","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-qcq2-496w-v96p","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2026-06-25T19:55:32.245Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-49851","url":"https://www.cve.org/CVERecord?id=CVE-2026-49851","licence":"CVE Terms of Use","modified":"2026-08-28T12:04:23.106Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-qcq2-496w-v96p","url":"https://github.com/advisories/GHSA-qcq2-496w-v96p","licence":"CC-BY-4.0","modified":"2026-09-10T03:51:11.807Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-49851","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-49851","licence":"Public domain","modified":"2026-10-25T22:10:00.150Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2652","url":"https://osv.dev/vulnerability/PYSEC-2026-2652","licence":"CC-BY-4.0","modified":"2026-07-13T16:31:51.196Z"}],"updatedAt":"2026-11-25T22:59:25.715Z","epss":{"score":0.0052,"percentile":0.45679,"date":"2026-12-01T12:00:22.000Z"}}