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

ARTEMIS-3593: Be defensive when reading data from ActiveMQBuffer and allocating memory. #3862

Closed
wants to merge 5 commits into from

Conversation

vkolomeyko
Copy link
Contributor

Or else, an adversary may handcraft the packet causing OOM situation for a running a JVM.

…emory.

Or else, an adversary may handcraft the packet causing OOM situation for a running a JVM.
@jbonofre jbonofre self-requested a review November 19, 2021 12:05
@vkolomeyko
Copy link
Contributor Author

FAO: @andytaylor

@jbonofre jbonofre removed their request for review November 19, 2021 12:08
Copy link
Contributor

@franz1981 franz1981 left a comment

Choose a reason for hiding this comment

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

If exceed readable bytes

@franz1981
Copy link
Contributor

franz1981 commented Nov 19, 2021

Otherwise look good: it's a good change but I would like to see a test and probably worth creating an exception without stack trace to save denial of service due to stack trace bombing

@vkolomeyko
Copy link
Contributor Author

@franz1981 - CI tests have passed. Please let me know if my changes make sense.

@vkolomeyko
Copy link
Contributor Author

@franz1981, @clebertsuconic, @jbertram - I would like to follow-up on this PR.

Could you kindly review my work and let me know what you think?

My interest in this work is not leisured. We have experienced a security vulnerability in our product and I hope that the fix I am making will be included into the next version of Artemis Active MQ.

@clebertsuconic
Copy link
Contributor

@vkolomeyko what led you to do this? did you see this particularly happen anywhere?

this needs a JIRA...

and I would not use the Exception you created..I would just use ActiveMQAMQPIllegalStateException here.

this is a way exceptional case.. this should not happen at all.. if this happens it seems a bug to me, hence I'm asking why you did this PR.

@vkolomeyko vkolomeyko changed the title Be defensive when reading data from ActiveMQBuffer and allocating memory. ARTEMIS-3593: Be defensive when reading data from ActiveMQBuffer and allocating memory. Nov 30, 2021
@vkolomeyko
Copy link
Contributor Author

@clebertsuconic - thanks for your input.

I have raised a Jira: https://issues.apache.org/jira/browse/ARTEMIS-3593 explaining the reason for this change.

@clebertsuconic
Copy link
Contributor

@vkolomeyko Why you went the extra mile to remove the stack trace from the exception?

I'm raising a new PR based on this one with some refactoring... I will ask your review.

@vkolomeyko
Copy link
Contributor Author

@clebertsuconic

@vkolomeyko Why you went the extra mile to remove the stack trace from the exception?

as per @franz1981 point up above "...worth creating an exception without stack trace to save denial of service due to stack trace bombing"

@gtully
Copy link
Contributor

gtully commented Nov 30, 2021

It may make sense to whack the connection in this case, it is a protocol violation. 5.x would error out with an IOException and close the connection. It is sensible behaviour if the client is sending rogue or invalid data. A good citizen may even notice and stop.

@clebertsuconic
Copy link
Contributor

clebertsuconic commented Nov 30, 2021

I agree with Gary.. if you actually throw any RuntimeException on the decode that will kill the connection

@vkolomeyko let me handle this PR? I will do some tweaking to the PR, and I will set you as the author on the commit... (with a note of my collaboration)

@clebertsuconic
Copy link
Contributor

I am refactoring the safeRead into BytebufferUtil BTW. so we can reuse the method in other packets

@vkolomeyko
Copy link
Contributor Author

I am refactoring the safeRead into BytebufferUtil BTW. so we can reuse the method in other packets

@clebertsuconic - sure. Please feel free to add me as a reviewer as soon as you have PR ready.

@clebertsuconic
Copy link
Contributor

PR #3871 replaces this one

@clebertsuconic
Copy link
Contributor

@vkolomeyko if you could review #3871 please?

I am now closing this one.

@vkolomeyko vkolomeyko deleted the vkolomeyko/boundary-check branch December 21, 2021 09:10
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.

4 participants