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

Terminate connection when custom verification fails (SecureTransport) #1977

Merged
merged 11 commits into from Nov 1, 2020

Conversation

hodbn
Copy link
Member

@hodbn hodbn commented Sep 22, 2020

Closes #1976.
It was fixed by manually sending TLS alerts and then terminating the connection.

I've added a helper to send TLS alerts since I couldn't find any supported way of sending a TLS alert in SecureTransport.

@hodbn hodbn added the TLS label Sep 22, 2020
@codecov
Copy link

codecov bot commented Sep 22, 2020

Codecov Report

Merging #1977 into master will increase coverage by 0.04%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #1977      +/-   ##
===========================================
+ Coverage   99.95%   100.00%   +0.04%     
===========================================
  Files          25        25              
  Lines        2294      2294              
===========================================
+ Hits         2293      2294       +1     
+ Misses          1         0       -1     
Impacted Files Coverage Δ
src/urllib3/contrib/_appengine_environ.py 100.00% <0.00%> (+10.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3308d65...8f9b974. Read the comment docs.

@hodbn hodbn marked this pull request as ready for review September 29, 2020 16:28
Copy link
Member

@sethmlarson sethmlarson left a comment

Choose a reason for hiding this comment

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

Thanks for this! I'm sad that we so much micromanaging of SecureTransport sockets here but 🤷

Definitely need to check the TLS alert record getting sent in Wireshark somehow.

src/urllib3/contrib/_securetransport/record.py Outdated Show resolved Hide resolved
src/urllib3/contrib/securetransport.py Show resolved Hide resolved
test/with_dummyserver/test_https.py Outdated Show resolved Hide resolved
@pquentin
Copy link
Member

pquentin commented Oct 1, 2020

@hodbn I merged master into your branch to fix the conflicts caused by the isort pull request.

@hodbn
Copy link
Member Author

hodbn commented Oct 4, 2020

Definitely need to check the TLS alert record getting sent in Wireshark somehow.

Now asserting that the SSL server error references the alert:

assert "alert unknown ca" in str(e)

@hodbn hodbn requested a review from sethmlarson October 4, 2020 12:05
Copy link
Member

@pquentin pquentin left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! I ran the new test multiple thousands of times and it does not seem to be flaky on my machine.

def _build_tls_unknown_ca_alert(version):
"""
Builds a TLS alert record for an unknown CA.
"""
Copy link
Member

Choose a reason for hiding this comment

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

Is there some useful documentation or even StackOverflow link for this?

@pquentin pquentin merged commit 5eb604f into urllib3:master Nov 1, 2020
@sethmlarson
Copy link
Member

@pquentin Thanks for reviewing and merging this!! 🥳

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.

SecureTransport does not close unverified connections correctly
3 participants