-
Notifications
You must be signed in to change notification settings - Fork 88
📚 DOCS: Clarify docs regarding security configuration #296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
chrisjsewell
merged 3 commits into
executablebooks:master
from
djramones:safety-config-docs
Jul 5, 2023
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,27 +2,36 @@ | |
|
|
||
| # Security | ||
|
|
||
| Many people don't understand that markdown format does not care much about security. | ||
| In many cases you have to pass output to sanitizers. | ||
| `markdown-it` provides 2 possible strategies to produce safe output: | ||
| Contrary to some expectations, the Markdown format, by default, is not particularly concerned about security. | ||
| This is fine for many use cases, for example when writing articles for one's own blog or composing technical documentation for a software package. | ||
|
|
||
| 1. Don't enable HTML. Extend markup features with [plugins](md/plugins). | ||
| We think it's the best choice and use it by default. | ||
| - That's ok for 99% of user needs. | ||
| - Output will be safe without sanitizer. | ||
| 2. Enable HTML and use external sanitizer package(s). | ||
| However, extra precautions are needed when parsing content from untrusted sources. | ||
| Generally, the output should be run through sanitizers to ensure safety and prevent vulnerabilities like cross-site scripting (XSS). | ||
| With `markdown-it`/`markdown-it-py`, there are two strategies for doing this: | ||
|
|
||
| Also by default `markdown-it` prohibits some kind of links, which could be used | ||
| for XSS: | ||
| 1. Enable HTML (as is needed for full CommonMark compliance), and then use external sanitizer package(s). | ||
| 2. Disable HTML, and then use [plugins](md/plugins) to selectively enable markup features. | ||
| This removes the need for further sanitizing. | ||
|
|
||
| ```{warning} | ||
| Unlike the original `markdown-it` JavaScript project, which uses the second, safe-by-default strategy, `markdown-it-py` enables less-secure (but more convenient) CommonMark-compliant settings by default. | ||
| This is not safe when using `markdown-it-py` in web applications that parse user-submitted content. | ||
| In such cases, [using the `js-default` preset](using.md) is strongly recommended. | ||
| For example: | ||
| ```python | ||
| from markdown_it import MarkdownIt | ||
| MarkdownIt("js-default").render("*user-submitted* text") | ||
| ``` | ||
|
|
||
| Note that even with the default configuration, `markdown-it-py` prohibits some kind of links which could be used for XSS: | ||
|
|
||
| - `javascript:`, `vbscript:` | ||
| - `file:` | ||
| - `data:`, except some images (gif/png/jpeg/webp). | ||
|
|
||
| So, by default `markdown-it` should be safe. We care about it. | ||
| - `data:` (except some images: gif/png/jpeg/webp) | ||
|
|
||
| If you find a security problem - contact us via <[email protected]>. | ||
| Such reports are fixed with top priority. | ||
| If you find a security problem, please report it to <[email protected]>. | ||
|
|
||
| ## Plugins | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.