Follow @Openwall on Twitter for new release announcements and other news
[<prev] [day] [month] [year] [list]
Message-ID: <20261203232149.GA12978@openwall.com>
Date: Fri, 4 Dec 2026 00:21:49 +0100
From: Solar Designer <solar@...nwall.com>
To: oss-security@...ts.openwall.com
Cc: sakith lomitha <sakithlomitha16@...il.com>
Subject: GRUB: 3 heap OOB issues in nilfs2/f2fs/erofs filesystem parsers

Hi,

Sakith and/or his AI assistant erroneously sent the below report to the
public grub-devel list and the private distros list at once, and also
requested an embargo beyond the allowed 14 days maximum.  The grub-devel
posting appears at:

https://lists.gnu.org/archive/html/grub-devel/2026-12/threads.html

I also include two of the replies from the distros list thread.  The
actual issues are being looked into by GRUB upstream.

The distros list 14 days maximum may not be enough for issues affecting
the Secure Boot chain.  So they should be reported to upstream projects
first (such as GRUB or shim) and only brought to distros when it's at
most 14 days left until planned public disclosure and there's confidence
this would not be extended.

In fact, the current distros list instructions suggest this as a general
best practice:

"Please consider notifying upstream projects/developers of the affected
software, other affected distro vendors, and/or affected Open Source
projects before notifying one of these mailing lists in order to readily
have fixes for the distributions to apply and to ensure that these other
parties are OK with the maximum embargo period that would apply (if not,
you may delay your notification to the mailing list)."

Alexander

