public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/unshield] f43: Validate the file table against the header size
@ 2026-10-18 16:04 Peter Lemenkov
0 siblings, 0 replies; only message in thread
From: Peter Lemenkov @ 2026-10-18 16:04 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/unshield
Branch : f43
Commit : f76ee6f6981c203ca3f5cd7908cde912f363ca37
Author : Peter Lemenkov <lemenkov@gmail.com>
Date : 2026-10-18T17:28:59+02:00
Stats : +72/-1 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/unshield/c/f76ee6f6981c203ca3f5cd7908cde912f363ca37?branch=f43
Log:
Validate the file table against the header size
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
diff --git a/0001-Validate-the-file-table-against-the-header-size.patch b/0001-Validate-the-file-table-against-the-header-size.patch
new file mode 100644
index 0000000..ea206b6
--- /dev/null
+++ b/0001-Validate-the-file-table-against-the-header-size.patch
@@ -0,0 +1,70 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov@gmail.com>
+Date: Sun, 18 Oct 2026 17:05:00 +0200
+Subject: [PATCH] Validate the file table against the header size
+
+unshield_get_file_table() took the cabinet descriptor offset, the file
+table offset and the directory/file counts directly from the cabinet
+file and then read (directory_count + file_count) 32-bit words starting
+at data + cab_descriptor_offset + file_table_offset, without checking
+that this range stays within the header buffer. A cabinet with an
+out-of-range offset or an oversized file or directory count makes the
+loop read past the end of the allocated buffer.
+
+Compute the start offset and the number of bytes the loop will read in
+64-bit arithmetic so the additions cannot wrap, reject an empty table,
+and reject any table that would start past the buffer or extend beyond
+it before reading. The allocation result is now checked as well.
+
+Reported-by: haind-pwn (VulnCheck)
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/lib/libunshield.c b/lib/libunshield.c
+index 7b8edf2..c98fed9 100644
+--- a/lib/libunshield.c
++++ b/lib/libunshield.c
+@@ -182,13 +182,37 @@ static bool unshield_get_cab_descriptor(Header* header)
+
+ static bool unshield_get_file_table(Header* header)
+ {
+- uint8_t* p = header->data +
+- header->common.cab_descriptor_offset +
+- header->cab.file_table_offset;
+- int count = header->cab.directory_count + header->cab.file_count;
+- int i;
+-
++ uint64_t start = (uint64_t)header->common.cab_descriptor_offset +
++ (uint64_t)header->cab.file_table_offset;
++ uint64_t count = (uint64_t)header->cab.directory_count +
++ (uint64_t)header->cab.file_count;
++ uint64_t bytes = count * (uint64_t)sizeof(uint32_t);
++ uint8_t* p;
++ uint64_t i;
++
++ if (count == 0)
++ {
++ unshield_error("File table is empty");
++ return false;
++ }
++
++ if (start > header->size || bytes > (uint64_t)header->size - start)
++ {
++ unshield_error("File table (offset %lu, %lu bytes) is out of bounds "
++ "for header of %lu bytes",
++ (unsigned long)start, (unsigned long)bytes,
++ (unsigned long)header->size);
++ return false;
++ }
++
++ p = header->data + start;
++
+ header->file_table = calloc(count, sizeof(uint32_t));
++ if (!header->file_table)
++ {
++ unshield_error("Failed to allocate file table");
++ return false;
++ }
+
+ for (i = 0; i < count; i++)
+ {
diff --git a/unshield.spec b/unshield.spec
index ab27f0c..4431f81 100644
--- a/unshield.spec
+++ b/unshield.spec
@@ -6,7 +6,8 @@ SourceLicense: MIT and LicenseRef-RSA
License: MIT
URL: https://github.com/twogood/unshield
VCS: git:%{url}.git
-Source0: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
+Source: %{url}/archive/%{version}/%{name}-%{version}.tar.gz
+Patch: 0001-Validate-the-file-table-against-the-header-size.patch
BuildRequires: gcc
BuildRequires: openssl-devel
BuildRequires: zlib-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-18 16:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-18 16:04 [rpms/unshield] f43: Validate the file table against the header size Peter Lemenkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox