Skip to content

Commit 966253d

Browse files
EricSesterhennX41JarLobsteadmon
authored andcommitted
fuzz: port fuzz-credential-from-url-gently 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-credential-from-url-gently 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 ef8ce8f commit 966253d

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2422,6 +2422,7 @@ endif
24222422
FUZZ_OBJS += oss-fuzz/dummy-cmd-main.o
24232423
FUZZ_OBJS += oss-fuzz/fuzz-commit-graph.o
24242424
FUZZ_OBJS += oss-fuzz/fuzz-config.o
2425+
FUZZ_OBJS += oss-fuzz/fuzz-credential-from-url-gently.o
24252426
FUZZ_OBJS += oss-fuzz/fuzz-date.o
24262427
FUZZ_OBJS += oss-fuzz/fuzz-pack-headers.o
24272428
FUZZ_OBJS += oss-fuzz/fuzz-pack-idx.o

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@ group "Build fuzzers" make \
1313
LIB_FUZZING_ENGINE="-fsanitize=fuzzer,address" \
1414
fuzz-all
1515

16-
for fuzzer in commit-graph config date pack-headers pack-idx ; do
16+
fuzzers="
17+
commit-graph
18+
config
19+
credential-from-url-gently
20+
date
21+
pack-headers
22+
pack-idx
23+
"
24+
25+
for fuzzer in $fuzzers; do
1726
begin_group "fuzz-$fuzzer"
1827
./oss-fuzz/fuzz-$fuzzer -verbosity=0 -runs=1 || exit 1
1928
end_group "fuzz-$fuzzer"

oss-fuzz/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
fuzz-commit-graph
22
fuzz-config
3+
fuzz-credential-from-url-gently
34
fuzz-date
45
fuzz-pack-headers
56
fuzz-pack-idx
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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 "credential.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+
struct credential c;
14+
char *buf;
15+
16+
buf = malloc(size + 1);
17+
if (!buf)
18+
return 0;
19+
20+
memcpy(buf, data, size);
21+
buf[size] = 0;
22+
23+
// start fuzzing
24+
credential_init(&c);
25+
credential_from_url_gently(&c, buf, 1);
26+
27+
// cleanup
28+
credential_clear(&c);
29+
free(buf);
30+
31+
return 0;
32+
}

0 commit comments

Comments
 (0)