Skip to content

Commit 2b5140f

Browse files
morehouserustyrussell
authored andcommitted
fuzz: don't fail when fuzzer generates valid MAC
The cryptofuzz target was based on a false premise: that it is impossible for any fuzzer to generate a valid ciphertext+MAC for the decrypt function. Niklas Gogge proved this premise incorrect using AFL++ with the CMPLOG feature, which enabled AFL++ to generate such valid messages. We remove the assertions requiring decryption to fail and add the inputs AFL++ found to the corpus.
1 parent 9da6487 commit 2b5140f

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CBBp��0h�u�� Ψ��Ӿ
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CB^~���kcȦO��zfB

tests/fuzz/fuzz-cryptomsg.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void test_encrypt_decrypt_equality(const u8 *msg)
7878
assert(tal_arr_eq(dec, msg));
7979
}
8080

81-
/* Test header decryption of arbitrary bytes (should always fail). */
81+
/* Test header decryption of arbitrary bytes. */
8282
static void test_decrypt_header(const u8 *buf)
8383
{
8484
struct crypto_state cs_in = init_cs_in;
@@ -87,15 +87,15 @@ static void test_decrypt_header(const u8 *buf)
8787
if (tal_bytelen(buf) < CRYPTOMSG_HDR_SIZE)
8888
return;
8989

90-
assert(!cryptomsg_decrypt_header(&cs_in, buf, &len));
90+
cryptomsg_decrypt_header(&cs_in, buf, &len);
9191
}
9292

93-
/* Test body decryption of arbitrary bytes (should always fail). */
93+
/* Test body decryption of arbitrary bytes. */
9494
static void test_decrypt_body(const u8 *buf)
9595
{
9696
struct crypto_state cs_in = init_cs_in;
9797

98-
assert(cryptomsg_decrypt_body(buf, &cs_in, buf) == NULL);
98+
cryptomsg_decrypt_body(buf, &cs_in, buf);
9999
}
100100

101101
void run(const u8 *data, size_t size)

0 commit comments

Comments
 (0)