Script injection vulnerability in search component
See original GitHub issueDescription
If any of your markdown documents contain script injection examples such as the following:
<style onload='alert("You executed this bit of JS");'></style>
You’ll trigger a script injection attack on yourself when the document shows up in the search result.
Expected behavior
I would expect mkdocs-material to not inject user-generated input straight into the DOM. This is happening due to the use of {{ __html }} in the search result component.
Actual behavior
It triggers an injection attack.
Steps to reproduce the bug
You can download a minimal working example here or follow the guide below
Put the following anywhere in a document and write a search query that finds the document
```
<style onload='alert("You executed this bit of JS");'></style>
```
or
`<style onload='alert("You executed this bit of JS");'></style>`
Package versions
I’m using verison 3.0.5 of the docker image
Project configuration
site_name: 'Example of injection'
theme:
name: 'material'
nav:
- Home: index.md
System information
- OS: macOS
- Browser: Chrome
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (10 by maintainers)
Top Results From Across the Web
Cross Site Scripting (XSS) - OWASP Foundation
Cross-Site Scripting (XSS) attacks are a type of injection, in which malicious scripts are injected into otherwise benign and trusted websites. XSS attacks ......
Read more >HTML Injection Tutorial: Types & Prevention with Examples
The essence of this type of injection attack is injecting HTML code through the vulnerable parts of the website. The Malicious user sends ......
Read more >How to Find XSS Vulnerability - Comparitech
In this guide, we explain how to find Cross-site scripting (XSS) vulnerability in web applications, including what you can do to prevent it....
Read more >【Javascript Injection】Definition, Examples, and Prevention
An injection vulnerability allows a malicious actor to inject harmful code into a system through another application.
Read more >What is Cross-site Scripting and How Can You Fix it? - Acunetix
To run malicious JavaScript code in a victim's browser, an attacker must first find a way to inject malicious code (payload) into a...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Are you talking about this bug https://github.com/Python-Markdown/markdown/issues/746?
The bug has been fixed, but we are still waiting for an official release. It snuck in with the newest 3.0 release, but it will be fixed in the next release.
Great, I’ll prepare a release.