Skip to content
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

[Question] Security risk with max-nesting #1

Open
BboyKeen opened this issue Nov 4, 2016 · 1 comment
Open

[Question] Security risk with max-nesting #1

BboyKeen opened this issue Nov 4, 2016 · 1 comment

Comments

@BboyKeen
Copy link

BboyKeen commented Nov 4, 2016

Hi @jmendeth

I'm willing to use this library with Hoedown to sanitize input coming from users. After looking at the documentation on the max-nesting level, I was wondering if there is any security risk with the max-nesting option ?
If the processor stops parsing the document once it has reached the maximum nesting level, I guess the remaining characters won't be escaped, right ?

If this is the case, what are my options to make sure the remaining characters will be escaped anyway ? I'm thinking about using the escape option of Hoedown but I guess using this option will result in doing the same job in a different way.

@mildsunrise
Copy link
Member

Tags nested beyond max_nesting - 1 levels are of course escaped. Not doing so would be a security risk, as you noted. For instance if max_nesting = 4 and the callback accepts all tags, then the following:

<b> <b> <b> <b> <b> foo </b> </b> </b> </b> </b>

sanitizes to

<b> <b> <b> &lt;b&gt; &lt;b&gt; foo </b> </b> </b> &lt;/b&gt; &lt;/b&gt;

The max_nesting option is only there to put a limit to the amount of memory that the parser is willing to allocate in order to parse input. You should just set it high enough that the limit will never be hit for any sensible input.

To be clear: whenever the documentation states that something isn't parsed (such as tags beyond max_nesting), that implies it'll be escaped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants