Repository navigation
gh-160369: Reject buffered plaintext after IMAP STARTTLS - #160370
Conversation
| if typ == 'OK': | ||
| if any(self._readbuf): | ||
| raise self.abort('unexpected data after STARTTLS response') | ||
| self._readbuf = [] |
There was a problem hiding this comment.
We have to discard all cached state that could have been received before a STARTTLS command, so that includes untagged_responses, too. We should add a test for this case.
|
@JelleZijlstra @sethmlarson I was thinking it'd be good to get this into alpha 2 tomorrow if we can. Do you folks think that's doable? |
|
@savannahostrowski I think so, @JelleZijlstra I can take over submitting a fix for my comment? |
|
@JelleZijlstra Pushed a fix here for you to review: 55f6dda |
| ssl_context=ssl_context) | ||
| client.shutdown() | ||
|
|
||
| def test_starttls_discards_untagged_responses(self): |
There was a problem hiding this comment.
This test should be moved into NewIMAPTests, the SSL fixture already makes all commands run as TLS so we don't test what we need to test.
|
I pushed a commit to skip a test when SSL not available: #160370 (comment). MSan now passes. |
|
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.11. |
|
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
|
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.14. |
|
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13. |
|
Thanks @JelleZijlstra for the PR 🌮🎉.. I'm working now to backport this PR to: 3.15. |
|
Sorry, @JelleZijlstra, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
Sorry, @JelleZijlstra, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
Sorry, @JelleZijlstra, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
Sorry, @JelleZijlstra, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
Sorry, @JelleZijlstra, I could not cleanly backport this to Please backport manually with cherry_picker, see the devguide for more information. |
|
GH-161757 is a backport of this pull request to the 3.11 branch. |
|
GH-161758 is a backport of this pull request to the 3.12 branch. |
|
GH-161759 is a backport of this pull request to the 3.13 branch. |
|
GH-161760 is a backport of this pull request to the 3.14 branch. |
|
GH-161761 is a backport of this pull request to the 3.15 branch. |
…n#160370) Co-authored-by: Seth Michael Larson <seth@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Reject unexpected plaintext buffered after the STARTTLS response before upgrading the connection, so it cannot be interpreted as TLS-protected server responses. Add regression coverage and a Security NEWS entry.
Closes #160369.