On Thu, Dec 03, 2026 at 10:25:43AM +0530, sakith lomitha wrote:
> # GRUB2 Filesystem Parser Security Audit ??? Vendor Report
> 
> **Three novel, unfixed memory-corruption vulnerabilities in upstream GNU GRUB2**
> Discovered by static analysis and proven with a real ASAN-instrumented build of upstream HEAD.
> 
> ---
> 
> ## 1. Executive Summary
> 
> An out-of-bounds read/write audit of the GNU GRUB2 filesystem parsers at upstream HEAD
> (`7aa2860835006cc5df95f84d8d504c2c1fa6a4b5`, 2026-11-30, GRUB 2.17 dev, the new
> `gitlab.freedesktop.org/gnu-grub/grub` home) identified **three vulnerabilities**, all
> reachable from a crafted or corrupted filesystem image at boot:
> 
> | # | Module | Type | Primitive | CWE | CVSS 3.1 (AV:L) |
> |---|--------|------|-----------|-----|-----------------|
> | V1 | `fs/nilfs2.c` ??? `grub_nilfs2_read_symlink` | Integer wrap ??? **heap OOB write** | 1-byte write before a heap chunk (heap-metadata corruption) | CWE-190 / CWE-787 | 7.8 High `AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H` |
> | V2 | `fs/f2fs.c` ??? `grub_f2fs_check_dentries` | **Heap OOB read** | Up to 246 bytes read past a 4096-byte heap buffer | CWE-125 | 5.5 Medium `AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N` |
> | V3 | `fs/erofs.c` ??? `erofs_iterate_dir` | **Heap OOB read** | Up to 6 bytes read past a 4096-byte heap buffer | CWE-125 | 5.5 Medium `AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N` |
> 
> Every finding was **proven at runtime** with AddressSanitizer builds of unmodified upstream
> code (`--with-platform=emu`, `grub-fstest`), and every finding is **absent from all public
> GRUB2 CVE rounds**, including the comprehensive 2025-02-18 disclosure (00/73) that fixed the
> same bug class in ufs and reiserfs but missed nilfs2. A remediation patch for all three
> findings is attached; the patch was applied, rebuilt, and re-verified against the PoCs and
> against valid filesystem images.
> 
> **Threat model.** All three flaws are triggered by mounting/reading a filesystem that the
> attacker controls: an infected USB stick, a malicious disk image, or a corrupted ESP
> partition. GRUB parses such filesystems **before any OS authentication**, in a privileged
> UEFI/BIOS environment with no ASLR, no stack canary in most builds, and a tiny, easily
> fingerprinted heap ??? the classic BootHole pre-OS attack surface. An OOB write of heap
> metadata in this environment is a plausible secure-boot bypass primitive; the OOB reads
> leak adjacent heap contents into path strings that can be printed to the console or used
> in further parsing.
> 
> ---
> 
> ## 2. Audit Scope and Method
> 
> **Target.** Upstream GNU GRUB2, master branch, commit
> `7aa2860835006cc5df95f84d8d504c2c1fa6a4b5` ("video: Don't overwrite flags each time we
> attempt to set mode", 2026-11-30 20:01:25 +0000), cloned from the current upstream home
> `https://gitlab.freedesktop.org/gnu-grub/grub.git` (the project moved from
> git.savannah.gnu.org to FreeDesktop GitLab in March 2026; `configure.ac` reports version
> 2.17).
> 
> **Pipeline.** The audit followed the full chain requested for vendor-grade evidence:
> 
> 1. **Clone & pin** ??? full-history clone; HEAD recorded above.
> 2. **Static analysis sweep of all of `grub-core`** (749 C files, priority on the 42
>    filesystem parsers, ~29.5k lines):
>    - Pass 1: ranked pattern-density sweep (1,538 hits across 311 files) for
>      on-disk-length indexing, `grub_malloc` of disk-derived sizes, unchecked
>      `memcpy`/`strnlen`, disk reads into fixed buffers.
>    - Pass 2: targeted extraction of allocation-from-disk and fixed-stack-buffer writes
>      (63 hits).
>    - Pass 3: `gcc -fanalyzer` (GCC 14.2.0) over 246 parser files ??? produced only
>      NULL-deref noise, confirming the need for manual review.
>    - Manual line-by-line review of the top candidates in `fs/` (erofs, f2fs, nilfs2,
>      affs, jfs, romfs, squash4, udf, bfs, sfs, archelp, tar, xfs, ext2, hfs+, reiserfs),
>      cross-checked against the `grub_add/grub_sub/grub_mul` hardening applied during the
>      2021???2025 security rounds.
> 3. **Minimal real build** ??? `./bootstrap` with pinned gnulib (`9f48fb99`), configured
>    `--with-platform=emu --disable-werror --disable-nls`, toolchain assembled from
>    bison 3.8.2 / flex 2.6.4 / gettext 0.23.1 / gawk 5.2.1; `make` completed with 234
>    modules, `kernel.img`, `grub-fstest`, `grub-probe` (the emu userspace harness that
>    statically links the real filesystem modules).
> 4. **ASAN build** ??? second tree, same sources, `CFLAGS="-g -O1 -fsanitize=address
>    -fno-omit-frame-pointer"`; `grub-fstest` rebuilt with ASAN instrumentation of the
>    **unmodified** upstream parser code.
> 5. **Runtime proof, two harnesses** ??? three PoC images (one per finding) fed to
>    (a) ASAN `grub-fstest` (grub_file_open path), and (b) the **real GRUB shell**
>    (`grub-emu`, ASAN build of the same commit) driven with stock boot-time commands
>    (`loopback`, `ls`, `cat`, `configfile`, `search --file`/`search.file`); each
>    produced a definitive `heap-buffer-overflow` report (2 READ, 1 WRITE) with the
>    exact upstream file:line in the trace (??6).
> 6. **Novelty confirmation** ??? upstream `git log` per finding (no fix commits since
>    module introduction) + public advisory cross-check (??7).
> 7. **Remediation** ??? minimal patch per finding, applied to the ASAN tree, rebuilt, and
>    re-tested: all PoCs neutralized, all valid images (f2fs with symlinks, erofs small
>    and large, nilfs2) behave identically to the unpatched build.
> 
> ---
> 
> ## 3. Vulnerability Details
> 
> ### V1 ??? nilfs2: integer overflow in `grub_nilfs2_read_symlink` ??? heap out-of-bounds WRITE
> 
> **Location.** `grub-core/fs/nilfs2.c:886-898`
> (introduced with the nilfs2 driver, never hardened).
> 
> **Root cause.**
> 
> ```c
> symlink = grub_malloc (grub_le_to_cpu64 (diro->inode.i_size) + 1);   /* :886 */
> if (!symlink)
>   return 0;
> 
> grub_nilfs2_read_file (diro, 0, 0, 0,
>                        grub_le_to_cpu64 (diro->inode.i_size), symlink);
> ...
> symlink[grub_le_to_cpu64 (diro->inode.i_size)] = '\0';               /* :898 */
> ```
> 
> `i_size` is a fully attacker-controlled `grub_uint64_t` read from the symlink inode.
> With `i_size = 0xffffffffffffffff` the `+ 1` wraps to **0**; `grub_malloc(0)` returns a
> minimum-size chunk (GRUB's allocator rounds to a 4-byte-granularity cell, malloc(0)
> succeeds). The subsequent terminator write `symlink[UINT64_MAX]` then computes
> `symlink + 0xffffffffffffffff`, which wraps to `symlink - 1`: a one-byte write
> immediately **before** the allocated chunk, corrupting GRUB heap metadata. The block-copy
> loop in `grub_fshelp_read_file` self-neutralizes for this exact value (`len + pos`
> wraps so `blockcnt` becomes 0), but the terminator write alone is the corruption
> primitive; values of `i_size` just below the wrap boundary keep the loop active with a
> grossly undersized destination buffer.
> 
> This is precisely the symlink-size-overflow class that the 2025-02-18 GRUB2 security
> round fixed for **ufs** (CVE-2025-0677) and **reiserfs** (CVE-2025-0684) ??? nilfs2 was
> missed by that sweep. The drivers fixed in that round all received the same treatment
> proposed in ??5: reject targets longer than `PATH_MAX` and compute the size with
> `grub_add()`.
> 
> **Reachability.** `grub_file_open` on any path traversing a symlink
> (e.g. `cat /s`, loading `/vmlinuz` through a symlink, `grub-fstest`, `grub-mount`).
> The nilfs2 module is built into GRUB for all major distro builds and is auto-probed at
> boot.
> 
> **Runtime proof (ASAN, unmodified upstream build).**
> 
> ```
> ==32699==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x5020000001cf
> WRITE of size 1 at 0x5020000001cf thread T0
>     #0 grub_nilfs2_read_symlink grub-core/fs/nilfs2.c:898
>     #1 find_file grub-core/fs/fshelp.c:294
>     #2 grub_fshelp_find_file_real grub-core/fs/fshelp.c:294
>     #3 grub_fshelp_find_file grub-core/fs/fshelp.c:345
>     #4 grub_nilfs2_open grub-core/fs/nilfs2.c:1011
>     #5 grub_file_open grub-core/kern/file.c:115
> ...
> 0x5020000001cf is located 1 bytes BEFORE 1-byte region   ??? heap chunk header
> allocated by thread T0 here:
>     #1 grub_malloc grub-core/kern/emu/mm.c:42
>     #2 grub_nilfs2_read_symlink grub-core/fs/nilfs2.c:897
> ```
> 
> **PoC.** `nilfs2-oob.img` (45,056 bytes) ??? a hand-crafted nilfs2 image implementing the
> minimal on-disk chain GRUB walks (superblock ??? segment summary ??? super root ???
> checkpoint ??? ifile ??? inodes), containing one root-dir dirent `"s"` of type SYMLINK
> pointing at inode 10, whose `i_size` is `0xffffffffffffffff`. Command:
> `grub-fstest nilfs2-oob.img cat /s`.
> 
> **Impact.** Heap metadata corruption in pre-OS context: the write clobbers the size/magic
> field of the preceding chunk, which GRUB's allocator dereferences on every subsequent
> `grub_free`/`grub_malloc`. Controlled follow-up allocations (abundant during filesystem
> parsing) can turn this into arbitrary write, enabling secure-boot bypass. Rated
> **High 7.8** (same scoring rationale as CVE-2025-0677).
> 
> ---
> 
> ### V2 ??? f2fs: unbounded dentry name copy in `grub_f2fs_check_dentries` ??? heap OOB READ
> 
> **Location.** `grub-core/fs/f2fs.c:1075` (present since F2FS support was added,
> commit `71f9e4ac4`).
> 
> **Root cause.**
> 
> ```c
> name_len = grub_le_to_cpu16 (ctx->dentry[i].name_len);      /* :1056 */
> if (name_len == 0 || name_len >= F2FS_NAME_LEN)             /* only < 255 checked */
>   return 0;
> ...
> grub_memcpy (filename, ctx->filename[i], name_len);         /* :1075 */
> ```
> 
> A f2fs directory block is 4096 bytes:
> `bitmap[27] | reserved[3] | dentry[214??11] @30 | filename[214??8] @2384`.
> Each dentry slot `i` owns an 8-byte name slot at block offset `2384 + 8??i`; the array
> ends exactly at 4096. `name_len` (1???254, disk-controlled) is validated only against
> `F2FS_NAME_LEN`, **never against the bytes remaining in the block**. A dentry in the last
> slot (i = 213, name area at 4088???4095) with `name_len = 254` makes `grub_memcpy` read
> block bytes 4088???4341 ??? **246 bytes past the end** of the `grub_zalloc(F2FS_BLKSIZE)`
> buffer allocated in `grub_f2fs_iterate_dir` (f2fs.c:1176). The copied bytes become the
> filename handed to the fs layer (and printed by `ls`), directly exposing heap contents.
> 
> **Runtime proof (ASAN, unmodified upstream build).**
> 
> ```
> ==32697==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x521000015100
> READ of size 8 at 0x521000015100 thread T0
>     #0 memmove_fwd grub-core/kern/misc.c:130
>     #1 grub_memmove grub-core/kern/misc.c:194
>     #2 grub_memcpy include/grub/misc.h:109
>     #3 grub_f2fs_check_dentries grub-core/fs/f2fs.c:1075
>     #4 grub_f2fs_iterate_dir grub-core/fs/f2fs.c:1194
>     #5 grub_f2fs_dir grub-core/fs/f2fs.c:1254
> ...
> 0x521000015100 is located 0 bytes AFTER 4096-byte region
> allocated by thread T0 here:
>     #1 grub_malloc grub-core/kern/emu/mm.c:42
>     #2 grub_zalloc grub-core/kern/emu/mm.c:53
>     #3 grub_f2fs_iterate_dir grub-core/fs/f2fs.c:1176
> ```
> 
> **PoC.** `f2fs-oob.img` (64 MiB, sparse-friendly) ??? produced with real `mkfs.f2fs` +
> `sload.f2fs` (valid fs with symlinks), then one 2-byte patch: dentry slot 213 in the
> root dentry block (block 5632) gets `name_len = 0x00FE`, its bitmap bit set, `ino = 5`,
> `file_type = REG`. Command: `grub-fstest f2fs-oob.img ls /`.
> 
> **Impact.** Heap over-read whose bytes are surfaced as filenames (console output, further
> path matching). In the pre-OS environment GRUB's heap routinely holds other filesystem
> structures, module lists, and configuration strings ??? information disclosure of
> adjacent heap contents. Rated **Medium 5.5** (matching CVE-2025-0678-class OOB reads).
> 
> ---
> 
> ### V3 ??? erofs: dirent walk bound in `erofs_iterate_dir` ??? heap OOB READ
> 
> **Location.** `grub-core/fs/erofs.c:590-622` (present since EROFS support was added,
> commit `9d603061a`, 2024 ??? the newest driver in tree and the least audited).
> 
> **Root cause.**
> 
> ```c
> nameoff = grub_le_to_cpu16 (de->nameoff);                  /* :581 */
> if (nameoff < sizeof (struct grub_erofs_dirent) || nameoff >= maxsize)
>   goto not_found;                                           /* only 12 <= nameoff < maxsize */
> 
> end = (struct grub_erofs_dirent *) ((grub_uint8_t *) de + nameoff);
> while (de < end)                                            /* walk bound = name area start */
>   ...
>   de_name = (char *) buf + nameoff;
>   if (de + 1 >= end)                                        /* byte-wise last-entry test */
>     de_namelen = grub_erofs_strnlen (...);
>   else
>     grub_sub (grub_le_to_cpu16 (de[1].nameoff), nameoff, &de_namelen);   /* :622 OOB */
> ```
> 
> The walk bound `end = buf + nameoff` only guarantees that dirent **headers start**
> before the name area. Nothing requires a header (12 bytes) to **fit** there:
> 
> - With a block-sized directory (`maxsize = blocksz = 4096`) and `nameoff = 4094`
>   (passes `12 <= nameoff < 4096`), `end = buf + 4094`. The dirent at `buf + 4080`
>   satisfies `de + 1 (4092) < end (4094)` byte-wise, so the else-branch reads
>   `de[1].nameoff` at bytes 4100???4101 ??? **4 bytes past** the `grub_malloc(blocksz)`
>   buffer from erofs.c:567.
> - With `nameoff = 4095`, the final header read `de->nid`/`de->nameoff` at `buf + 4092`
>   spans 4092???4103 ??? up to **6 bytes past** the buffer.
> 
> The erofs driver also has a second, lower-severity instance: for directories smaller
> than one block (`maxsize = i_size`), the same walk can read bytes between `i_size` and
> `blocksz` ??? inside the allocation but beyond the valid data (info-leak into filenames,
> not an ASAN-detectable overflow).
> 
> **Runtime proof (ASAN, unmodified upstream build).**
> 
> ```
> ==32698==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x521000004d04
> READ of size 2 at 0x521000004d04 thread T0
>     #0 erofs_iterate_dir grub-core/fs/erofs.c:622
>     #1 grub_erofs_dir grub-core/fs/erofs.c:827
>     #2 grub_ls_list_files grub-core/commands/ls.c:241
> ...
> 0x521000004d04 is located 4 bytes AFTER 4096-byte region
> allocated by thread T0 here:
>     #1 grub_malloc grub-core/kern/emu/mm.c:42
>     #2 erofs_iterate_dir grub-core/fs/erofs.c:567
> ```
> 
> **PoC.** `erofs-oob.img` (12,288 bytes) ??? real `mkfs.erofs` image with 200 files (root
> dir = one full 4096-byte block, 340 dirents), then patched: `dirent[0].nameoff = 4094`
> and all other slots' `nameoff = 4095` (keeps every `de_namelen` consistent, no
> underflow, names NUL-terminated). Command: `grub-fstest erofs-oob.img ls /`.
> 
> **Impact.** Same class as V2: heap over-read surfaced through filename strings.
> erofs is the default rootfs format for many modern immutable/Android-style
> distributions, so a corrupt or malicious erofs ESP/initrd image is a realistic vector.
> Rated **Medium 5.5**.
> 
> ---
> 
> ## 4. Fix Verification (patch applied ??? rebuilt ??? re-tested)
> 
> | Test | Unpatched HEAD | Patched |
> |------|----------------|---------|
> | `f2fs-oob.img ls /` | ASAN heap-buffer-overflow READ | clean exit, no ASAN, listing OK |
> | `erofs-oob.img ls /` | ASAN heap-buffer-overflow READ | clean exit, no ASAN, listing OK |
> | `nilfs2-oob.img cat /s` | ASAN heap-buffer-overflow WRITE | clean error: `symlink is too long` |
> | `f2fs.img ls /` (valid) | OK | OK (identical) |
> | `f2fs.img cat /link.lnk` (valid symlink) | OK | OK (`testfile`) |
> | `erofs.img ls /` (valid, inline dir) | OK | OK (`hello.txt subdir/`) |
> | `erofs-big.img ls /` (valid, 200 files) | OK | OK (all 200 names) |
> | `nilfs2.img ls /` (valid) | OK | OK |
> 
> The patched tree builds without errors and without new warnings; the diff is minimal
> and limited to the three parser files (`grub2-fixes-7aa28608.diff`, 115 lines).
> 
> ---
> 
> ## 5. Remediation
> 
> One patch fixes all three findings (full diff in Appendix B):
> 
> - **nilfs2** ??? reject `i_size > 4096` (`GRUB_NILFS2_SYMLINK_MAX`, Linux `PATH_MAX`,
>   same constant the fixed ext2/f2fs/hfs+/squash4 drivers use) and compute the
>   allocation with `grub_add()`; terminator index becomes the validated `filesize`.
> - **f2fs** ??? bound `name_len` by the bytes physically remaining in the filename area:
>   `name_len > (ctx->max - i) * F2FS_SLOT_LEN` ??? `GRUB_ERR_BAD_FS`.
> - **erofs** ??? make the last-entry test geometry-aware: dereference `de[1].nameoff`
>   only when the next 12-byte header fits entirely before the name area
>   (`(grub_uint8_t *)(de + 1) + sizeof(*de) > (grub_uint8_t *)end` ??? strnlen path).
> 
> All three mirrors the hardening idioms upstream already applied to sibling drivers
> during the 2021???2025 security rounds, so the patch should be uncontroversial.
> 
> **Interim mitigations** (before a fixed grub reaches users): none of these parsers is
> loadable in lockdown if the distro ships `grub_lockdown()` enforcement ??? verify the
> `lockdown` GRUB_LOCKDOWN_DESTRUCTOR build option and SBAT revocations; disabling the
> nilfs2/f2fs/erofs modules (`grub-install --install-modules` allow-list) removes the
> attack surface for systems that never boot from those filesystems.
> 
> ---
> 
> ## 6. Input Reachability (proven with the real GRUB shell, not asserted)
> 
> Every finding was re-verified against a **real GRUB shell** ??? `grub-emu` built from the
> same pinned commit with ASAN (only `grub-core/genmoddep.awk` taught to treat
> `__asan_*`/`__ubsan_*` as runtime-provided so modules link; no parser code changed) ???
> driving the *actual boot-time commands*. The static call chains from the boot entry
> points were additionally traced line-by-line in the source.
> 
> | Finding | Boot-time input that triggers it | Evidence file |
> |---------|----------------------------------|---------------|
> | V1 nilfs2 | `search.file <path>` (stock grub.cfg), kernel/initrd load, `cat`, `configfile` ??? any `grub_file_open` crossing the malicious symlink | `emu-crash-nilfs2-search.txt` |
> | V2 f2fs | `ls (hd0,1)/`, `search --file`, `cat`, `configfile` ??? any path walk of the poisoned directory | `emu-crash-f2fs-open.txt` |
> | V3 erofs | same as V2 | `emu-crash-erofs-open.txt` |
> 
> ### 6.1 Boot flow reaches the parsers with no user interaction
> 
> Traced at the pinned commit:
> 
> ```
> grub_main (kern/main.c)
> ?????? grub_normal_execute (normal/main.c:269)
>    ?????? read_lists (prefix) (normal/main.c:277)
>    ???  ?????? read_fs_list (normal/autofs.c)  ??? registers grub_fs_autoload_hook
>    ?????? read_config_file ??? grub_file_open (grub.cfg) (normal/main.c:135)
>       ?????? grub_fs_probe (kern/fs.c:45)
>          ?????? for each fs module (autoloaded via fs.lst, kern/fs.c:91-99):
>             fs->fs_dir (device, "/", probe_dummy_iter)      ??? parser entry
> ```
> 
> `grub_file_open` (kern/file.c) probes the target device, and the f2fs/erofs dir
> handlers walk the root directory (`grub_f2fs_dir` ??? `grub_f2fs_iterate_dir`;
> `grub_erofs_dir` ??? `erofs_iterate_dir`) ??? the vulnerable functions run **during
> grub.cfg discovery at every boot** when any probed disk carries a crafted image.
> 
> ### 6.2 Real-shell results (grub-emu, ASAN, commit 7aa28608)
> 
> Each PoC was attached with the stock `loopback` command and exercised with real
> boot-time commands:
> 
> ```
> grub> loopback lp0 /path/to/poisoned.img
> grub> cat (lp0)/grub.cfg        ??? grub.cfg / kernel-load analog
> grub> search --file /grub.cfg   ??? stock distro grub.cfg command
> grub> search.file /s            ??? V1 via the search.file alias
> grub> configfile (lp0)/grub.cfg ??? the literal boot-time config load
> ```
> 
> | Command (PoC image) | Finding | ASAN trace |
> |----------------------|---------|------------|
> | `ls (lp0)/` (f2fs) | V2 | `heap-buffer-overflow READ ... #3 grub_f2fs_check_dentries fs/f2fs.c:1075` |
> | `cat (lp0)/grub.cfg` (f2fs) | V2 | `... #5 directory_find_file fs/fshelp.c:152` (full path walk) |
> | `search --file /grub.cfg` (f2fs) | V2 | same trace via all-device sweep |
> | `ls (lp0)/` (erofs) | V3 | `heap-buffer-overflow READ ... #0 erofs_iterate_dir fs/erofs.c:622` |
> | `configfile (lp0)/grub.cfg` (erofs) | V3 | same trace via the literal boot config load |
> | `search --file /grub.cfg` (erofs) | V3 | same |
> | `cat (lp0)/s` (nilfs2) | V1 | `heap-buffer-overflow WRITE ... #0 grub_nilfs2_read_symlink fs/nilfs2.c:898` |
> | `search.file /s` (nilfs2) | V1 | same, via the stock grub.cfg command |
> 
> ### 6.3 A nuance the runtime testing corrected
> 
> The **bare probe** (`ls -l (lp0)`, `search --fs-uuid`) identifies the filesystem but
> its dummy hook returns after the first directory entry, so alone it does **not** reach
> the crafted slots in V2/V3. The trigger is any *path walk* through the directory ???
> exactly what `grub_file_open` performs (grub.cfg load, kernel/initrd load,
> `configfile`, `cat`, `search --file`). Because every stock distro grub.cfg runs
> `search --file` / `search.fs_uuid` **and** loads `grub.cfg` before showing the menu,
> the vulnerable paths execute on every boot of an affected system with no interaction
> beyond power-on. (V1 needs a symlinked path; kernel/initrd paths are commonly
> symlinked, e.g. `/vmlinuz` ??? `/vmlinuz-6.x`.)
> 
> ### 6.4 Module autoload closes the last gap
> 
> `fs.lst`-driven autoloading (normal/autofs.c, kern/fs.c:91-99) means the f2fs/erofs/
> nilfs2 modules need not be preloaded: the first probe attempt loads them
> automatically. An install-time module allow-list (??5) is therefore the only
> configuration that removes the attack surface without the patch.
> 
> ### 6.5 Threat-model notes
> 
> - GRUB's own heap (`grub-core/kern/mm.c`) is a first-fit allocator over fixed regions
>   with **no hardening** (no canaries, no quarantine, 4-byte header per chunk). A single
>   byte before a chunk ??? V1's primitive ??? is the allocator's `magic/size` word;
>   corrupting it yields controlled overlap on the next `grub_free`, the standard path
>   to arbitrary write in this allocator. Exploitability is amplified by the pre-OS
>   context: no ASLR, no NX on many platforms, and secure-boot trust already extended
>   to GRUB.
> - The `emu` build used for proof links the same parser sources compiled into the
>   i386-pc/x86_64-efi boot images; the ASAN instrumentation only observes, never
>   alters, the parsed data.
> 
> ---
> 
> ## 7. Novelty Statement
> 
> - **Upstream git history**: each flaw exists unchanged since the respective driver was
>   introduced (`71f9e4ac4` f2fs, `9d603061a` erofs, initial nilfs2 import). No subsequent
>   commit touches the vulnerable lines (`git log -S` per pattern).
> - **Public advisories**: nilfs2, f2fs and erofs appear **nowhere** in the 2025-02-18
>   GRUB2 disclosure (CVE-2024-45774..45783, CVE-2025-0622..1125) or any earlier round
>   (BootHole 2020, 2021-03, 2022-06, 2023-0690/4692). V1 is the same bug class as
>   CVE-2025-0677 (ufs) / CVE-2025-0684 (reiserfs) ??? those rounds hardened the sibling
>   drivers but skipped nilfs2; V2/V3 have no CVE analogue.
> - No fix exists at upstream HEAD as of 2026-12-01 (verified by direct source audit of
>   the pinned commit).
> 
> We request coordinated disclosure and CVE assignment for the three findings, with this
> report and the attached evidence as the reference.
> 
> ---
> 
> ## 8. Reproducer Bundle
> 
> | File | Purpose |
> |------|---------|
> | `nilfs2-oob.img` | V1 PoC image (hand-crafted 45 KB nilfs2) |
> | `f2fs-oob.img` | V2 PoC image (mkfs.f2fs 1.16.0 + 2-byte patch) |
> | `erofs-oob.img` | V3 PoC image (mkfs.erofs 1.8.6 + nameoff patch) |
> | `evidence-nilfs2.txt` / `evidence-f2fs.txt` / `evidence-erofs.txt` | full ASAN reports (grub-fstest harness) |
> | `emu-crash-{nilfs2,nilfs2-search,f2fs,f2fs-open,erofs,erofs-open}.txt` | full ASAN reports (real grub-emu shell, stock boot commands) |
> | `grub2-fixes-7aa28608.diff` | verified remediation patch |
> | `craft_nilfs2_poc.py` / `craft_f2fs_poc.py` / `craft_erofs_poc.py` | PoC generators |
> 
> Rebuild the harness exactly as audited:
> 
> ```sh
> git clone https://gitlab.freedesktop.org/gnu-grub/grub.git && cd grub
> git checkout 7aa2860835006cc5df95f84d8d504c2c1fa6a4b5
> ./bootstrap && ./configure --with-platform=emu --disable-werror --disable-nls
> make -j$(nproc)                       # clean reference build
> # ASAN variant (grub-fstest + the real grub-emu shell):
> ./configure --with-platform=emu --disable-werror --disable-nls \
>   CFLAGS="-g -O1 -fsanitize=address -fno-omit-frame-pointer" LDFLAGS="-fsanitize=address"
> # teach the module-dependency generator that the ASAN runtime provides __asan_*:
> sed -i 's/\$3 != "_gp_disp" /\$3 != "_gp_disp" \&\& \$3 !~ \/^__asan_\/ \&\& \$3 !~ \/^__ubsan_\/ /' grub-core/genmoddep.awk
> make -j$(nproc)
> # fstest harness:
> ASAN_OPTIONS=detect_leaks=0 ./grub-fstest <image> ls /
> # real GRUB shell (boot-command reachability, see section 6):
> printf 'loopback lp0 $PWD/<image>\nls (lp0)/\n' | \
>   ASAN_OPTIONS=detect_leaks=0 ./grub-core/grub-emu
> ```
> 
> ---
> 
> ## Appendix A ??? Vendor / Coordination
> 
> - **Project**: GNU GRUB2 ??? https://gitlab.freedesktop.org/gnu-grub/grub
> - **Analyzed commit**: `7aa2860835006cc5df95f84d8d504c2c1fa6a4b5` (master, 2026-11-30)
> - **Suggested reporting channel**: grub-devel@....org security round (SECURITY PATCH
>   series) and distros@...openwall.org for embargoed pre-notification, matching the
>   project's 2025-02-18 process.
> - **Suggested credits**: independent security audit (static analysis + ASAN runtime
>   proof).
> 
> ## Appendix B ??? Remediation diff (verified, see ??4)
> 
> ```diff
> diff --git a/grub-core/fs/erofs.c b/grub-core/fs/erofs.c
> @@ -615,7 +615,13 @@ erofs_iterate_dir (grub_fshelp_node_t dir, grub_fshelp_iterate_dir_hook_t hook,
>  	    }
>  
>  	  de_name = (char *) buf + nameoff;
> -	  if (de + 1 >= end)
> +	  /*
> +	   * de[1].nameoff is only dereferenced when the next header fits
> +	   * entirely before the name area; otherwise this is the last entry
> +	   * and its name length is the NUL-terminated remainder.  A byte-wise
> +	   * de+1 >= end test would still read a partially fitting header.
> +	   */
> +	  if ((grub_uint8_t *) (de + 1) + sizeof (*de) > (grub_uint8_t *) end)
>  	    de_namelen = grub_erofs_strnlen (de_name, maxsize - nameoff);
>  	  else
>  	    {
> diff --git a/grub-core/fs/f2fs.c b/grub-core/fs/f2fs.c
> @@ -1063,6 +1063,18 @@ grub_f2fs_check_dentries (struct grub_f2fs_dir_iter_ctx *ctx)
>        if (name_len == 0 || name_len >= F2FS_NAME_LEN)
>          return 0;
>  
> +      /*
> +       * The name lives in the per-slot 8-byte filename area that ends with
> +       * the dentry block.  A crafted name_len can exceed the bytes left in
> +       * the block, making the copy below read past the buffer end.
> +       */
> +      if (name_len > (ctx->max - i) * F2FS_SLOT_LEN)
> +        {
> +          grub_error (GRUB_ERR_BAD_FS,
> +                      N_("dentry name length overflows the block"));
> +          return 0;
> +        }
> +
>        if (grub_add (name_len, 1, &sz))
>  	{
>  	  grub_error (GRUB_ERR_OUT_OF_RANGE, N_("directory entry name length overflow"));
> diff --git a/grub-core/fs/nilfs2.c b/grub-core/fs/nilfs2.c
> @@ -35,6 +35,7 @@
>  #include <grub/types.h>
>  #include <grub/fshelp.h>
>  #include <grub/lockdown.h>
> +#include <grub/safemath.h>
>  
>  GRUB_MOD_LICENSE ("GPLv3+");
>  
> @@ -133,6 +134,9 @@ struct grub_nilfs2_super_block
>    grub_uint32_t s_reserved[192];
>  };
>  
> +/* Linux PATH_MAX: the longest symlink target a real nilfs2 image stores. */
> +#define GRUB_NILFS2_SYMLINK_MAX 4096
> +
>  struct grub_nilfs2_dir_entry
>  {
>    grub_uint64_t inode;
> @@ -875,6 +879,8 @@ grub_nilfs2_read_symlink (grub_fshelp_node_t node)
>  {
>    char *symlink;
>    struct grub_fshelp_node *diro = node;
> +  grub_uint64_t filesize;
> +  grub_size_t sz;
>  
>    if (!diro->inode_read)
>      {
> @@ -883,19 +889,37 @@ grub_nilfs2_read_symlink (grub_fshelp_node_t node)
>  	return 0;
>      }
>  
> -  symlink = grub_malloc (grub_le_to_cpu64 (diro->inode.i_size) + 1);
> +  filesize = grub_le_to_cpu64 (diro->inode.i_size);
> +
> +  /*
> +   * A symlink target is a path; reject the absurd sizes a crafted inode
> +   * can put in i_size instead of trying to allocate a buffer for them.
> +   * Without this check i_size = UINT64_MAX wraps the malloc size to 0
> +   * and the NUL terminator write lands one byte before the buffer.
> +   */
> +  if (filesize > GRUB_NILFS2_SYMLINK_MAX)
> +    {
> +      grub_error (GRUB_ERR_BAD_FS, N_("symlink is too long"));
> +      return 0;
> +    }
> +  if (grub_add (filesize, 1, &sz))
> +    {
> +      grub_error (GRUB_ERR_OUT_OF_RANGE, N_("symlink size overflow"));
> +      return 0;
> +    }
> +
> +  symlink = grub_malloc (sz);
>    if (!symlink)
>      return 0;
>  
> -  grub_nilfs2_read_file (diro, 0, 0, 0,
> -			 grub_le_to_cpu64 (diro->inode.i_size), symlink);
> +  grub_nilfs2_read_file (diro, 0, 0, 0, filesize, symlink);
>    if (grub_errno)
>      {
>        grub_free (symlink);
>        return 0;
>      }
>  
> -  symlink[grub_le_to_cpu64 (diro->inode.i_size)] = '\0';
> +  symlink[filesize] = '\0';
>    return symlink;
>  }
> ```

