2025-12-30 05:08:05 +03:00
|
|
|
[package]
|
|
|
|
|
name = "telemt"
|
2026-05-10 14:14:52 +03:00
|
|
|
version = "3.4.11"
|
2026-03-20 01:06:00 +04:00
|
|
|
edition = "2024"
|
2025-12-30 05:08:05 +03:00
|
|
|
|
Security hardening, concurrency fixes, and expanded test coverage
This commit introduces a comprehensive set of improvements to enhance
the security, reliability, and configurability of the proxy server,
specifically targeting adversarial resilience and high-load concurrency.
Security & Cryptography:
- Zeroize MTProto cryptographic key material (`dec_key`, `enc_key`)
immediately after use to prevent memory leakage on early returns.
- Move TLS handshake replay tracking after full policy/ALPN validation
to prevent cache poisoning by unauthenticated probes.
- Add `proxy_protocol_trusted_cidrs` configuration to restrict PROXY
protocol headers to trusted networks, rejecting spoofed IPs.
Adversarial Resilience & DoS Mitigation:
- Implement "Tiny Frame Debt" tracking in the middle-relay to prevent
CPU exhaustion from malicious 0-byte or 1-byte frame floods.
- Add `mask_relay_max_bytes` to strictly bound unauthenticated fallback
connections, preventing the proxy from being abused as an open relay.
- Add a 5ms prefetch window (`mask_classifier_prefetch_timeout_ms`) to
correctly assemble and classify fragmented HTTP/1.1 and HTTP/2 probes
(e.g., `PRI * HTTP/2.0`) before routing them to masking heuristics.
- Prevent recursive masking loops (FD exhaustion) by verifying the mask
target is not the proxy's own listener via local interface enumeration.
Concurrency & Reliability:
- Eliminate executor waker storms during quota lock contention by replacing
the spin-waker task with inline `Sleep` and exponential backoff.
- Roll back user quota reservations (`rollback_me2c_quota_reservation`)
if a network write fails, preventing Head-of-Line (HoL) blocking from
permanently burning data quotas.
- Recover gracefully from idle-registry `Mutex` poisoning instead of
panicking, ensuring isolated thread failures do not break the proxy.
- Fix `auth_probe_scan_start_offset` modulo logic to ensure bounds safety.
Testing:
- Add extensive adversarial, timing, fuzzing, and invariant test suites
for both the client and handshake modules.
2026-03-22 23:06:26 +04:00
|
|
|
[features]
|
|
|
|
|
redteam_offline_expected_fail = []
|
|
|
|
|
|
2025-12-30 05:08:05 +03:00
|
|
|
[dependencies]
|
|
|
|
|
# C
|
|
|
|
|
libc = "0.2"
|
|
|
|
|
|
|
|
|
|
# Async runtime
|
2026-02-07 19:49:41 +03:00
|
|
|
tokio = { version = "1.42", features = ["full", "tracing"] }
|
2026-02-17 03:40:39 +03:00
|
|
|
tokio-util = { version = "0.7", features = ["full"] }
|
2025-12-30 05:08:05 +03:00
|
|
|
|
|
|
|
|
# Crypto
|
|
|
|
|
aes = "0.8"
|
|
|
|
|
ctr = "0.9"
|
|
|
|
|
cbc = "0.1"
|
|
|
|
|
sha2 = "0.10"
|
|
|
|
|
sha1 = "0.10"
|
|
|
|
|
md-5 = "0.10"
|
|
|
|
|
hmac = "0.12"
|
2026-02-07 19:49:41 +03:00
|
|
|
crc32fast = "1.4"
|
2026-02-23 02:32:13 +03:00
|
|
|
crc32c = "0.6"
|
2026-02-07 19:49:41 +03:00
|
|
|
zeroize = { version = "1.8", features = ["derive"] }
|
2026-03-15 00:02:03 +04:00
|
|
|
subtle = "2.6"
|
2026-03-16 20:04:41 +04:00
|
|
|
static_assertions = "1.1"
|
2025-12-30 05:08:05 +03:00
|
|
|
|
|
|
|
|
# Network
|
2026-03-21 15:43:07 +04:00
|
|
|
socket2 = { version = "0.6", features = ["all"] }
|
2026-03-20 20:31:47 +02:00
|
|
|
nix = { version = "0.31", default-features = false, features = [
|
|
|
|
|
"net",
|
|
|
|
|
"user",
|
|
|
|
|
"process",
|
|
|
|
|
"fs",
|
|
|
|
|
"signal",
|
|
|
|
|
] }
|
2026-03-18 12:36:44 +03:00
|
|
|
shadowsocks = { version = "1.24", features = ["aead-cipher-2022"] }
|
2025-12-30 05:08:05 +03:00
|
|
|
|
2026-02-07 19:49:41 +03:00
|
|
|
# Serialization
|
2025-12-30 05:08:05 +03:00
|
|
|
serde = { version = "1.0", features = ["derive"] }
|
|
|
|
|
serde_json = "1.0"
|
2026-03-21 15:43:07 +04:00
|
|
|
toml = "1.0"
|
|
|
|
|
x509-parser = "0.18"
|
2025-12-30 05:08:05 +03:00
|
|
|
|
|
|
|
|
# Utils
|
2026-02-07 19:49:41 +03:00
|
|
|
bytes = "1.9"
|
|
|
|
|
thiserror = "2.0"
|
2025-12-30 05:08:05 +03:00
|
|
|
tracing = "0.1"
|
|
|
|
|
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
2026-03-20 22:26:42 +02:00
|
|
|
tracing-appender = "0.2"
|
2025-12-30 05:08:05 +03:00
|
|
|
parking_lot = "0.12"
|
2026-03-21 15:43:07 +04:00
|
|
|
dashmap = "6.1"
|
2026-03-20 00:45:04 +03:00
|
|
|
arc-swap = "1.7"
|
2026-02-13 00:31:52 +00:00
|
|
|
lru = "0.16"
|
2026-03-21 15:43:07 +04:00
|
|
|
rand = "0.10"
|
2025-12-30 05:08:05 +03:00
|
|
|
chrono = { version = "0.4", features = ["serde"] }
|
|
|
|
|
hex = "0.4"
|
2026-02-07 19:49:41 +03:00
|
|
|
base64 = "0.22"
|
2025-12-30 05:08:05 +03:00
|
|
|
url = "2.5"
|
2026-02-07 19:49:41 +03:00
|
|
|
regex = "1.11"
|
2026-01-01 23:34:04 +03:00
|
|
|
crossbeam-queue = "0.3"
|
2026-02-15 14:15:56 +03:00
|
|
|
num-bigint = "0.4"
|
|
|
|
|
num-traits = "0.2"
|
2026-03-18 01:40:38 +04:00
|
|
|
x25519-dalek = "2"
|
2026-02-20 13:14:09 +03:00
|
|
|
anyhow = "1.0"
|
2025-12-30 05:08:05 +03:00
|
|
|
|
|
|
|
|
# HTTP
|
2026-03-21 15:43:07 +04:00
|
|
|
reqwest = { version = "0.13", features = ["rustls"], default-features = false }
|
|
|
|
|
notify = "8.2"
|
|
|
|
|
ipnetwork = { version = "0.21", features = ["serde"] }
|
2026-02-17 01:11:01 +03:00
|
|
|
hyper = { version = "1", features = ["server", "http1"] }
|
|
|
|
|
hyper-util = { version = "0.1", features = ["tokio", "server-auto"] }
|
|
|
|
|
http-body-util = "0.1"
|
2026-02-17 04:16:16 +03:00
|
|
|
httpdate = "1.0"
|
2026-03-20 20:31:47 +02:00
|
|
|
tokio-rustls = { version = "0.26", default-features = false, features = [
|
|
|
|
|
"tls12",
|
|
|
|
|
] }
|
|
|
|
|
rustls = { version = "0.23", default-features = false, features = [
|
|
|
|
|
"std",
|
|
|
|
|
"tls12",
|
|
|
|
|
"ring",
|
|
|
|
|
] }
|
2026-03-21 15:43:07 +04:00
|
|
|
webpki-roots = "1.0"
|
2025-12-30 05:08:05 +03:00
|
|
|
|
|
|
|
|
[dev-dependencies]
|
|
|
|
|
tokio-test = "0.4"
|
2026-03-21 15:43:07 +04:00
|
|
|
criterion = "0.8"
|
2025-12-30 05:08:05 +03:00
|
|
|
proptest = "1.4"
|
2026-02-07 19:49:41 +03:00
|
|
|
futures = "0.3"
|
2025-12-30 05:08:05 +03:00
|
|
|
|
|
|
|
|
[[bench]]
|
|
|
|
|
name = "crypto_bench"
|
2026-02-15 13:20:19 +03:00
|
|
|
harness = false
|
2026-03-11 20:49:51 +04:00
|
|
|
|
|
|
|
|
[profile.release]
|
2026-03-24 14:01:49 +03:00
|
|
|
lto = "fat"
|
|
|
|
|
codegen-units = 1
|