trentm / trentm/python-markdown2
[shadow] safe_mode bypassed by links
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.8k
- Forks
- 459
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 4
Description
_This is a _shadow issue* for Issue 51 on Google Code (from which this project was moved).
Added 2011-01-19T00:10:59.000Z by he...@precheur.org.
Labels: Type-Defect, Priority-Medium.
Please make updates to the bug there.*
Original description
>>> from markdown2 import Markdown
>>> m = Markdown(safe_mode='replace')
>>> m.convert("[evil][evil]\n[evil]: javascript:alert('evil');")
u'<p><a href="javascript:alert(\'evil\');">evil</a></p>\n'
>>> m.convert(';)')
u'<p><img src="javascript:void(0);" alt="img" /></p>\n'
As you can see, it's possible to execute javascript code via the the src & href attributes and maybe others. It would be good to have something like `is_safe_link` in Markdown's contructor:
def is_safe_link(value):
return value.startswith('http://') or value.startswith('#')
<b>What version of the product are you using? On what operating system?</b>
1.0.1.17
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the original Google Code issue linked in the shadow report and reproduce the two Markdown.convert examples using Markdown(safe_mode='replace'). Review the safe_mode handling and the proposed is_safe_link entry point; done means javascript URLs in link and image attributes are no longer accepted or emitted when safe mode is enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100