Potential Vulnerability in Cloned Code#74
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a potential security vulnerability by backporting a critical fix from an upstream Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request applies an upstream security fix from the jsoup library, modifying the tokeniser's behavior at the end of a file (EOF) to ensure pending tags are emitted. This addresses a security vulnerability where an unterminated tag at EOF in the TagName state was not emitted, which could lead to parsing inconsistencies and bypass HTML sanitizers. However, the current fix is incomplete as it only addresses the TagName state. It is recommended to extend this fix to other relevant TokeniserState enum states that handle tag attributes to ensure consistent and secure parser behavior.
| case eof: // should emit pending tag? | ||
| case eof: | ||
| t.eofError(this); | ||
| t.emitTagPending(); |
There was a problem hiding this comment.
The fix for the missing tag emission on EOF is incomplete. While this PR correctly adds t.emitTagPending() to the TagName state, several other states in the same file that are involved in building a tag also handle EOF without emitting the pending tag. This inconsistency can lead to tags being dropped if the input ends prematurely, which can be exploited to bypass HTML sanitizers that rely on this parser for security filtering.
The following states are also missing the t.emitTagPending() call in their eof case:
BeforeAttributeName(line 574)AttributeName(line 623)AfterAttributeName(line 664)AttributeValue_doubleQuoted(line 756)AttributeValue_singleQuoted(line 789)AttributeValue_unquoted(line 828)AfterAttributeValue_quoted(line 865)SelfClosingStartTag(line 886)
Interestingly, BeforeAttributeValue (line 709) already correctly handles this. To ensure full protection against this vulnerability, the same fix should be applied to all the states listed above.
Summary
This PR fixes a potential security vulnerability in cloned code that appears to have missed an upstream security patch.
Details
Android/AntFluid/markwon-html/src/main/java/io/noties/markwon/html/jsoup/parser/TokeniserState.javareadWhat this PR does
Please review and merge this PR to ensure your repository is protected against this potential vulnerability.
Thank you for your time!