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

SslHandler LocalChannel read/unwrap reentry fix #11156

Merged
merged 4 commits into from
Apr 16, 2021

Conversation

Scottmitch
Copy link
Member

Motivation:
SslHandler invokes channel.read() during the handshake process. For some
channel implementations (e.g. LocalChannel) this may result in re-entry
conditions into unwrap. Unwrap currently defers updating the input
buffer indexes until the unwrap method returns to avoid intermediate
updates if not necessary, but this may result in unwrapping the same
contents multiple times which leads to handshake failures [1][2].

[1] ssl3_get_record:decryption failed or bad record mac
[2] ssl3_read_bytes:sslv3 alert bad record mac

Modifications:

  • SslHandler#unwrap updates buffer indexes on each iteration so that if
    reentry scenario happens the correct indexes will be visible.

Result:
Fixes #11146

@rkapsi
Copy link
Member

rkapsi commented Apr 14, 2021

@Scottmitch tested and fixes #11146. All our Unit Tests pass.

@Scottmitch
Copy link
Member Author

the state consolidation was moved into #11160, and this PR has been rebased

@Scottmitch Scottmitch marked this pull request as ready for review April 14, 2021 21:10
Motivation:
SslHandler invokes channel.read() during the handshake process. For some
channel implementations (e.g. LocalChannel) this may result in re-entry
conditions into unwrap. Unwrap currently defers updating the input
buffer indexes until the unwrap method returns to avoid intermediate
updates if not necessary, but this may result in unwrapping the same
contents multiple times which leads to handshake failures [1][2].

[1] ssl3_get_record:decryption failed or bad record mac
[2] ssl3_read_bytes:sslv3 alert bad record mac

Modifications:
- SslHandler#unwrap updates buffer indexes on each iteration so that if
  reentry scenario happens the correct indexes will be visible.

Result:
Fixes netty#11146
@Scottmitch
Copy link
Member Author

Scottmitch commented Apr 15, 2021

@rkapsi - would you mind re-checking this PR resolves your issues? it has been rebased and there are some additional changes made since your first verified.

@rkapsi
Copy link
Member

rkapsi commented Apr 16, 2021

@Scottmitch re-tested; still works and all tests pass.

@Scottmitch Scottmitch merged commit 0ef2f05 into netty:4.1 Apr 16, 2021
@Scottmitch Scottmitch deleted the ssl_handler_read_reentry branch April 16, 2021 15:21
Scottmitch added a commit that referenced this pull request Apr 16, 2021
Motivation:
SslHandler invokes channel.read() during the handshake process. For some
channel implementations (e.g. LocalChannel) this may result in re-entry
conditions into unwrap. Unwrap currently defers updating the input
buffer indexes until the unwrap method returns to avoid intermediate
updates if not necessary, but this may result in unwrapping the same
contents multiple times which leads to handshake failures [1][2].

[1] ssl3_get_record:decryption failed or bad record mac
[2] ssl3_read_bytes:sslv3 alert bad record mac

Modifications:
- SslHandler#unwrap updates buffer indexes on each iteration so that if
  reentry scenario happens the correct indexes will be visible.

Result:
Fixes #11146
@Scottmitch
Copy link
Member Author

master (59867fa)

normanmaurer added a commit that referenced this pull request Apr 29, 2021
…ion for a handshake success (#11203)

Motivation:

#11210 fixed a regression caused by #11156. This change adds a unit test for it.

Modifications:

- Add test

Result:

Verify fix in #11210 

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
raidyue pushed a commit to raidyue/netty that referenced this pull request Jul 8, 2022
Motivation:
SslHandler invokes channel.read() during the handshake process. For some
channel implementations (e.g. LocalChannel) this may result in re-entry
conditions into unwrap. Unwrap currently defers updating the input
buffer indexes until the unwrap method returns to avoid intermediate
updates if not necessary, but this may result in unwrapping the same
contents multiple times which leads to handshake failures [1][2].

[1] ssl3_get_record:decryption failed or bad record mac
[2] ssl3_read_bytes:sslv3 alert bad record mac

Modifications:
- SslHandler#unwrap updates buffer indexes on each iteration so that if
  reentry scenario happens the correct indexes will be visible.

Result:
Fixes netty#11146
raidyue pushed a commit to raidyue/netty that referenced this pull request Jul 8, 2022
…ion for a handshake success (netty#11203)

Motivation:

netty#11210 fixed a regression caused by netty#11156. This change adds a unit test for it.

Modifications:

- Add test

Result:

Verify fix in netty#11210 

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
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.

TLS sslv3 alert bad record mac error from 4.1.61 to 4.1.63 (inclusive)
3 participants