The relay's SMTP door timed only its reads. The banner, every reply and the flush after it were written with no timeout, so a client that pipelined NOOPs and never read its replies held its session for good once the socket buffers filled. Nothing capped sessions across the relay either: the only limit was per remote address, keyed on the full IPv6 address, so anyone with an IPv6 /64 (or a few thousand IPv4 addresses) could open sessions until the relay ran out of file descriptors. Then accept() failed on the link port too, the downstream couldn't relink, and outbound delivery couldn't open sockets. No authentication was needed. Now every write on port 25 (banner, refusals, replies) must finish within the command timeout (5 minutes), or the session ends. A new setting, maxSmtpSessions (default 1000, must be above zero), caps the sessions open at once from all senders together; past it a connection gets "421 4.3.2 Too busy" and is closed. The per-IP limits count an IPv6 sender by its /64, and an IPv4-mapped address as the IPv4 address. The relay spec says so. Found in a security review. Test: in crates/relay, a session whose client pipelines NOOPs and never reads was still open an hour on (paused clock), a third session with maxSmtpSessions 2 got the 220 banner, and three addresses in one /64 were counted as three senders. Now the session ends at the write timeout, the third session gets 421 and a closed session's place is taken again, and a /64 shares one count.
46 lines
1.8 KiB
TOML
46 lines
1.8 KiB
TOML
[package]
|
|
name = "inbuxa-relay"
|
|
description = "inbuxa Relay: a small edge appliance that takes mail in for one downstream inbuxa server and sends its mail on (docs/spec/features/relay.md)"
|
|
license = "AGPL-3.0-only"
|
|
version.workspace = true
|
|
edition = "2024"
|
|
|
|
[[bin]]
|
|
name = "inbuxa-relay"
|
|
path = "src/main.rs"
|
|
|
|
# The footprint rule (RL-30): no inbuxa server crate. Everything here is
|
|
# small, and most of it the server already uses.
|
|
[dependencies]
|
|
inbuxa-relay-proto = { path = "../relay-proto" }
|
|
inbuxa-outbound-tls = { path = "../outbound-tls" }
|
|
rustls-native-certs = "0.8"
|
|
aws-lc-rs = { version = "1" }
|
|
smtp-proto = { version = "0.2.3" }
|
|
tokio = { version = "1.53", features = ["rt-multi-thread", "net", "io-util", "time", "sync", "macros", "signal", "fs"] }
|
|
rustls = { version = "0.23.43", default-features = false, features = ["std", "aws_lc_rs", "tls12"] }
|
|
tokio-rustls = { version = "0.26", default-features = false, features = ["aws_lc_rs", "tls12"] }
|
|
rustls-pki-types = { version = "1", features = ["std"] }
|
|
rustls-webpki = { version = "0.103", default-features = false, features = ["std", "aws-lc-rs"] }
|
|
rcgen = { version = "0.14", default-features = false, features = ["crypto", "pem", "aws_lc_rs"] }
|
|
x509-parser = { version = "0.18" }
|
|
hyper = { version = "1.11.1", features = ["server", "client", "http1"] }
|
|
hyper-util = { version = "0.1.20", features = ["tokio"] }
|
|
http-body-util = "0.1.5"
|
|
tokio-tungstenite = "0.30"
|
|
futures-util = "0.3.34"
|
|
serde = { version = "1.0", features = ["derive"] }
|
|
serde_json = "1.0"
|
|
|
|
[features]
|
|
# For the server's system tests only: `INBUXA_RELAY_TEST_MX=<port>` sends
|
|
# every domain's mail to 127.0.0.1 on that port. Never in a release.
|
|
test-mx = []
|
|
|
|
[lints]
|
|
workspace = true
|
|
|
|
[dev-dependencies]
|
|
hyper = { version = "1.11.1", features = ["client", "http1"] }
|
|
tokio = { version = "1.53", features = ["test-util"] }
|