mbedtls/programs/test
Hanno Becker bcf97ec18c UDP proxy: Don't attempt to dissect dgram into records when dropping
To prevent dropping the same message over and over again, the UDP proxy
test application programs/test/udp_proxy _logically_ maintains a mapping
from records to the number of times the record has already been dropped,
and stops dropping once a configurable threshold (currently 2) is passed.

However, the actual implementation deviates from this logical view
in two crucial respects:
- To keep the implementation simple and independent of
  implementations of suitable map interfaces, it only counts how
  many times a record of a given _size_ has been dropped, and
  stops dropping further records of that size once the configurable
  threshold is passed. Of course, this is not fail-proof, but a
  good enough approximation for the proxy, and it allows to use
  an inefficient but simple array for the required map.
- The implementation mixes datagram lengths and record lengths:
  When deciding whether it is allowed to drop a datagram, it
  uses the total datagram size as a lookup index into the map
  counting the number of times a package has been dropped. However,
  when updating this map, the UDP proxy traverses the datagram
  record by record, and updates the mapping at the level of record
  lengths.

Apart from this inconsistency, the current implementation suffers
from a lack of bounds checking for the parsed length of incoming
DTLS records that can lead to a buffer overflow when facing
malformed records.

This commit removes the inconsistency in datagram vs. record length
and resolves the buffer overflow issue by not attempting any dissection
of datagrams into records, and instead only counting how often _datagrams_
of a particular size have been dropped.

There is only one practical situation where this makes a difference:
If datagram packing is used by default but disabled on retransmission
(which OpenSSL has been seen to do), it can happen that we drop a
datagram in its initial transmission, then also drop some of its records
when they retransmitted one-by-one afterwards, yet still keeping the
drop-counter at 1 instead of 2. However, even in this situation, we'll
correctly count the number of droppings from that point on and eventually
stop dropping, because the peer will not fall back to using packing
and hence use stable record lengths.
2019-06-13 11:21:42 +01:00
..
benchmark.c Improve macro hygiene 2019-04-24 10:51:54 +02:00
CMakeLists.txt Remove ssl_cert_test sample app 2019-04-07 16:51:18 +03:00
cpp_dummy_build.cpp cpp_dummy_build: Add NIST key wrapping header 2018-07-24 16:51:09 +01:00
query_compile_time_config.c Fix aligment in programs/test/query_compile_time_config.c 2019-02-07 10:32:31 +00:00
selftest.c Fix const-ness in mbedtls_param_failed() 2018-12-11 12:28:56 +01:00
udp_proxy.c UDP proxy: Don't attempt to dissect dgram into records when dropping 2019-06-13 11:21:42 +01:00
udp_proxy_wrapper.sh udp_proxy_wrapper.sh: fix cleanup not cleaning up 2017-10-24 11:25:19 +01:00
zeroize.c Fix coverity defects 2018-06-06 03:44:03 +01:00