Skip to content

Potential Vulnerability in Cloned Code#74

Open
pr-hung wants to merge 1 commit into
antgroup:mainfrom
pr-hung:clone-vuln-1
Open

Potential Vulnerability in Cloned Code#74
pr-hung wants to merge 1 commit into
antgroup:mainfrom
pr-hung:clone-vuln-1

Conversation

@pr-hung
Copy link
Copy Markdown

@pr-hung pr-hung commented Mar 8, 2026

Summary

This PR fixes a potential security vulnerability in cloned code that appears to have missed an upstream security patch.

Details

  • Affected file: Android/AntFluid/markwon-html/src/main/java/io/noties/markwon/html/jsoup/parser/TokeniserState.java
  • Affected function: read
  • Upstream fix commit: jhy/jsoup@b86beca
  • Clone similarity score: 0.9999783635139465

What this PR does

  • Applies the upstream security fix logic to the cloned implementation in this repository.

Please review and merge this PR to ensure your repository is protected against this potential vulnerability.
Thank you for your time!

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, 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 jsoup library. The change ensures that a pending HTML tag is correctly emitted when the end-of-file is reached during tokenization, preventing potential parsing issues or unexpected behavior that could be exploited.

Highlights

  • Security Vulnerability Fix: Applied an upstream security patch to cloned jsoup parser code to address a potential vulnerability related to un-emitted pending tags at EOF.

🧠 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
  • Android/AntFluid/markwon-html/src/main/java/io/noties/markwon/html/jsoup/parser/TokeniserState.java
    • Applied an upstream security fix to correctly emit pending tags at the end of the input stream.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

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.

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

Successfully merging this pull request may close these issues.

1 participant