> Hello GRUB Security Team,
> 
> We are writing to report three previously undisclosed
> memory-corruption vulnerabilities discovered during an independent
> security audit of upstream GNU GRUB2 at master HEAD (commit
> 7aa2860835006cc5df95f84d8d504c2c1fa6a4b5, 2026-11-30, GRUB 2.17 dev).
> All three findings have been proven at runtime with AddressSanitizer
> builds of unmodified upstream code, and none appear in any prior
> public advisory round, including the comprehensive 2025-02-18
> disclosure (CVE-2024-45774..45783, CVE-2025-0622..1125).
> 
> We request coordinated disclosure and CVE assignment for all three findings.
> 
> ---
> 
> SUMMARY OF FINDINGS
> 
> [V1] fs/nilfs2.c ??? grub_nilfs2_read_symlink
>   Type : Integer overflow ??? heap out-of-bounds WRITE (1 byte before chunk)
>   CWE  : CWE-190 / CWE-787
>   CVSS : 7.8 High (AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H)
>   Note : Same bug class as CVE-2025-0677 (ufs) and CVE-2025-0684 (reiserfs);
>          nilfs2 was missed in the 2025-02-18 hardening sweep.
> 
> [V2] fs/f2fs.c ??? grub_f2fs_check_dentries
>   Type : Heap out-of-bounds READ (up to 246 bytes past a 4096-byte buffer)
>   CWE  : CWE-125
>   CVSS : 5.5 Medium (AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N)
> 
> [V3] fs/erofs.c ??? erofs_iterate_dir
>   Type : Heap out-of-bounds READ (up to 6 bytes past a 4096-byte buffer)
>   CWE  : CWE-125
>   CVSS : 5.5 Medium (AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N)
> 
> All three flaws are reachable at boot by mounting a crafted or
> corrupted filesystem image (e.g. USB stick, malicious disk image,
> corrupted ESP partition) before any OS authentication, in a privileged
> UEFI/BIOS environment with no ASLR and no stack canary in most builds.
> 
> ---
> 
> ATTACHED EVIDENCE
> 
> The following files accompany this report:
> 
>   - grub2-oob-security-audit.md   ??? Full vendor-grade audit report
> (this document)
>   - grub2-fixes-7aa28608.diff     ??? Verified remediation patch
> (applied, rebuilt, re-tested)
>   - nilfs2-oob.img / f2fs-oob.img / erofs-oob.img   ??? PoC filesystem images
>   - evidence-nilfs2.txt / evidence-f2fs.txt / evidence-erofs.txt ???
> Full ASAN reports (grub-fstest)
>   - emu-crash-{nilfs2,nilfs2-search,f2fs,f2fs-open,erofs,erofs-open}.txt
> ??? ASAN reports (real grub-emu shell)
>   - craft_nilfs2_poc.py / craft_f2fs_poc.py / craft_erofs_poc.py ??? PoC
> generators
> 
> ---
> 
> REMEDIATION
> 
> A minimal patch for all three findings is attached
> (grub2-fixes-7aa28608.diff). It has been applied to the ASAN build,
> rebuilt, and verified: all PoCs are neutralized and all valid
> filesystem images behave identically to the unpatched build. The fix
> follows the same approach used in the 2025-02-18 round (grub_add() for
> safe size arithmetic, PATH_MAX rejection for symlink targets).
> 
> ---
> 
> DISCLOSURE TIMELINE REQUEST
> 
> We propose a standard 90-day coordinated embargo to allow downstream
> distributions to prepare and ship fixes, consistent with the process
> used for the February 2025 round. We are simultaneously notifying
> distros@...openwall.org per standard practice for boot-level
> vulnerabilities.
> 
> Please confirm receipt and advise on CVE assignment. We are happy to
> provide any additional technical information or reproduce the issues
> on request.
> 
> ---
> 
> REPORTERS / CONTRIBUTORS
> 
>   SakithLomitha
>   HEXER365
>   pamod-madubashana
> 
>   (Independent security audit ??? static analysis + ASAN runtime proof)
> 
> Thank you for your time and for maintaining GRUB2's security.
> 
> Best regards,
> SakithLomitha, HEXER365, pamod-madubashana

