fix: harden Haraka TLS (renegotiation DoS + untrusted cert chain)#8
Draft
taobojlen wants to merge 1 commit into
Draft
fix: harden Haraka TLS (renegotiation DoS + untrusted cert chain)#8taobojlen wants to merge 1 commit into
taobojlen wants to merge 1 commit into
Conversation
Two scanner findings on app.shroud.email:25, both in the SMTP (Haraka)
TLS path:
1. Client-initiated TLS renegotiation allowed (DoS). Haraka tls_socket
passes secureOptions from tls.ini [main] straight to
tls.createSecureContext. Set secureOptions=1073741824
(crypto.constants.SSL_OP_NO_RENEGOTIATION) to refuse renegotiation,
closing the CPU-exhaustion vector.
2. Untrusted certificate presented on port 25. The daily cron bundle
appended a hardcoded, now-expired intermediate (lets-encrypt-r4.pem,
expired 2025-09-15) to Caddy fullchain, producing a broken chain.
Caddy {domain}.crt is already leaf + intermediates; copy it verbatim
and drop the stale intermediate. Also run the bundle at container
startup (not only daily) so a fresh pem_certs volume is populated
before Haraka first STARTTLS, and no-op gracefully when Caddy has not
issued yet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two security scanner findings on
app.shroud.email:25(the Haraka SMTP TLS path):1. Client-initiated TLS renegotiation (DoS)
haraka/haraka_config/config/tls.ini— setsecureOptions=1073741824(=crypto.constants.SSL_OP_NO_RENEGOTIATION). Haraka'stls_socket.jspassessecureOptionsfromtls.ini [main]straight totls.createSecureContext/TLSSocket, so this refuses renegotiation on every STARTTLS upgrade (ports 25 and 465), closing the CPU-exhaustion vector where an attacker forces repeated handshakes.2. Untrusted certificate on port 25
cron/bundle_certs.sh+cron/Dockerfile— the daily bundle appended a hardcoded, now-expired Let's Encrypt intermediate (lets-encrypt-r4.pem, expired 2025-09-15) to Caddy's fullchain, producingleaf + correct_intermediate + expired_R4→ broken chain → untrusted. Caddy's{domain}.crtis already the full chain (leaf + intermediates); copy it verbatim and delete the stale intermediate. Also:pem_certsvolume is populated before Haraka's first STARTTLS.exit 0) when Caddy hasn't issued yet, so a cold boot where ACME is still running doesn't crash crond.Test plan
docker compose build cron && docker compose up -d --build cron haraka— verify Haraka starts and presents a valid chain on port 25.openssl s_client -starttls smtp -connect app.shroud.email:25 -showcerts </dev/null | openssl x509 -noout -issuer -subject— issuer is a current Let's Encrypt intermediate (R10/R11), not R4.openssl s_client -starttls smtp -connect app.shroud.email:25 -CAfile /etc/ssl/cert.pem -verify_return_error </dev/null—Verify return code: 0 (ok).printf 'R\n' | openssl s_client -starttls smtp -connect app.shroud.email:25) returns an alert/reset while the initial handshake still succeeds.app.shroud.email:25; both findings clear.Notes
secureOptionsdoes not inherit into Haraka's[outbound]section, but renegotiation isn't a DoS risk on outbound (we're the client), so this is intentional.