|
|
226fcd |
From d74a30d45c6834c8e9f87115197370fe86656d81 Mon Sep 17 00:00:00 2001
|
|
|
226fcd |
From: Jim Meyering <meyering@fb.com>
|
|
|
226fcd |
Date: Mon, 4 Apr 2022 23:52:49 -0700
|
|
|
226fcd |
Subject: zgrep: add NEWS and tests for this exploitable bug
|
|
|
226fcd |
|
|
|
226fcd |
* tests/zgrep-abuse: New file, based on PoC by cleemy desu wayo.
|
|
|
226fcd |
* tests/Makefile.am (TESTS): Add it.
|
|
|
226fcd |
* NEWS: Mention the exploit.
|
|
|
226fcd |
The bug appears to have been present since the beginning.
|
|
|
226fcd |
---
|
|
|
226fcd |
tests/Makefile.am | 1 +
|
|
|
226fcd |
tests/zgrep-abuse | 41 +++++++++++++++++++++++++++++++++++++++++
|
|
|
226fcd |
3 files changed, 45 insertions(+)
|
|
|
226fcd |
create mode 100755 tests/zgrep-abuse
|
|
|
226fcd |
|
|
|
226fcd |
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
|
226fcd |
index d09672e..5f148d6 100644
|
|
|
226fcd |
--- a/tests/Makefile.am
|
|
|
226fcd |
+++ b/tests/Makefile.am
|
|
|
226fcd |
@@ -36,6 +36,7 @@ TESTS = \
|
|
|
226fcd |
trailing-nul \
|
|
|
226fcd |
zdiff \
|
|
|
226fcd |
zgrep-f \
|
|
|
226fcd |
+ zgrep-abuse \
|
|
|
226fcd |
zgrep-signal \
|
|
|
226fcd |
znew-k
|
|
|
226fcd |
|
|
|
226fcd |
diff --git a/tests/zgrep-abuse b/tests/zgrep-abuse
|
|
|
226fcd |
new file mode 100755
|
|
|
226fcd |
index 0000000..3e8a8f9
|
|
|
226fcd |
--- /dev/null
|
|
|
226fcd |
+++ b/tests/zgrep-abuse
|
|
|
226fcd |
@@ -0,0 +1,41 @@
|
|
|
226fcd |
+#!/bin/sh
|
|
|
226fcd |
+# Show how zgrep applied to a crafted file name may overwrite
|
|
|
226fcd |
+# a selected file with chosen content. Fixed in gzip-1.12.
|
|
|
226fcd |
+
|
|
|
226fcd |
+# Copyright (C) 2022 Free Software Foundation, Inc.
|
|
|
226fcd |
+
|
|
|
226fcd |
+# This program is free software: you can redistribute it and/or modify
|
|
|
226fcd |
+# it under the terms of the GNU General Public License as published by
|
|
|
226fcd |
+# the Free Software Foundation, either version 3 of the License, or
|
|
|
226fcd |
+# (at your option) any later version.
|
|
|
226fcd |
+
|
|
|
226fcd |
+# This program is distributed in the hope that it will be useful,
|
|
|
226fcd |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
226fcd |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
226fcd |
+# GNU General Public License for more details.
|
|
|
226fcd |
+
|
|
|
226fcd |
+# You should have received a copy of the GNU General Public License
|
|
|
226fcd |
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
226fcd |
+# limit so don't run it by default.
|
|
|
226fcd |
+
|
|
|
226fcd |
+. "${srcdir=.}/init.sh"; path_prepend_ ..
|
|
|
226fcd |
+
|
|
|
226fcd |
+: > z || framework_failure_
|
|
|
226fcd |
+echo test |gzip > 'z|
|
|
|
226fcd |
+p
|
|
|
226fcd |
+1s|.*|chosen-content|
|
|
|
226fcd |
+1w hacked
|
|
|
226fcd |
+etouch .\x2fhacked2
|
|
|
226fcd |
+d
|
|
|
226fcd |
+#
|
|
|
226fcd |
+#' || framework_failure_
|
|
|
226fcd |
+
|
|
|
226fcd |
+fail=0
|
|
|
226fcd |
+
|
|
|
226fcd |
+zgrep test z* > /dev/null
|
|
|
226fcd |
+
|
|
|
226fcd |
+# Before the fix, each of these would be created.
|
|
|
226fcd |
+test -f hacked && fail=1
|
|
|
226fcd |
+test -f hacked2 && fail=1
|
|
|
226fcd |
+
|
|
|
226fcd |
+Exit $fail
|
|
|
226fcd |
--
|
|
|
226fcd |
cgit v1.1
|
|
|
226fcd |
|