From aa5a2a6fe8ad0f8f43e19d315bc267e7bea6592c Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 13 Mar 2020 19:07:02 +0100 Subject: [PATCH] Add a fuzzing target for the Proxy Protocol v2 parser --- fuzzing/README.md | 5 ++- .../proxy-protocol-local-header | Bin 0 -> 52 bytes .../proxy-protocol-v4-with-tlvs | Bin 0 -> 97 bytes pdns/Makefile.am | 11 +++++ pdns/fuzz_proxyprotocol.cc | 42 ++++++++++++++++++ 5 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 fuzzing/corpus/proxy-protocol-raw-packets/proxy-protocol-local-header create mode 100644 fuzzing/corpus/proxy-protocol-raw-packets/proxy-protocol-v4-with-tlvs create mode 100644 pdns/fuzz_proxyprotocol.cc diff --git a/fuzzing/README.md b/fuzzing/README.md index c42c5c12f1..055c448830 100644 --- a/fuzzing/README.md +++ b/fuzzing/README.md @@ -12,6 +12,7 @@ The current targets cover: - the auth, dnsdist and rec packet caches (fuzz_target_packetcache and fuzz_target_dnsdistcache) ; - MOADNSParser (fuzz_target_moadnsparser) ; +- the Proxy Protocol parser (fuzz_target_proxyprotocol) ; - ZoneParserTNG (fuzz_target_zoneparsertng). By default the targets are linked against a standalone target, @@ -38,7 +39,9 @@ Corpus This directory contains a few files used for continuous fuzzing of the PowerDNS products. -The 'corpus' directory contains two sub-directories: +The 'corpus' directory contains three sub-directories: +- proxy-protocol-raw-packets/ contains DNS queries prefixed with a Proxy + Protocol v2 header, used by fuzz_target_proxyprotocol ; - raw-dns-packets/ contains DNS queries and responses as captured on the wire. These are used by the fuzz_target_dnsdistcache, fuzz_target_moadnsparser and fuzz_target_packetcache targets ; diff --git a/fuzzing/corpus/proxy-protocol-raw-packets/proxy-protocol-local-header b/fuzzing/corpus/proxy-protocol-raw-packets/proxy-protocol-local-header new file mode 100644 index 0000000000000000000000000000000000000000..f2f8264e12924e26f00ac7b281d8d029abb33dce GIT binary patch literal 52 zc-rIT;^kuCU| values; + ComboAddress source; + ComboAddress destination; + bool proxy = false; + bool tcp = false; + + try { + parseProxyHeader(std::string(reinterpret_cast(data), size), proxy, source, destination, tcp, values); + } + catch(const std::exception& e) { + } + catch(const PDNSException& e) { + } + + return 0; +} -- 2.47.2