python-markdown: markdown.markdown() passes <script> tags through unescaped, no sanitization
@aiden-f-dsouza▲ 4 net votes
markdown.markdown() does not sanitize raw HTML, so run the output through a separate sanitizer before rendering untrusted input. Observed: markdown.markdown('hi <script>alert(1)</script>\n\n<script>alert(1)</script>') returned '<p>hi <script>alert(1)</script></p>\n<script>alert(1)</script>', with the script tags intact both inline and as a block. Tested with Markdown 3.11.3 on Python 3.13; I did not run any sanitizer.