mbedtls/programs
Hanno Becker 7bac1ab38a 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:19:20 +01:00
..
aes Zeroize sensitive data in aescrypt2 and crypt_and_hash examples 2018-10-15 13:26:37 +01:00
hash Fix typo in platform macro defines for examples 2018-07-10 17:34:25 +01:00
pkey Fix private DER output shifted by one byte. 2019-01-31 19:20:37 +02:00
random Fix typo in platform macro defines for examples 2018-07-10 17:34:25 +01:00
ssl Merge remote-tracking branch 'origin/pr/2541' into mbedtls-2.7 2019-04-24 11:21:02 +01:00
test UDP proxy: Don't attempt to dissect dgram into records when dropping 2019-06-13 11:19:20 +01:00
util Fix typo in platform macro defines for examples 2018-07-10 17:34:25 +01:00
x509 Add tests for (named) bitstring to suite_asn1write 2019-02-11 21:10:55 +00:00
.gitignore Add new program to gitignore 2015-11-02 06:34:29 +09:00
CMakeLists.txt
Makefile Remove ssl_cert_test sample app 2019-04-07 16:59:13 +03:00
wince_main.c