mtproto_proxy/test
Sergey Prokhorov dfe8ebf034
Send TLS decode_error alert on malformed ClientHello and missing SNI
Scanners probe for fake-TLS proxies by sending structurally malformed
ClientHellos (e.g. ExtensionsLen=0 with trailing extension bytes). A
real TLS server responds with a fatal decode_error alert; previously
the proxy crashed the handler process silently, making it detectable.

Changes:
- mtp_fake_tls: add TLS_REC_ALERT, TLS_ALERT_FATAL, TLS_ALERT_DECODE_ERROR
  macros; export tls_decode_error_alert/0 which builds the 7-byte alert
  frame from macros
- mtp_fake_tls: add second clause to parse_client_hello/1 that throws
  {protocol_error, tls_bad_client_hello, bad_client_hello} instead of
  letting a bare function_clause propagate
- mtp_fake_tls: tighten parse_sni/1 catch to match the specific tagged
  error rather than a catch-all error:_
- mtp_handler: add attempt_fronting clauses for tls_bad_client_hello and
  tls_no_sni — both send the decode_error alert before closing
- mtp_handler: effective_secret/2 now raises tls_bad_client_hello (not
  tls_invalid_digest) when per_sni_secrets=on and the ClientHello has
  no SNI, so it also gets the alert treatment
- single_dc_SUITE: new malformed_tls_hello_decode_error_case/1 verifies
  the alert bytes are sent and the metric is incremented
- AGENTS.md: document test organisation, process architecture diagram,
  and upstream/downstream naming note

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-04-07 13:46:39 +02:00
..
bench_codec_decode.erl Add option to disable crc32 check in mtp_full to save CPU 2019-10-24 23:28:24 +02:00
bench_codec_encode.erl Add benchmarks 2019-10-14 02:48:08 +02:00
mtp_prop_gen.erl Fix decoding of packets split to multiple TLS frames. Fixes gh-16 2019-08-12 19:02:37 +02:00
mtp_test_client.erl Modernisations 2026-02-17 01:11:32 +01:00
mtp_test_cmd_rpc.erl Add some statefull property-based integration tests 2019-03-13 02:12:21 +01:00
mtp_test_datacenter.erl Fix httpd "eaddrinuse" in tests 2019-04-02 00:02:10 +02:00
mtp_test_echo_rpc.erl Make it possible to change logick of test server RPC handling 2019-03-07 02:32:22 +01:00
mtp_test_metric.erl Replace Travis-CI with Github actions, add support for OTP-25 2022-11-23 00:58:53 +01:00
mtp_test_middle_server.erl Upgrade ranch 1.7.0 → 2.2.0 2026-04-05 01:41:01 +02:00
prop_mtp_abridged.erl Refactor codecs 2019-07-25 13:17:37 +02:00
prop_mtp_aes_cbc.erl Refactor codecs 2019-07-25 13:17:37 +02:00
prop_mtp_codec.erl Add option to disable crc32 check in mtp_full to save CPU 2019-10-24 23:28:24 +02:00
prop_mtp_fake_tls.erl Add per-SNI derived secrets feature 2026-04-07 03:22:57 +02:00
prop_mtp_full.erl Add option to disable crc32 check in mtp_full to save CPU 2019-10-24 23:28:24 +02:00
prop_mtp_intermediate.erl Refactor codecs 2019-07-25 13:17:37 +02:00
prop_mtp_obfuscated.erl Cosmetic changes: README, docker, dialyzer fixes 2019-08-12 19:02:37 +02:00
prop_mtp_rpc.erl Add some docstrings to tests 2019-03-05 01:30:38 +01:00
prop_mtp_statefull.erl Use OTP logger instead of lager. 2026-02-17 01:50:54 +01:00
single_dc_SUITE.erl Send TLS decode_error alert on malformed ClientHello and missing SNI 2026-04-07 13:46:39 +02:00
test-sys.config Use OTP logger instead of lager. 2026-02-17 01:50:54 +01:00