Skip to content

Prevent authentication after a failed STARTTLS handshake - #193

Merged
stevebauman merged 1 commit into
masterfrom
fix/starttls-handshake
Oct 24, 2026
Merged

stevebauman merged 1 commit into
masterfrom
fix/starttls-handshake

Conversation

@stevebauman

Copy link
Copy Markdown
Member

When a server accepts STARTTLS but the TLS handshake fails, ImapConnection continues to authenticate over the unencrypted connection. This can send a password or OAuth token in plain text.

This checks that encryption was established before continuing. If it wasn't, we disconnect and throw ImapConnectionFailedException.

I reproduced the issue with a local TCP server and confirmed that the fix prevents credentials from being sent. All 386 unit tests pass.

Closes #192.

@stevebauman
stevebauman merged commit 54e5806 into master Oct 24, 2026
13 checks passed
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.

startTls() ignores the result of stream_socket_enable_crypto(), so LOGIN can go out in plain text

1 participant