Skip to content

Commit 751d063

Browse files
EricSesterhennX41JarLobsteadmon
authored andcommitted
fuzz: port fuzz-url-decode-mem from OSS-Fuzz
Git's fuzz tests are run continuously as part of OSS-Fuzz [1]. Several additional fuzz tests have been contributed directly to OSS-Fuzz; however, these tests are vulnerable to bitrot because they are not built during Git's CI runs, and thus breaking changes are much less likely to be noticed by Git contributors. Port one of these tests back to the Git project: fuzz-url-decode-mem This test was originally written by Eric Sesterhenn as part of a security audit of Git [2]. It was then contributed to the OSS-Fuzz repo in commit c58ac4492 (Git fuzzing: uncomment the existing and add new targets. (#11486), 2024-02-21) by Jaroslav Lobačevski. I (Josh Steadmon) have verified with both Eric and Jaroslav that they're OK with moving this test to the Git project. [1] https://github.com/google/oss-fuzz [2] https://ostif.org/wp-content/uploads/2023/01/X41-OSTIF-Gitlab-Git-Security-Audit-20230117-public.pdf Co-authored-by: Jaroslav Lobačevski <[email protected]> Co-authored-by: Josh Steadmon <[email protected]> Signed-off-by: Josh Steadmon <[email protected]> Signed-off-by: Taylor Blau <[email protected]>
1 parent 72686d4 commit 751d063

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,7 @@ FUZZ_OBJS += oss-fuzz/fuzz-date.o
24272427
FUZZ_OBJS += oss-fuzz/fuzz-pack-headers.o
24282428
FUZZ_OBJS += oss-fuzz/fuzz-pack-idx.o
24292429
FUZZ_OBJS += oss-fuzz/fuzz-parse-attr-line.o
2430+
FUZZ_OBJS += oss-fuzz/fuzz-url-decode-mem.o
24302431
.PHONY: fuzz-objs
24312432
fuzz-objs: $(FUZZ_OBJS)
24322433

ci/run-build-and-minimal-fuzzers.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ date
2121
pack-headers
2222
pack-idx
2323
parse-attr-line
24+
url-decode-mem
2425
"
2526

2627
for fuzzer in $fuzzers; do

oss-fuzz/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ fuzz-date
55
fuzz-pack-headers
66
fuzz-pack-idx
77
fuzz-parse-attr-line
8+
fuzz-url-decode-mem

oss-fuzz/fuzz-url-decode-mem.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#include "git-compat-util.h"
2+
#include <stddef.h>
3+
#include <stdlib.h>
4+
#include <stdint.h>
5+
#include <string.h>
6+
#include <stdio.h>
7+
#include "url.h"
8+
9+
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
10+
11+
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
12+
{
13+
char *buf;
14+
char *r;
15+
const char *pbuf;
16+
17+
buf = malloc(size + 1);
18+
if (!buf)
19+
return 0;
20+
21+
memcpy(buf, data, size);
22+
buf[size] = 0;
23+
24+
// start fuzzing
25+
r = url_decode(buf);
26+
free(r);
27+
28+
r = url_percent_decode(buf);
29+
free(r);
30+
31+
pbuf = (const char*) buf;
32+
r = url_decode_parameter_name(&pbuf);
33+
free(r);
34+
35+
pbuf = (const char*) buf;
36+
r = url_decode_parameter_value(&pbuf);
37+
free(r);
38+
39+
// cleanup
40+
free(buf);
41+
42+
return 0;
43+
}

0 commit comments

Comments
 (0)