question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Script injection vulnerability in search component

See original GitHub issue

Description

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:closed
  • Created 5 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
facelessusercommented, Nov 9, 2018

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.

1reaction
squidfunkcommented, Oct 26, 2018

Great, I’ll prepare a release.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found