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

Reduce the number of runtime exceptions (SecurityModuleException) #4508

Merged
merged 8 commits into from
Oct 19, 2022

Conversation

ahamlat
Copy link
Contributor

@ahamlat ahamlat commented Oct 10, 2022

Signed-off-by: Ameziane H [email protected]

PR description

During handshake, flip the encrypted message decryption by starting with the new format (EIP-8), and if there is an exception, try the old format. This will reduce the number of exceptions and unnecessary executions.

I noticed by adding some debug logs that on 4400 calls to ECIESHandshaker.handleMessage, there're only 7 cases where the encrypted message has the old format.
image

By changing the order of execution, starting by decoding the new format (eip8) and without resetting the logs, we can notice there're no more exceptions

image

There is one case I'm not sure about it : if (buf.writerIndex() < size), do we need to try to decode with the old format or we should just throw HandshakeException. With the current PR, HandshakeException will be caught and the old format decryption will be executed.

Fixed Issue(s)

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if
    updates are required.

Changelog

…ith the new format (EIP-8), and if there is an exception, try the old format. This will reduce the number of exceptions and unnecessary executions.

Signed-off-by: Ameziane H <[email protected]>
@ahamlat ahamlat marked this pull request as ready for review October 10, 2022 13:19
Copy link
Contributor

@fab-10 fab-10 left a comment

Choose a reason for hiding this comment

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

LGTM, just a suggestion on the changelog

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Contributor

@garyschulte garyschulte left a comment

Choose a reason for hiding this comment

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

LGTM.

Seems like such a low percentage of handshakes are using the pre-EIP-8 format, that it doesn't really matter much whether we try to decode with the old format if the buffer length is wrong.

@ahamlat ahamlat merged commit 90e54c0 into hyperledger:main Oct 19, 2022
fab-10 pushed a commit to fab-10/besu that referenced this pull request Oct 19, 2022
…perledger#4508)

* During handshake, flip the encrypted message decryption by starting with the new format (EIP-8), and if there is an exception, try the old format. This will reduce the number of exceptions and unnecessary executions.

Signed-off-by: Ameziane H <[email protected]>

* update CHANGELOG.md to give more context on this PR.

Signed-off-by: Ameziane H <[email protected]>

* update CHANGELOG.md to give more context on this PR.

Signed-off-by: Ameziane H <[email protected]>

* Delete some debug code committed by error

Signed-off-by: Ameziane H <[email protected]>

Signed-off-by: Ameziane H <[email protected]>
Signed-off-by: ahamlat <[email protected]>
fab-10 added a commit that referenced this pull request Oct 19, 2022
* The block variable was keeping too much memory while waiting for future to finish (#4489)

Signed-off-by: Jiri Peinlich <[email protected]>

* Reduce the number of runtime exceptions (SecurityModuleException) (#4508)

* During handshake, flip the encrypted message decryption by starting with the new format (EIP-8), and if there is an exception, try the old format. This will reduce the number of exceptions and unnecessary executions.

Signed-off-by: Ameziane H <[email protected]>

* update CHANGELOG.md to give more context on this PR.

Signed-off-by: Ameziane H <[email protected]>

* update CHANGELOG.md to give more context on this PR.

Signed-off-by: Ameziane H <[email protected]>

* Delete some debug code committed by error

Signed-off-by: Ameziane H <[email protected]>

Signed-off-by: Ameziane H <[email protected]>
Signed-off-by: ahamlat <[email protected]>

* Upgrade Apache Commons Text to 1.10.0 (#4542)

* upgraded Apache Commons Text to fix CVE-2022-42889

Signed-off-by: Daniel Lehrner <[email protected]>

* add changelog

Signed-off-by: garyschulte <[email protected]>

Signed-off-by: Daniel Lehrner <[email protected]>
Signed-off-by: garyschulte <[email protected]>
Co-authored-by: garyschulte <[email protected]>

* Tune EthScheduler thread pools to avoid to recreate too many threads (#4529)

Signed-off-by: Fabio Di Fabio <[email protected]>

* Make GraphQL scalar parsing compatible with variables (#4522)

Our current GraphQL scalar parsing interacts poorly with the variables
support in the library.  Revise the parsing so it works correctly.

Signed-off-by: Danno Ferrin <[email protected]>

* don't add to bad blocks manager on StorageException (#4524)

* don't add to bad blocks manager on StorageException
* add bugfix to changelog
* adds test coverage

Signed-off-by: Justin Florentine <[email protected]>

* CHANGELOG for 22.7.7

Signed-off-by: Fabio Di Fabio <[email protected]>

* Release 22.7.7

Signed-off-by: Fabio Di Fabio <[email protected]>

Signed-off-by: Jiri Peinlich <[email protected]>
Signed-off-by: Ameziane H <[email protected]>
Signed-off-by: ahamlat <[email protected]>
Signed-off-by: Daniel Lehrner <[email protected]>
Signed-off-by: garyschulte <[email protected]>
Signed-off-by: Fabio Di Fabio <[email protected]>
Signed-off-by: Danno Ferrin <[email protected]>
Signed-off-by: Justin Florentine <[email protected]>
Co-authored-by: Jiri Peinlich <[email protected]>
Co-authored-by: ahamlat <[email protected]>
Co-authored-by: Daniel Lehrner <[email protected]>
Co-authored-by: garyschulte <[email protected]>
Co-authored-by: Danno Ferrin <[email protected]>
Co-authored-by: Justin Florentine <[email protected]>
macfarla pushed a commit to jflo/besu that referenced this pull request Jan 10, 2023
…perledger#4508)

* During handshake, flip the encrypted message decryption by starting with the new format (EIP-8), and if there is an exception, try the old format. This will reduce the number of exceptions and unnecessary executions.

Signed-off-by: Ameziane H <[email protected]>

* update CHANGELOG.md to give more context on this PR.

Signed-off-by: Ameziane H <[email protected]>

* update CHANGELOG.md to give more context on this PR.

Signed-off-by: Ameziane H <[email protected]>

* Delete some debug code committed by error

Signed-off-by: Ameziane H <[email protected]>

Signed-off-by: Ameziane H <[email protected]>
Signed-off-by: ahamlat <[email protected]>
Signed-off-by: Sally MacFarlane <[email protected]>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
…perledger#4508)

* During handshake, flip the encrypted message decryption by starting with the new format (EIP-8), and if there is an exception, try the old format. This will reduce the number of exceptions and unnecessary executions.

Signed-off-by: Ameziane H <[email protected]>

* update CHANGELOG.md to give more context on this PR.

Signed-off-by: Ameziane H <[email protected]>

* update CHANGELOG.md to give more context on this PR.

Signed-off-by: Ameziane H <[email protected]>

* Delete some debug code committed by error

Signed-off-by: Ameziane H <[email protected]>

Signed-off-by: Ameziane H <[email protected]>
Signed-off-by: ahamlat <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants