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

[UNDERTOW-2451] fix the information leakage issues #1668

Closed
wants to merge 2 commits into from

Conversation

BFionaccept
Copy link

@BFionaccept BFionaccept commented Sep 25, 2024

Issue: https://issues.redhat.com/browse/UNDERTOW-2451
fix the information leakage issues

AJP Parser: Do not share the decodeBuffer StringBuilder instance between responses
fix the message leak issue in HPACK decoder
@baranowb baranowb requested review from fl4via and baranowb September 30, 2024 08:16
@baranowb baranowb added bug fix Contains bug fix(es) under verification Currently being verified (running tests, reviewing) before posting a review to contributor waiting CI check Ready to be merged but waiting for CI check waiting peer review PRs that edit core classes might require an extra review labels Sep 30, 2024
@baranowb
Copy link
Contributor

@BFionaccept could you please update commit messages? Add [UNDERTOW-2451] as prefix and reword first message, since that CVE is very specific and does not cover class you make change to.

@@ -260,12 +258,12 @@ private String readHpackString(ByteBuffer buffer) throws HpackException {
}

private String readHuffmanString(int length, ByteBuffer buffer) throws HpackException {
StringBuilder stringBuilder = new StringBuilder(length);
Copy link
Contributor

Choose a reason for hiding this comment

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

final ?

Copy link
Author

Choose a reason for hiding this comment

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

In this fix, I referenced the patch for a similar vulnerability (CVE-2020-17527) in the corresponding functional module of Tomcat, as shown in this commit: apache/tomcat@d56293f#diff-98723542790b05d2e3c2dadeef7c632e641e3118b3b809660e9b1ef41686cfe0R226. I removed the final from the StringBuilder stringBuilder declaration, enhancing code flexibility and allowing for future reassignment if needed.

Certainly, I think it is also acceptable to retain the final modifier.

Copy link
Author

Choose a reason for hiding this comment

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

Oh, I’m sorry, I accidentally deleted a previous conversation.

@baranowb baranowb changed the title fix the information leakage issues [UNDERTOW-2451] fix the information leakage issues Sep 30, 2024
@BFionaccept
Copy link
Author

@baranowb Hi baranowb, I'm unable to view this issue: https://issues.redhat.com/browse/UNDERTOW-2451. Could you please help add me to it?

@fl4via
Copy link
Member

fl4via commented Oct 4, 2024

@baranowb Hi baranowb, I'm unable to view this issue: https://issues.redhat.com/browse/UNDERTOW-2451. Could you please help add me to it?

@BFionaccept I have opened the Jira. You can try again.

Copy link
Member

@fl4via fl4via left a comment

Choose a reason for hiding this comment

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

I am rejecting this PR because there are no leakages in the edited classes.

/**
* The current string being read
*/
public StringBuilder currentString;
Copy link
Member

Choose a reason for hiding this comment

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

You can't remove currentString here. The parser is invoked multiple times as bytes are made available and, when the last byte is read, it wil need the whole currentString to form a parsed result, it will neeed information from previous parse invocations. Otherwise, you risk losing bytes. It all depends on how many bytes the parser has received on every invocation.

@@ -73,8 +73,6 @@ public class HpackDecoder {

private boolean first = true;

private final StringBuilder stringBuilder = new StringBuilder();
Copy link
Member

Choose a reason for hiding this comment

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

There is no leakage in this class either. In this case, we are reusing the same builder across multiple decode invocations, but we are clearing the buffer right after we use it on every call. It just prevents us from having to create a new builder everytime we are invoked, which is a good thing.

Copy link
Author

Choose a reason for hiding this comment

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

The root cause for this leak is very similar to the vulnerability CVE-2020-17527 in Tomcat. I added additional details at https://issues.redhat.com/browse/UNDERTOW-2451.

@fl4via fl4via added invalid Fixes not existing bug or breaks existing code or behaviour and removed bug fix Contains bug fix(es) under verification Currently being verified (running tests, reviewing) before posting a review to contributor waiting CI check Ready to be merged but waiting for CI check waiting peer review PRs that edit core classes might require an extra review labels Oct 4, 2024
@carnil
Copy link

carnil commented Dec 13, 2024

My understanding from https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2024-4109 is that this issue has assigned CVE-2024-4109 ?

@romabaz
Copy link

romabaz commented Dec 26, 2024

@fl4via , sorry for pinging you here, but I did not find any relevant thread to ask about CVE-2024-4109
Are there any plans to address this anytime soon?
Thank you!

@miklish
Copy link

miklish commented Jan 6, 2025

I had the same questions as @carnil and @romabaz

if this is the fix for CVE-2024-4109 (or, based on exchange between @fl4via and @BFionaccept -- it seems that this CVE may have been created in error?), the undertow team may be interested to know that -- as of today -- this is still listed as a vulnerability in many CVE databases and CVE scanning tools for both undertow 2.1.37 and 2.1.38

e.g.:

Both versions still have 2024-4109 listed as direct vulnerabilities

@fl4via
Copy link
Member

fl4via commented Jan 15, 2025

Hi! @carnil @romabaz @miklish @BFionaccept The fix for CVE-2024-4109 is in #1715 . We will be doing a release of that within the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Fixes not existing bug or breaks existing code or behaviour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants