Bug: OSS-Fuzz: Deny an unreasonably large header to avoid OOM (PR #26607)

27 views
Skip to first unread message

Arthur Chan

unread,
Jun 17, 2026, 7:15:14 AM (7 days ago) Jun 17
to wx-...@googlegroups.com, Subscribed

This PR adds a guard to deny an unreasonably large header to avoid possible OOM in wxTarInputStream processing, discovered by OSS-Fuzz fuzzer (#26588).


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/26607

Commit Summary

  • 27e7176 Bug: OSS-Fuzz: Decline an unreasonably large header to avoid OOM

File Changes

(1 file)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607@github.com>

VZ

unread,
Jun 17, 2026, 9:19:05 AM (7 days ago) Jun 17
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26607)

Thanks, I don't know enough about (GNU?) TAR format to be sure if this limitation can be a problem in practice. Does anybody have any example tar files using extended header? I've tried a few of tarballs I had lying around but none of them uses it at all, so I couldn't see what could its reasonable size be like.

Maybe bump it up to 10MiB? This should be enough and still shouldn't be a problem to allocate on any modern system. We could also add a static wxTarInputStream function to set this.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/c4730633545@github.com>

Arthur Chan

unread,
Jun 17, 2026, 9:33:48 AM (7 days ago) Jun 17
to wx-...@googlegroups.com, Subscribed
arthurscchan left a comment (wxWidgets/wxWidgets#26607)

I don't think we care about legitimate tar files. But since the widget itself is meant to process tar stream and thus it be could possible to have an adversary just pass in a random stream claimed to be tar file (not necessary to be a real tar) but with extremely large extended header and cause the OOM.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/c4730797674@github.com>

VZ

unread,
Jun 17, 2026, 10:15:35 AM (7 days ago) Jun 17
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26607)

Err, we do care about legitimate tar files. In case I wasn't clear, my concern was that we could now start rejecting valid (legitimate) tar files which have extended header bigger than 1MiB. I don't know how likely is this to happen but it doesn't seem completely impossible, something like a Boost tarball can contain thousands of files with very long names.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/c4731273292@github.com>

Arthur Chan

unread,
Jun 17, 2026, 10:18:52 AM (7 days ago) Jun 17
to wx-...@googlegroups.com, Subscribed
arthurscchan left a comment (wxWidgets/wxWidgets#26607)

er... true. I am now double checking about the standard for tar ball extended headers. Sorry for the rush conclusion.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/c4731330980@github.com>

Ian McInerney

unread,
Jun 17, 2026, 10:43:06 AM (7 days ago) Jun 17
to wx-...@googlegroups.com, Subscribed
imciner2 left a comment (wxWidgets/wxWidgets#26607)

I looked in the POSIX 1.2001 standard, and there is nothing stating how long an extended header can be - it is basically left as a free field in terms of length.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/c4731685710@github.com>

VZ

unread,
Jun 17, 2026, 11:49:36 AM (7 days ago) Jun 17
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26607)

Thanks Ian, this confirms my suspicion that there is no universally acceptable limit here. But I still think adding wxTarInputStream::SetMaxExtendedHeaderSize() and setting it to 10MiB by default would be a reasonable thing to do.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/c4732464239@github.com>

Arthur Chan

unread,
Jun 17, 2026, 1:30:36 PM (6 days ago) Jun 17
to wx-...@googlegroups.com, Subscribed
arthurscchan left a comment (wxWidgets/wxWidgets#26607)

Thanks for confirming. Do you want me help do the changes in this PR following the 10MB assumption you mentioned?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/c4733440189@github.com>

Miguel Gimenez

unread,
Jun 18, 2026, 1:07:38 PM (5 days ago) Jun 18
to wx-...@googlegroups.com, Subscribed
wh11204 left a comment (wxWidgets/wxWidgets#26607)

I just want to remark that the last modification time field in the given header (bytes 136 to 147, Unix timestamp in octal) contains a '@', obviously not a valid octal digit. I do not know if the code uses this field at all, but it could possibly crash.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/c4744354850@github.com>

VZ

unread,
Jun 23, 2026, 2:04:36 PM (11 hours ago) Jun 23
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26607)

Thanks for confirming. Do you want me help do the changes in this PR following the 10MB assumption you mentioned?

I am still not sure what to do about this, but the best idea I have remains to

  1. Restrict this to 10MiB (or any other arbitrary but pretty high number).
  2. Add a static function allowing to change this limit if the application ever really needs it.

If you could please do it, it would be great, of course. And if you can think of something better to do, it would be even better :-)


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/c4782069217@github.com>

VZ

unread,
Jun 23, 2026, 2:05:38 PM (11 hours ago) Jun 23
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26607)

I just want to remark that the last modification time field in the given header (bytes 136 to 147, Unix timestamp in octal) contains a '@', obviously not a valid octal digit. I do not know if the code uses this field at all, but it could possibly crash.

Sorry, I hardly know this code at all but if you think it's a bug, please open a separate issue for it, I don't think it's related to anything being discussed here (other than in the sense that the fuzzer should be able to find this bug as well).


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/c4782077482@github.com>

Arthur Chan

unread,
Jun 23, 2026, 2:52:08 PM (10 hours ago) Jun 23
to wx-...@googlegroups.com, Push

@arthurscchan pushed 1 commit.

  • 790d6ea Add static functions and restrain allocation


View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/before/27e71765cf1092413db28318bc35f4a84d4033d4/after/790d6eadb798988d2546127377ca380d5fd763d8@github.com>

Arthur Chan

unread,
Jun 23, 2026, 3:14:24 PM (10 hours ago) Jun 23
to wx-...@googlegroups.com, Subscribed
arthurscchan left a comment (wxWidgets/wxWidgets#26607)

I have updated the logic, now the logic rejects extended headers larger than a configurable cap (default 10 MiB, settable via wxTarInputStream::SetMaxExtendedHeaderSize()) instead of allocating the declared size up front. I also adds a check of size capped to 64-bit value before narrowing to size_t, and the allocation is clamped
to the bytes actually available on streams.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/c4782610517@github.com>

VZ

unread,
Jun 23, 2026, 3:18:30 PM (10 hours ago) Jun 23
to wx-...@googlegroups.com, Subscribed

@vadz requested changes on this pull request.

Thanks, this looks good but we need to document the new functions in interface/wx/tarstrm.h, could you please do this (please use @since 3.3.3 in their documentation to indicate that they're new)? TIA!


In src/common/tarstrm.cpp:

> @@ -909,8 +912,26 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
     if (!recs)
         recs = new wxTarHeaderRecords;
 
+    // read the declared size as 64-bit before narrowing, to avoid truncation
+    const wxTarNumber declared = m_hdr->GetOctal(TAR_SIZE);
+
+    // reject an unreasonably large extended header to avoid excessive allocation
+    if (declared < 0 || declared > (wxTarNumber)GetMaxExtendedHeaderSize()) {
+        wxLogWarning(_("invalid data in extended tar header"));
+        return false;
+    }
+
+    size_t len = (size_t)declared;

If we did this above, we could compare it with GetMax...Size() without a cast (< 0 would become unnecessary).


In src/common/tarstrm.cpp:

> @@ -909,8 +912,26 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
     if (!recs)
         recs = new wxTarHeaderRecords;
 
+    // read the declared size as 64-bit before narrowing, to avoid truncation
+    const wxTarNumber declared = m_hdr->GetOctal(TAR_SIZE);
+
+    // reject an unreasonably large extended header to avoid excessive allocation
+    if (declared < 0 || declared > (wxTarNumber)GetMaxExtendedHeaderSize()) {

Minor, but in wx coding style braces should be on their own line:

⬇️ Suggested change
-    if (declared < 0 || declared > (wxTarNumber)GetMaxExtendedHeaderSize()) {
+    if (declared < 0 || declared > (wxTarNumber)GetMaxExtendedHeaderSize())
+    {

In src/common/tarstrm.cpp:

> @@ -909,8 +912,26 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
     if (!recs)
         recs = new wxTarHeaderRecords;
 
+    // read the declared size as 64-bit before narrowing, to avoid truncation
+    const wxTarNumber declared = m_hdr->GetOctal(TAR_SIZE);
+
+    // reject an unreasonably large extended header to avoid excessive allocation
+    if (declared < 0 || declared > (wxTarNumber)GetMaxExtendedHeaderSize()) {
+        wxLogWarning(_("invalid data in extended tar header"));

This is an error and not a warning as the stream can't be used and I think it would be worth giving more details about the problem, i.e.:

⬇️ Suggested change
-        wxLogWarning(_("invalid data in extended tar header"));
+        wxLogError(_("Extended tar header size %zu is greater than maximum allowed."), len);

In src/common/tarstrm.cpp:

> @@ -909,8 +912,26 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
     if (!recs)
         recs = new wxTarHeaderRecords;
 
+    // read the declared size as 64-bit before narrowing, to avoid truncation
+    const wxTarNumber declared = m_hdr->GetOctal(TAR_SIZE);
+
+    // reject an unreasonably large extended header to avoid excessive allocation
+    if (declared < 0 || declared > (wxTarNumber)GetMaxExtendedHeaderSize()) {
+        wxLogWarning(_("invalid data in extended tar header"));
+        return false;
+    }
+
+    size_t len = (size_t)declared;
+
+    // don't allocate more than the stream can actually provide

Sorry, why do we need this? Allocating up to 10MiB shouldn't be a huge problem and we hopefully get an error if we read less data than expected (if we don't, we should fix this).

And if we really want to check for this, we should return an error if there is not enough data in the file as this means that it is corrupted, not allocate less.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/review/4556341686@github.com>

Arthur Chan

unread,
Jun 23, 2026, 5:33:27 PM (7 hours ago) Jun 23
to wx-...@googlegroups.com, Push

@arthurscchan pushed 1 commit.

  • 457278e Add static functions and restrain allocation


View it on GitHub or unsubscribe.


Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/before/790d6eadb798988d2546127377ca380d5fd763d8/after/457278e03c3fe938f1b015e0ae41005478d974fa@github.com>

Arthur Chan

unread,
Jun 23, 2026, 5:33:36 PM (7 hours ago) Jun 23
to wx-...@googlegroups.com, Subscribed

@arthurscchan commented on this pull request.


In src/common/tarstrm.cpp:

> @@ -909,8 +912,26 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
     if (!recs)
         recs = new wxTarHeaderRecords;
 
+    // read the declared size as 64-bit before narrowing, to avoid truncation
+    const wxTarNumber declared = m_hdr->GetOctal(TAR_SIZE);
+
+    // reject an unreasonably large extended header to avoid excessive allocation
+    if (declared < 0 || declared > (wxTarNumber)GetMaxExtendedHeaderSize()) {
+        wxLogWarning(_("invalid data in extended tar header"));
+        return false;
+    }
+
+    size_t len = (size_t)declared;

Changed.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/review/4557252723@github.com>

Arthur Chan

unread,
Jun 23, 2026, 5:33:43 PM (7 hours ago) Jun 23
to wx-...@googlegroups.com, Subscribed

@arthurscchan commented on this pull request.


In src/common/tarstrm.cpp:

> @@ -909,8 +912,26 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
     if (!recs)
         recs = new wxTarHeaderRecords;
 
+    // read the declared size as 64-bit before narrowing, to avoid truncation
+    const wxTarNumber declared = m_hdr->GetOctal(TAR_SIZE);
+
+    // reject an unreasonably large extended header to avoid excessive allocation
+    if (declared < 0 || declared > (wxTarNumber)GetMaxExtendedHeaderSize()) {

Changed.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/review/4557253884@github.com>

Arthur Chan

unread,
Jun 23, 2026, 5:34:16 PM (7 hours ago) Jun 23
to wx-...@googlegroups.com, Subscribed

@arthurscchan commented on this pull request.


In src/common/tarstrm.cpp:

> @@ -909,8 +912,26 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
     if (!recs)
         recs = new wxTarHeaderRecords;
 
+    // read the declared size as 64-bit before narrowing, to avoid truncation
+    const wxTarNumber declared = m_hdr->GetOctal(TAR_SIZE);
+
+    // reject an unreasonably large extended header to avoid excessive allocation
+    if (declared < 0 || declared > (wxTarNumber)GetMaxExtendedHeaderSize()) {
+        wxLogWarning(_("invalid data in extended tar header"));
+        return false;
+    }
+
+    size_t len = (size_t)declared;
+
+    // don't allocate more than the stream can actually provide

True, it is more like defensive in my original though. But I do agree it is not needed. Removed.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/review/4557257397@github.com>

Arthur Chan

unread,
Jun 23, 2026, 5:34:24 PM (7 hours ago) Jun 23
to wx-...@googlegroups.com, Subscribed

@arthurscchan commented on this pull request.


In src/common/tarstrm.cpp:

> @@ -909,8 +912,26 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
     if (!recs)
         recs = new wxTarHeaderRecords;
 
+    // read the declared size as 64-bit before narrowing, to avoid truncation
+    const wxTarNumber declared = m_hdr->GetOctal(TAR_SIZE);
+
+    // reject an unreasonably large extended header to avoid excessive allocation
+    if (declared < 0 || declared > (wxTarNumber)GetMaxExtendedHeaderSize()) {
+        wxLogWarning(_("invalid data in extended tar header"));

Fixed.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26607/review/4557258194@github.com>

Reply all
Reply to author
Forward
0 new messages