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

Billion Laughs causes extension to consume all cpu and die #476

Closed
zkrising opened this issue May 18, 2021 · 6 comments · Fixed by eclipse/lemminx#1038
Closed

Billion Laughs causes extension to consume all cpu and die #476

zkrising opened this issue May 18, 2021 · 6 comments · Fixed by eclipse/lemminx#1038
Assignees
Labels
bug Something isn't working
Milestone

Comments

@zkrising
Copy link

I guess this is expected behaviour but I was running tests that involve throwing billion laughs at an xml parser and this extension - upon seeing billion laughs - halted vscode and consumed as much cpu as possible.

Is there a way around this without disabling the extension/getting the extension to ignore the file? My vscode just slowly crashes if I even see the file.

@angelozerr
Copy link
Contributor

Is it possible to share your XML, DTD, XSD, files which causes problem and share your tests you are executing in order to we can reproduce your problem. Thanks.

@zkrising
Copy link
Author

No worries -

<?xml version="1.0"?>
<!DOCTYPE lolz [
    <!ENTITY lol "lol">
    <!ELEMENT lolz (#PCDATA)>
    <!ENTITY lol1 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
    <!ENTITY lol2 "&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;&lol1;">
    <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
    <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
    <!ENTITY lol5 "&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;&lol4;">
    <!ENTITY lol6 "&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;&lol5;">
    <!ENTITY lol7 "&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;&lol6;">
    <!ENTITY lol8 "&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;&lol7;">
    <!ENTITY lol9 "&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;&lol8;">
]>
<lolz>&lol9;</lolz>

This is the billion laughs attack as per wikipedia - should crash your pc if its noticed by vscode with this extension enabled.

@fbricon
Copy link
Collaborator

fbricon commented May 18, 2021

@angelozerr @evidolob YAML is similarly affected, see kubernetes/kubernetes#83253 and one mitigation strategy (limiting recursive entities): go-yaml/yaml@bb4e33b

@fbricon fbricon added the bug Something isn't working label May 18, 2021
@angelozerr
Copy link
Contributor

This is the billion laughs attack as per wikipedia - should crash your pc if its noticed by vscode with this extension enabled.

Thanks for your sample!

It seems that you have enabled the resolve of XML entities https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md#resolve-external-entities If you disable it, you should ignore the problem, no?

YAML is similarly affected, see kubernetes/kubernetes#83253 and one mitigation strategy (limiting recursive entities)

resolve of XML entities is managed by Xerces,I don't know ifit's possible to set a limit for recursive entities.

angelozerr added a commit to angelozerr/lemminx that referenced this issue May 18, 2021
angelozerr added a commit to angelozerr/lemminx that referenced this issue May 18, 2021
@angelozerr angelozerr self-assigned this May 18, 2021
@angelozerr angelozerr added this to the 0.16.1 milestone May 18, 2021
angelozerr added a commit to angelozerr/lemminx that referenced this issue May 18, 2021
@zkrising
Copy link
Author

This is the billion laughs attack as per wikipedia - should crash your pc if its noticed by vscode with this extension enabled.

Thanks for your sample!

It seems that you have enabled the resolve of XML entities https://github.com/redhat-developer/vscode-xml/blob/master/docs/Validation.md#resolve-external-entities If you disable it, you should ignore the problem, no?

YAML is similarly affected, see kubernetes/kubernetes#83253 and one mitigation strategy (limiting recursive entities)

resolve of XML entities is managed by Xerces,I don't know ifit's possible to set a limit for recursive entities.

Hi, Thanks for the quick response! Changing that setting does fix the problem, but does mean you can't take advantage of doctype declarations.

I looked at the commit that fixes this, looks like a good way to mitigate this problem. Thanks again for fixing this so quickly!

angelozerr added a commit to angelozerr/lemminx that referenced this issue May 18, 2021
@angelozerr
Copy link
Contributor

angelozerr commented May 18, 2021

@zkldi my current PR eclipse/lemminx#1038 should fix your issue and you will benefit with doctype declaration again.

You should see now an error:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants