8000 glib: 2.88.4 + backport CVE-2026-16118 fix (xdgmime heap overflow), declare GithubRepo provenance by bryan-minimal · Pull Request #918 · gominimal/pkgs · GitHub
[go: up one dir, main page]

Skip to content

glib: 2.88.4 + backport CVE-2026-16118 fix (xdgmime heap overflow), declare GithubRepo provenance - #918

Merged
bryan-minimal merged 3 commits into
mainfrom
glib-cve-backport
Oct 22, 2026
Merged

bryan-minimal merged 3 commits into
mainfrom
glib-cve-backport

Conversation

@bryan-minimal
@bryan-minimal bryan-minimal commented Oct 17, 2026 •
Copy link
Copy Markdown
Member

What this fixes

CVE-2026-16118 is a heap overflow in GLib's bundled xdgmime, in _xdg_mime_magic_parse_magic_line() (gio/xdgmime/xdgmimemagic.c).

  • The bug. On little-endian hosts, each ~2 / ~4 magic value is byte-swapped in place. The write side does *((xdg_uint16_t *) matchlet->value + i): the cast is applied before the byte offset is added, so the write lands at i * word_size bytes. With value_length = 4 and word_size = 2, it writes 2 bytes past the end of the allocation.
  • How it's reached. A MIME magic file in a user-writable XDG data dir ($XDG_DATA_HOME/mime/magic) is enough. Any process that guesses a content type then parses it, for example through g_content_type_guess().
  • Upstream fix. GNOME/glib@ca75aff8, from MR !5286 "Update xdgmime", merged 2026-08-07. It closes glib#3992 and is on main only. It is not in 2.88.4 (2026-10-08): that release's security backports (!5394) leave gio/xdgmime/ byte-identical to 2.88.3, and xdgmimemagic.c:486 is still unparenthesized.
  • Debian. Debian fixes it as 2.88.3-3 with the same change. The security tracker also lists trixie 2.84.4-3~deb13u5.
  • Where it came from. The Ruby on Rails development support: chromedriver, Ruby 3.x, initdb locale fix, dev-loop tools #848 Debian-revision audit found it (gominimal/pkgmgr-rs#848).

Changes

  1. glib 2.88.3 → 2.88.4, for the !5394 security backports (unicode normalization overflows, gmarkup error paths, gvariant, socketaddress, giochannel, gresource, logging). The tarball's sha256 25fd169f…c5a8 matches download.gnome.org's glib-2.88.4.sha256sum; it is mirrored to gs://minimal-staging-archives (GCS md5 matches the download). The patch below still applies unchanged.
  2. CVE-2026-16118.patch. This is upstream's .patch for ca75aff8, unmodified: 4 lines, adding parentheses only. build.sh applies it with patch -Np1 under set -e, using the same pattern as wget and python, and patch is added to build_deps. The second commit in !5286, 4ef012af ("Check if caches are set before dumping them"), only touches debug-dump code and is not a security fix, so it is not carried.
  3. Regression test, run at build time against the installed gio. The bug changes behaviour, not only memory safety. With the cast in the wrong place, the second word is written out of bounds and never swapped in place.
    • The rule. The test writes a magic rule >0=ABCD~2 into a private XDG_DATA_HOME.
    • Patched. That rule becomes the byte string BADC, and gio info -a standard::content-type on a file starting with BADC returns application/x-cve-2026-16118.
    • Negative control (patch line disabled, fresh session). The output is 'application/octet-stream', and the build fails.
    • Endianness. The test only runs on little-endian hosts. Big-endian never swaps, so there is nothing to test there; both of our arches are LE.
  4. source_provenance = GithubRepo GNOME/glib. glib had no provenance, so the advisory pipeline never asked about it by identity (pkgmgr-rs#848). The canonical home is gitlab.gnome.org, and github.com/GNOME/glib is GNOME's own read-only mirror, with the same tags (2.88.3) and the same SHAs. I chose GithubRepo over 'Gitlab deliberately:
    • Precedent. libxml2 and libxslt already declare their GNOME GitHub mirrors.
    • The scanner's GithubRepo arm keeps the curated gnome:glib CPE identity (37 advisories in prod advisory_cpe). The Gitlab arm uses that identity only when the provenance purl has zero rows. pkg:generic/gitlab.gnome.org/gnome/glib has 46, so Gitlab would drop NVD-CPE coverage in exchange for records it cannot place by version (sc scan.rs:4334-4363).
    • Measured risk under GithubRepo. pkg:github/gnome/glib holds 31 records. All 31 carry an enumerated versions[] of bare tags, and none of them list 2.88.3, so none should newly flag at our version.

Verification

All runs were in a min session with the pkgbuild loadout, on arm64, re-run on 2.88.4 (Project version: 2.88.4):

  • Build. min package build --rebuild --verbose glib printed patching file gio/xdgmime/xdgmimemagic.c and CVE-2026-16118 probe content type: 'application/x-cve-2026-16118', then build finished.
  • Negative control. Run as described above; it fails, as it should. The session was re-activated before each run.
  • Checks. min check --packages glib passes everything.

Reviewer notes

  • CVE-2026-16118 is still unreachable after this PR. Prod advisories holds it only as an NVD record, with no CPE configuration and no purl rows. Once NVD adds gnome:glib CPEs, the curated identity will pick it up and report it as affected even though this patch is carried. That will need a VEX not_affected / inline_mitigations_already_exist until a release carries ca75aff8 (2.90, or a later 2.88.x backport; 2.88.4 does not).
  • The patch will drop itself. pkgmgr-rs#988's carried-patch check will remove it automatically on the first upstream release that contains ca75aff8.
  • Version checks may change tier. With GithubRepo provenance, the GitHub tag tier can now answer before the name-keyed gitlab handler. pkgmgr's GNOME_EVEN_ODD_STACK guard still rejects odd-minor devel releases at check_latest's single exit, whichever tier answers. It is still worth a pkgmgr check --package glib -v after merge. I could not run it here, because there is no local pkgmgr build.
  • Rebuild blast radius. 9 direct importers: at-spi2-core, atk, chromium-bin, chromium-headless-shell-bin, harfbuzz, libvips, next, pango, sshfs. 15 transitively, which adds agent-browser, ffmpeg, graphviz, libass, mermaid-cli, tamarin-prover.

Refs gominimal/pkgmgr-rs#848

🤖 Generated with Claude Code

_xdg_mime_magic_parse_magic_line in the bundled xdgmime
(gio/xdgmime/xdgmimemagic.c) byte-swaps `~2`/`~4` magic values on
little-endian hosts. The write side applied the cast before adding the
byte offset, so a 4-byte value with word size 2 wrote 2 bytes past the
end of matchlet->value. A MIME magic file in a user-writable XDG data
dir is enough to reach it, for example through g_content_type_guess().

The fix is GNOME/glib ca75aff83af9 (MR !5286, merged 2026-08-07), which
came after 2.88.3. Debian carries the same commit as 2.88.3-3.

- Carry the upstream commit verbatim and apply it fail-closed with
  `patch -Np1`.
- Add a build-time regression test using the installed `gio`. A magic
  rule `>0=ABCD~2` must classify a file that starts with "BADC". Without
  the patch the second word is never swapped (it is written out of bounds
  instead), so the file comes back as application/octet-stream and the
  build fails. Verified as a negative control.
- Declare source_provenance GithubRepo GNOME/glib, GNOME's own read-only
  mirror. This follows the libxml2/libxslt precedent, and it keeps the
  curated gnome:glib CPE identity in use (pkgmgr-rs#848).

Refs gominimal/pkgmgr-rs#848

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal requested a review from a team as a code owner October 17, 2026 19:03
@coderabbitai
coderabbitai Bot commented Oct 17, 2026 •
Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 14 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available. Your 58 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: gominimal/pkgs/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: fd4854f9-684d-4ce7-ac76-938540e1506b
📥 Commits

Reviewing files that changed from the base of the PR and between 0618acc and ad9e401.

📒 Files selected for processing: 3
  • packages/glib/CVE-2026-16118.patch
  • packages/glib/build.ncl
  • packages/glib/build.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@norrietaylor norrietaylor left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch is identical to upstream ca75aff83af9 and applies cleanly to 2.88.3, and the post-install gio info probe is fine. Two things:

  1. 2.88.4 is out (tagged 2026-10-08, before this PR was opened) with a batch of security backports (!5394: unicode normalization overflows, gmarkup error paths, gvariant, socketaddress, giochannel strncmp overread, gresource underflow, logging stack overflow). It does not contain the xdgmime fix: xdgmimemagic.c:486 is still unparenthesized there. So please bump to 2.88.4 and keep this patch. The note that "2.88.4 or 2.90" will fix it is wrong for 2.88.4.
  2. Provenance (build.ncl:64-73) deliberately declares the GitHub mirror, which AGENTS.md forbids. The canonical source is gitlab.gnome.org, and 'Gitlab with host can express that (see packages/psmisc, packages/tree). I understand the CPE-identity argument (libxml2/libxslt precedent), but that's a policy exception that needs an explicit decision, and if accepted it should be written into AGENTS.md. Holding approval until that's settled.

Generated by Claude Code

bryan-minimal and others added 2 commits October 21, 2026 19:07
2.88.4 (2026-10-08) brings the !5394 security backports but leaves
gio/xdgmime/ byte-identical to 2.88.3, so ca75aff83af9 is still needed
and applies unchanged. Tarball sha256 matches download.gnome.org's
sha256sum; mirrored to minimal-staging-archives.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal bryan-minimal changed the title glib: backport CVE-2026-16118 fix (xdgmime heap overflow), declare GithubRepo provenance glib: 2.88.4 + backport CVE-2026-16118 fix (xdgmime heap overflow), declare GithubRepo provenance Oct 22, 2026
@bryan-minimal
Copy link
Copy Markdown
Member Author

Thanks @norrietaylor.

  1. Bumped to 2.88.4, patch kept (ad9e401, on top of a merge of main). You're right that 2.88.4 doesn't fix it: gio/xdgmime/ is byte-identical between the 2.88.3 and 2.88.4 tarballs, so line 486 is unchanged and the patch applies as-is.
    • The sha256 matches download.gnome.org's sha256sum.
    • I corrected the wrong "2.88.4 or 2.90" note in build.ncl and the PR body.
    • Re-verified in fresh pkgbuild sessions on 2.88.4. Patched, the probe returns application/x-cve-2026-16118 and the build finishes. With the patch line removed, it returns application/octet-stream and the build fails.
  2. Provenance: agreed that it's a policy exception, not something to decide inside this PR. I've left it unchanged for now and passed the decision (accept the GNOME-mirror exception in AGENTS.md, or move to 'Gitlab with host = "gitlab.gnome.org") to Bryan. I'll update this PR once that's settled.

🤖 Generated with Claude Code

@norrietaylor norrietaylor left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. Both technical points from my last review are addressed:

  • It's on 2.88.4, and the xdgmime patch is kept. 2.88.4's gio/xdgmime/ is byte-identical to 2.88.3's, so the patch is still needed.
  • The patch applies cleanly, before meson and under set -e, and the negative control is meaningful.
  • The incorrect "2.88.4 will fix it" note is gone.

I'm deferring to your judgement on provenance and accepting the GNOME GitHub mirror as declared. Please follow up with an AGENTS.md entry for official upstream mirrors (glib, libxml2, libxslt), so the three are covered by policy rather than precedent. The build.ncl:70 comment cites pkgmgr-rs#848, which is the audit, not a policy, so that entry would be the right reference.

Nits:

  • I could only verify the 2.88.4 sha256 against the staging copy; GNOME's own sha256sum couldn't be checked from my environment.
  • The build.sh:35-36 comment says "on big-endian hosts no swap happens", but upstream tests #if LITTLE_ENDIAN, which is always defined with glibc's <endian.h>. That's moot on our arches; just soften the wording.

Generated by Claude Code

@bryan-minimal
bryan-minimal added this pull request to the merge queue Oct 22, 2026
Merged via the queue into main with commit 735d135 Oct 22, 2026
11 checks passed
@bryan-minimal
bryan-minimal deleted the glib-cve-backport branch October 22, 2026 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0