git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] fuzz: port fuzz-url-decode-mem from OSS-Fuzz

From
Josh Steadmon <steadmon@google.com>
Date
Oct 10, 2024, 21:11 UTC
Message-ID
<4c9813313ccb620f2ac176ef9fe9223113523c75.1728594659.git.steadmon@google.com>
In-Reply-To
<cover.1728594659.git.steadmon@google.com>
From: Eric Sesterhenn <eric.sesterhenn@x41-dsec.de>

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 <jarlob@gmail.com>
Co-authored-by: Josh Steadmon <steadmon@google.com>
Signed-off-by: Josh Steadmon <steadmon@google.com>
---
 Makefile                            |  1 +
 ci/run-build-and-minimal-fuzzers.sh |  1 +
 oss-fuzz/.gitignore                 |  1 +
 oss-fuzz/fuzz-url-decode-mem.c      | 43 +++++++++++++++++++++++++++++
 4 files changed, 46 insertions(+)
 create mode 100644 oss-fuzz/fuzz-url-decode-mem.c
diff --git a/Makefile b/Makefile
index 141e194bf5..2cd7a6e003 100644
--- a/Makefile
+++ b/Makefile
@@ -2383,6 +2383,7 @@ FUZZ_OBJS += oss-fuzz/fuzz-date.o
 FUZZ_OBJS += oss-fuzz/fuzz-pack-headers.o
 FUZZ_OBJS += oss-fuzz/fuzz-pack-idx.o
 FUZZ_OBJS += oss-fuzz/fuzz-parse-attr-line.o
+FUZZ_OBJS += oss-fuzz/fuzz-url-decode-mem.o
 .PHONY: fuzz-objs
 fuzz-objs: $(FUZZ_OBJS)
 
diff --git a/ci/run-build-and-minimal-fuzzers.sh b/ci/run-build-and-minimal-fuzzers.sh
index 60fe8b0dfc..08c556c818 100755
--- a/ci/run-build-and-minimal-fuzzers.sh
+++ b/ci/run-build-and-minimal-fuzzers.sh
@@ -21,6 +21,7 @@ date \
 pack-headers \
 pack-idx \
 parse-attr-line \
+url-decode-mem \
 "
 
 for fuzzer in $fuzzers ; do
diff --git a/oss-fuzz/.gitignore b/oss-fuzz/.gitignore
index ec185f061c..f2d74de457 100644
--- a/oss-fuzz/.gitignore
+++ b/oss-fuzz/.gitignore
@@ -5,3 +5,4 @@ fuzz-date
 fuzz-pack-headers
 fuzz-pack-idx
 fuzz-parse-attr-line
+fuzz-url-decode-mem
diff --git a/oss-fuzz/fuzz-url-decode-mem.c b/oss-fuzz/fuzz-url-decode-mem.c
new file mode 100644
index 0000000000..2342aa993b
--- /dev/null
+++ b/oss-fuzz/fuzz-url-decode-mem.c
@@ -0,0 +1,43 @@
+#include "git-compat-util.h"
+#include <stddef.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdio.h>
+#include "url.h"
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
+
+int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+	char *buf;
+	char *r;
+	const char *pbuf;
+
+	buf = malloc(size + 1);
+	if (!buf)
+		return 0;
+
+	memcpy(buf, data, size);
+	buf[size] = 0;
+
+	// start fuzzing
+	r = url_decode(buf);
+	free(r);
+
+	r = url_percent_decode(buf);
+	free(r);
+
+	pbuf = (const char*) buf;
+	r = url_decode_parameter_name(&pbuf);
+	free(r);
+
+	pbuf = (const char*) buf;
+	r = url_decode_parameter_value(&pbuf);
+	free(r);
+
+	// cleanup
+	free(buf);
+
+	return 0;
+}
-- 
2.47.0.rc1.288.g06298d1525-goog
Previous: Josh SteadmonNext: Junio C Hamano
Message 8 of 13 in “fuzz: port OSS-Fuzz tests back to Git”
  1. 0/3 fuzz: port OSS-Fuzz tests back to GitJosh Steadmon, Oct 10, 2024
  2. 1/3 fuzz: port fuzz-credential-from-url-gently from OSS-FuzzJosh Steadmon, Oct 10, 2024
  3. Oswald BuddenhagenOct 11, 2024
  4. Junio C HamanoOct 11, 2024
  5. Josh SteadmonOct 14, 2024
  6. Josh SteadmonOct 14, 2024
  7. 2/3 fuzz: port fuzz-parse-attr-line from OSS-FuzzJosh Steadmon, Oct 10, 2024
  8. 3/3 fuzz: port fuzz-url-decode-mem from OSS-FuzzJosh Steadmon, Oct 10, 2024
  9. Junio C HamanoOct 10, 2024
  10. 0/3 fuzz: port OSS-Fuzz tests back to GitJosh Steadmon, Oct 14, 2024
  11. 1/3 fuzz: port fuzz-credential-from-url-gently from OSS-FuzzJosh Steadmon, Oct 14, 2024
  12. 2/3 fuzz: port fuzz-parse-attr-line from OSS-FuzzJosh Steadmon, Oct 14, 2024
  13. 3/3 fuzz: port fuzz-url-decode-mem from OSS-FuzzJosh Steadmon, Oct 14, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.