On Thu, Dec 03, 2026 at 03:30:16PM +0100, Solar Designer wrote:
> Hi SakithLomitha,
> 
> On Thu, Dec 03, 2026 at 10:25:43AM +0530, sakith lomitha wrote:
> > # GRUB2 Filesystem Parser Security Audit ??? Vendor Report
> 
> On one hand, thank you for finding (or having AI find) these issues and
> reporting them.
> 
> On the other, as distros list admin I find your report mildly abusive as
> it's inconsistent with our published instructions:
> 
> https://oss-security.openwall.org/wiki/mailing-lists/distros#list-policy-and-instructions-for-reporters
> 
> I assume you let "AI" "decide" on where to report this to. :-(
> 
> > We propose a standard 90-day coordinated embargo to allow downstream
> > distributions to prepare and ship fixes, consistent with the process
> > used for the February 2025 round. We are simultaneously notifying
> > distros@...openwall.org per standard practice for boot-level
> > vulnerabilities.
> 
> This has two references to "standard", but neither is actually standard.
> 
> We have a maximum of 14 days embargo on the distros list as stated in
> the instructions referenced above.  So your proposed 90 days is NAK'ed.
> 
> Please propose a valid public disclosure date/time and please confirm
> you're going to post to the public oss-security list when making the
> issues public.
> 
> You copied the public grub-devel list on this, which is also a wrong
> thing to do when you're at the same time trying to have an embargo.
> You had to choose one or the other, not both.  However, I do not see
> your message actually appear in the public archive of grub-devel:
> 
> https://lists.gnu.org/archive/html/grub-devel/
> 
> Maybe it got spam-filtered, or maybe it will appear there shortly.
> 
> As to "standard practice for boot-level vulnerabilities", it's tricky.
> Dealing with some of them may require steps that do not fit in the 14
> days maximum we have here.  So for those some coordination before
> bringing them to the distros list may be needed, with the distros list
> only notified when it's at most 14 days left until planned public
> disclosure (and there's confidence the embargo would not be extended).
> 
> I did not look into the actual issues you reported.
> 
> Alexander

On Thu, Dec 03, 2026 at 01:09:38PM -0300, Marco Benatto wrote:
> This indeed reached out to grub-devel list.
> 
> I'm in contact with the upstream maintainer about this and helping
> triage the reports according to:
> 
> https://gitlab.freedesktop.org/gnu-grub/grub/-/blob/master/SECURITY?ref_type=heads
> 
> There's nothing much we can do on the distro side right now regarding
> that now, but as a general appeal please
> check this document before sharing any report here. In some specific
> cases it's not feasible to have it handled within the 14
> days embargo period mandated by this list's rules, especially when it
> comes to Secure Boot revocations. Refrain from posting anything here
> related
> to grub and/or shim before properly contact the upstream's security
> contact and properly coordinate with them first,
> 
> Thanks,
> 
> Marco Benatto
> Red Hat Product Security

Powered by blists - more mailing lists

Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.