Files
telemt/Cargo.toml

101 lines
2.0 KiB
TOML
Raw Normal View History

[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"
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 = []
[dependencies]
# C
libc = "0.2"
# Async runtime
Zeroize for key + log refactor + fix tests - Fixed tests that failed to compile due to mismatched generic parameters of HandshakeResult: - Changed `HandshakeResult<i32>` to `HandshakeResult<i32, (), ()>` - Changed `HandshakeResult::BadClient` to `HandshakeResult::BadClient { reader: (), writer: () }` - Added Zeroize for all structures holding key material: - AesCbc – key and IV are zeroized on drop - SecureRandomInner – PRNG output buffer is zeroized on drop; local key copy in constructor is zeroized immediately after being passed to the cipher - ObfuscationParams – all four key‑material fields are zeroized on drop - HandshakeSuccess – all four key‑material fields are zeroized on drop - Added protocol‑requirement documentation for legacy hashes (CodeQL suppression) in hash.rs (MD5/SHA‑1) - Added documentation for zeroize limitations of AesCtr (opaque cipher state) in aes.rs - Implemented silent‑mode logging and refactored initialization: - Added LogLevel enum to config and CLI flags --silent / --log-level - Added parse_cli() to handle --silent, --log-level, --help - Restructured main.rs initialization order: CLI → config load → determine log level → init tracing - Errors before tracing initialization are printed via eprintln! - Proxy links (tg://) are printed via println! – always visible regardless of log level - Configuration summary and operational messages are logged via info! (suppressed in silent mode) - Connection processing errors are lowered to debug! (hidden in silent mode) - Warning about default tls_domain moved to main (after tracing init) Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
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"] }
# Crypto
aes = "0.8"
ctr = "0.9"
cbc = "0.1"
sha2 = "0.10"
sha1 = "0.10"
md-5 = "0.10"
hmac = "0.12"
Zeroize for key + log refactor + fix tests - Fixed tests that failed to compile due to mismatched generic parameters of HandshakeResult: - Changed `HandshakeResult<i32>` to `HandshakeResult<i32, (), ()>` - Changed `HandshakeResult::BadClient` to `HandshakeResult::BadClient { reader: (), writer: () }` - Added Zeroize for all structures holding key material: - AesCbc – key and IV are zeroized on drop - SecureRandomInner – PRNG output buffer is zeroized on drop; local key copy in constructor is zeroized immediately after being passed to the cipher - ObfuscationParams – all four key‑material fields are zeroized on drop - HandshakeSuccess – all four key‑material fields are zeroized on drop - Added protocol‑requirement documentation for legacy hashes (CodeQL suppression) in hash.rs (MD5/SHA‑1) - Added documentation for zeroize limitations of AesCtr (opaque cipher state) in aes.rs - Implemented silent‑mode logging and refactored initialization: - Added LogLevel enum to config and CLI flags --silent / --log-level - Added parse_cli() to handle --silent, --log-level, --help - Restructured main.rs initialization order: CLI → config load → determine log level → init tracing - Errors before tracing initialization are printed via eprintln! - Proxy links (tg://) are printed via println! – always visible regardless of log level - Configuration summary and operational messages are logged via info! (suppressed in silent mode) - Connection processing errors are lowered to debug! (hidden in silent mode) - Warning about default tls_domain moved to main (after tracing init) Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
2026-02-07 19:49:41 +03:00
crc32fast = "1.4"
2026-02-23 02:32:13 +03:00
crc32c = "0.6"
Zeroize for key + log refactor + fix tests - Fixed tests that failed to compile due to mismatched generic parameters of HandshakeResult: - Changed `HandshakeResult<i32>` to `HandshakeResult<i32, (), ()>` - Changed `HandshakeResult::BadClient` to `HandshakeResult::BadClient { reader: (), writer: () }` - Added Zeroize for all structures holding key material: - AesCbc – key and IV are zeroized on drop - SecureRandomInner – PRNG output buffer is zeroized on drop; local key copy in constructor is zeroized immediately after being passed to the cipher - ObfuscationParams – all four key‑material fields are zeroized on drop - HandshakeSuccess – all four key‑material fields are zeroized on drop - Added protocol‑requirement documentation for legacy hashes (CodeQL suppression) in hash.rs (MD5/SHA‑1) - Added documentation for zeroize limitations of AesCtr (opaque cipher state) in aes.rs - Implemented silent‑mode logging and refactored initialization: - Added LogLevel enum to config and CLI flags --silent / --log-level - Added parse_cli() to handle --silent, --log-level, --help - Restructured main.rs initialization order: CLI → config load → determine log level → init tracing - Errors before tracing initialization are printed via eprintln! - Proxy links (tg://) are printed via println! – always visible regardless of log level - Configuration summary and operational messages are logged via info! (suppressed in silent mode) - Connection processing errors are lowered to debug! (hidden in silent mode) - Warning about default tls_domain moved to main (after tracing init) Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
2026-02-07 19:49:41 +03:00
zeroize = { version = "1.8", features = ["derive"] }
subtle = "2.6"
static_assertions = "1.1"
# Network
socket2 = { version = "0.6", features = ["all"] }
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"] }
Zeroize for key + log refactor + fix tests - Fixed tests that failed to compile due to mismatched generic parameters of HandshakeResult: - Changed `HandshakeResult<i32>` to `HandshakeResult<i32, (), ()>` - Changed `HandshakeResult::BadClient` to `HandshakeResult::BadClient { reader: (), writer: () }` - Added Zeroize for all structures holding key material: - AesCbc – key and IV are zeroized on drop - SecureRandomInner – PRNG output buffer is zeroized on drop; local key copy in constructor is zeroized immediately after being passed to the cipher - ObfuscationParams – all four key‑material fields are zeroized on drop - HandshakeSuccess – all four key‑material fields are zeroized on drop - Added protocol‑requirement documentation for legacy hashes (CodeQL suppression) in hash.rs (MD5/SHA‑1) - Added documentation for zeroize limitations of AesCtr (opaque cipher state) in aes.rs - Implemented silent‑mode logging and refactored initialization: - Added LogLevel enum to config and CLI flags --silent / --log-level - Added parse_cli() to handle --silent, --log-level, --help - Restructured main.rs initialization order: CLI → config load → determine log level → init tracing - Errors before tracing initialization are printed via eprintln! - Proxy links (tg://) are printed via println! – always visible regardless of log level - Configuration summary and operational messages are logged via info! (suppressed in silent mode) - Connection processing errors are lowered to debug! (hidden in silent mode) - Warning about default tls_domain moved to main (after tracing init) Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
2026-02-07 19:49:41 +03:00
# Serialization
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "1.0"
x509-parser = "0.18"
# Utils
Zeroize for key + log refactor + fix tests - Fixed tests that failed to compile due to mismatched generic parameters of HandshakeResult: - Changed `HandshakeResult<i32>` to `HandshakeResult<i32, (), ()>` - Changed `HandshakeResult::BadClient` to `HandshakeResult::BadClient { reader: (), writer: () }` - Added Zeroize for all structures holding key material: - AesCbc – key and IV are zeroized on drop - SecureRandomInner – PRNG output buffer is zeroized on drop; local key copy in constructor is zeroized immediately after being passed to the cipher - ObfuscationParams – all four key‑material fields are zeroized on drop - HandshakeSuccess – all four key‑material fields are zeroized on drop - Added protocol‑requirement documentation for legacy hashes (CodeQL suppression) in hash.rs (MD5/SHA‑1) - Added documentation for zeroize limitations of AesCtr (opaque cipher state) in aes.rs - Implemented silent‑mode logging and refactored initialization: - Added LogLevel enum to config and CLI flags --silent / --log-level - Added parse_cli() to handle --silent, --log-level, --help - Restructured main.rs initialization order: CLI → config load → determine log level → init tracing - Errors before tracing initialization are printed via eprintln! - Proxy links (tg://) are printed via println! – always visible regardless of log level - Configuration summary and operational messages are logged via info! (suppressed in silent mode) - Connection processing errors are lowered to debug! (hidden in silent mode) - Warning about default tls_domain moved to main (after tracing init) Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
2026-02-07 19:49:41 +03:00
bytes = "1.9"
thiserror = "2.0"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing-appender = "0.2"
parking_lot = "0.12"
dashmap = "6.1"
arc-swap = "1.7"
lru = "0.16"
rand = "0.10"
chrono = { version = "0.4", features = ["serde"] }
hex = "0.4"
Zeroize for key + log refactor + fix tests - Fixed tests that failed to compile due to mismatched generic parameters of HandshakeResult: - Changed `HandshakeResult<i32>` to `HandshakeResult<i32, (), ()>` - Changed `HandshakeResult::BadClient` to `HandshakeResult::BadClient { reader: (), writer: () }` - Added Zeroize for all structures holding key material: - AesCbc – key and IV are zeroized on drop - SecureRandomInner – PRNG output buffer is zeroized on drop; local key copy in constructor is zeroized immediately after being passed to the cipher - ObfuscationParams – all four key‑material fields are zeroized on drop - HandshakeSuccess – all four key‑material fields are zeroized on drop - Added protocol‑requirement documentation for legacy hashes (CodeQL suppression) in hash.rs (MD5/SHA‑1) - Added documentation for zeroize limitations of AesCtr (opaque cipher state) in aes.rs - Implemented silent‑mode logging and refactored initialization: - Added LogLevel enum to config and CLI flags --silent / --log-level - Added parse_cli() to handle --silent, --log-level, --help - Restructured main.rs initialization order: CLI → config load → determine log level → init tracing - Errors before tracing initialization are printed via eprintln! - Proxy links (tg://) are printed via println! – always visible regardless of log level - Configuration summary and operational messages are logged via info! (suppressed in silent mode) - Connection processing errors are lowered to debug! (hidden in silent mode) - Warning about default tls_domain moved to main (after tracing init) Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
2026-02-07 19:49:41 +03:00
base64 = "0.22"
url = "2.5"
Zeroize for key + log refactor + fix tests - Fixed tests that failed to compile due to mismatched generic parameters of HandshakeResult: - Changed `HandshakeResult<i32>` to `HandshakeResult<i32, (), ()>` - Changed `HandshakeResult::BadClient` to `HandshakeResult::BadClient { reader: (), writer: () }` - Added Zeroize for all structures holding key material: - AesCbc – key and IV are zeroized on drop - SecureRandomInner – PRNG output buffer is zeroized on drop; local key copy in constructor is zeroized immediately after being passed to the cipher - ObfuscationParams – all four key‑material fields are zeroized on drop - HandshakeSuccess – all four key‑material fields are zeroized on drop - Added protocol‑requirement documentation for legacy hashes (CodeQL suppression) in hash.rs (MD5/SHA‑1) - Added documentation for zeroize limitations of AesCtr (opaque cipher state) in aes.rs - Implemented silent‑mode logging and refactored initialization: - Added LogLevel enum to config and CLI flags --silent / --log-level - Added parse_cli() to handle --silent, --log-level, --help - Restructured main.rs initialization order: CLI → config load → determine log level → init tracing - Errors before tracing initialization are printed via eprintln! - Proxy links (tg://) are printed via println! – always visible regardless of log level - Configuration summary and operational messages are logged via info! (suppressed in silent mode) - Connection processing errors are lowered to debug! (hidden in silent mode) - Warning about default tls_domain moved to main (after tracing init) Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
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"
x25519-dalek = "2"
anyhow = "1.0"
# HTTP
reqwest = { version = "0.13", features = ["rustls"], default-features = false }
notify = "8.2"
ipnetwork = { version = "0.21", features = ["serde"] }
hyper = { version = "1", features = ["server", "http1"] }
hyper-util = { version = "0.1", features = ["tokio", "server-auto"] }
http-body-util = "0.1"
httpdate = "1.0"
tokio-rustls = { version = "0.26", default-features = false, features = [
"tls12",
] }
rustls = { version = "0.23", default-features = false, features = [
"std",
"tls12",
"ring",
] }
webpki-roots = "1.0"
[dev-dependencies]
tokio-test = "0.4"
criterion = "0.8"
proptest = "1.4"
Zeroize for key + log refactor + fix tests - Fixed tests that failed to compile due to mismatched generic parameters of HandshakeResult: - Changed `HandshakeResult<i32>` to `HandshakeResult<i32, (), ()>` - Changed `HandshakeResult::BadClient` to `HandshakeResult::BadClient { reader: (), writer: () }` - Added Zeroize for all structures holding key material: - AesCbc – key and IV are zeroized on drop - SecureRandomInner – PRNG output buffer is zeroized on drop; local key copy in constructor is zeroized immediately after being passed to the cipher - ObfuscationParams – all four key‑material fields are zeroized on drop - HandshakeSuccess – all four key‑material fields are zeroized on drop - Added protocol‑requirement documentation for legacy hashes (CodeQL suppression) in hash.rs (MD5/SHA‑1) - Added documentation for zeroize limitations of AesCtr (opaque cipher state) in aes.rs - Implemented silent‑mode logging and refactored initialization: - Added LogLevel enum to config and CLI flags --silent / --log-level - Added parse_cli() to handle --silent, --log-level, --help - Restructured main.rs initialization order: CLI → config load → determine log level → init tracing - Errors before tracing initialization are printed via eprintln! - Proxy links (tg://) are printed via println! – always visible regardless of log level - Configuration summary and operational messages are logged via info! (suppressed in silent mode) - Connection processing errors are lowered to debug! (hidden in silent mode) - Warning about default tls_domain moved to main (after tracing init) Co-Authored-By: brekotis <93345790+brekotis@users.noreply.github.com>
2026-02-07 19:49:41 +03:00
futures = "0.3"
[[bench]]
name = "crypto_bench"
2026-02-15 13:20:19 +03:00
harness = false
[profile.release]
lto = "fat"
codegen-units = 1