Skip to content

Fix Proton Bridge STARTTLS before authentication - #277

Merged
huacnlee merged 2 commits into
huacnlee:mainfrom
klaudworks:fix/proton-bridge-starttls
Sep 25, 2026
Merged

huacnlee merged 2 commits into
huacnlee:mainfrom
klaudworks:fix/proton-bridge-starttls

Conversation

@klaudworks

Copy link
Copy Markdown
Collaborator

Fixes #225.

The native backend treated the Proton Bridge preset's loopback insecure setting as a reason to skip encryption. Bridge sends its greeting in the clear but requires STARTTLS before authentication; its self-signed certificate needs a local trust exception, not a plaintext session.

Separate transport selection from certificate verification. Loopback IMAP/SMTP uses STARTTLS, including the default Bridge ports and custom ports, except that 993/465 select implicit TLS. Remote services retain the existing standard STARTTLS-port/otherwise-implicit-TLS convention. insecure only relaxes certificate trust for the exact loopback allowlist, and localhost is dialed as 127.0.0.1. TLS handshake signatures are still verified, buffered plaintext is refused, and failed upgrades never fall back to plaintext authentication.

Existing plaintext test peers explicitly opt into a fixture-only setting compiled only in unit-test or integration-credential-test builds. Normal builds have no plaintext transport variant.

Verification

A fresh independent agent re-reviewed the revised diff and approved it with scoped security verdict PASS. The initial review's three findings were addressed: custom loopback ports no longer authenticate in plaintext, remote nonstandard ports retain implicit TLS, and policy tests exercise the production host/port/trust selection path with only the socket destination substituted.

Controlled IMAP and SMTP peers cover default Bridge ports, custom ports, standard STARTTLS ports, implicit TLS, strict verification, mixed local IMAP/remote SMTP settings, refusal, malformed TLS, and buffered plaintext. The reviewer ran 18 connection tests, all 57 IMAP tests, and a normal-build cargo check --locked --lib; all passed.

The new proton_custom_port_requires_starttls_before_credentials regression was transplanted onto unmodified upstream 3024f026b71b9b5041d2da46a198670257a5aaac, where it compiled and failed: the peer received a non-STARTTLS first command and never reported encrypted credentials. It passes with this fix and calls production connect() directly. Only synthetic localhost credentials were used for this regression.

make validate passed in this isolated branch's worktree with its own build directory: 607 Rust tests passed (11 ignored), all JavaScript and shell/Python suites passed, and the QML suites reported 980 + 6 + 64 passing tests with zero failures. QML lint, plugin manifest validation, cargo fmt --check, and git diff --check passed. The separate ordering fix is not included in this branch. No live SMTP message was sent.

Live Proton IMAP listing succeeded using the combined local build. A separate synthetic peer tested the installed normal release with testPlaintext: true: it still received STARTTLS, and its refusal received no credentials, confirming that the test-only plaintext transport is unavailable in the shipped build configuration.

Release Notes

  • Proton Mail Bridge connections now negotiate TLS before signing in, including Bridge installations using custom ports.

huacnlee
huacnlee previously approved these changes Sep 25, 2026

@huacnlee huacnlee left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Reviewed and approved; Security: PASS for the affected TLS and credential scope.

@huacnlee
huacnlee dismissed their stale review September 25, 2026 04:09

Retracting my premature approval: the required Published backend merge gate has no result for commit 415377a. Local validation passed; review will be finalized after the required check reports.

@klaudworks

Copy link
Copy Markdown
Collaborator Author

Fixed the Windows test failure in 112a24d. The STARTTLS matrix test shut down and dropped its TLS socket immediately after writing the synthetic credential, before the Python peer acknowledged receipt. This could abort the server-side TLS handshake on Windows (WinError 10053). The test now retains the socket until the peer reports its result and exits, and assertion failures identify the protocol/host/port/mode.

Verification: all 14 GitHub checks now pass, including Native credentials (windows-2022). Local connection tests (18), cargo fmt --check, git diff --check, and full make validate also pass.

Security verdict: PASS for this test-only change. The peer still requires the exact synthetic credential inside TLS for success, and all rejection cases retain their no-credentials assertions.

@huacnlee
huacnlee merged commit 162b057 into huacnlee:main Sep 25, 2026
14 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.

IMAP connect() never STARTTLS-upgrades Proton Bridge (1143/1025)

2 participants