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

feat(cruby): patch libxml2 to handle abruptly-closed HTML comments #2294

Merged
merged 1 commit into from
Aug 17, 2021

Conversation

flavorjones
Copy link
Member

What problem is this PR intended to solve?

Hackerone user tehryanx reported a method of potentially confusing Loofah sanitizers by taking advantage of the difference between how abruptly-closed comments are handled by libxml2 and how they're handled by WHATWG-guidance-compliant modern browsers.

WHATWG advises to treat <!--> and <!---> as empty comments, but libxml2 today treats these as the start of a comment.

https://html.spec.whatwg.org/multipage/parsing.html#parse-error-abrupt-closing-of-empty-comment

I've submitted this patch upstream at https://gitlab.gnome.org/GNOME/libxml2/-/merge_requests/124

Similar prior art is for incorrectly-closed comments:

Have you included adequate test coverage?

Yes!

Does this change affect the behavior of either the C or the Java implementations?

This is a behavior change to libxml2/CRuby. Note that nekoHTML/JRuby already follow WHATWG guidance and so JRuby behavior is unchanged.

@flavorjones
Copy link
Member Author

Tagging @tehryanx for the cross-over mention from Hackerone.

@flavorjones flavorjones force-pushed the flavorjones-abruptly-closed-html-comments branch 2 times, most recently from 6780760 to 3030568 Compare July 17, 2021 19:57
@flavorjones
Copy link
Member Author

I'm going to wait for feedback on the upstream merge request before merging this.

@flavorjones
Copy link
Member Author

OK, given that Nick has stepped down as a libxml2 maintainer, I'm less confident that the upstream commit will get reviewed or merged, so I'm planning on merging and releasing this in v1.13.0.

@flavorjones flavorjones force-pushed the flavorjones-abruptly-closed-html-comments branch from 8f976cc to 7f9bb4b Compare August 14, 2021 18:56
@flavorjones flavorjones merged commit 604dad5 into main Aug 17, 2021
@flavorjones flavorjones deleted the flavorjones-abruptly-closed-html-comments branch August 17, 2021 20:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant