From ed05b1054df10a2fbc68000cfdd429daec03a456 Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 4 May 2026 18:13:13 +0200 Subject: cgit: truncate all config values at the newline These would be largely invalid anyway (save, I suppose, for Linux file paths that technically can contain new lines). The actual problem is that these get printed back out into cached -- and trusted -- cgitrc files, and if the fields have newlines, the git-config way of less trusted users configuring repos on a shared system can be abused to inject newlines, which then can be used to smuggle global options (including filters, which execute code) into the cached cgitrc. So now, only ever duplicate up to the newline, when dealing with these inputs. Reported-by: Adrian Denkiewicz Signed-off-by: Jason A. Donenfeld --- ui-repolist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui-repolist.c') diff --git a/ui-repolist.c b/ui-repolist.c index d12e3dd..1b224cf 100644 --- a/ui-repolist.c +++ b/ui-repolist.c @@ -18,7 +18,7 @@ static time_t read_agefile(const char *path) char *buf = NULL; struct strbuf date_buf = STRBUF_INIT; - if (readfile(path, &buf, &size)) { + if (read_first_line(path, &buf, &size)) { free(buf); return 0; } -- cgit v1.2.3