Bug 2572341 (CVE-2026-109908)

Summary: CVE-2026-109908 libfontenc: libfontenc File Parsing Validation Failure
Product: [Other] Security Response Reporter: OSIDB Bzimport <bzimport>
Component: vulnerabilityAssignee: Product Security <prodsec-ir-bot>
Status: NEW --- QA Contact:
Severity: high Docs Contact:
Priority: high    
Version: unspecifiedCC: rhel-process-autobot, security-response-team, watson-tool-maintainers
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: ---
Doc Text:
A flaw was found in libfontenc. The font encoding parser fails to validate dimensions when processing font encoding (.enc) files, resulting in a heap-based buffer overflow. A local attacker can exploit this vulnerability by placing a specially crafted encoding file in a directory read by a privileged process, such as an X server. Successful exploitation may allow the attacker to achieve local privilege escalation or cause a Denial of Service (DoS) by crashing the process.
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Deadline: 2026-11-18   

Description OSIDB Bzimport 2026-11-12 11:40:19 UTC
libfontenc's .enc encoding-file parser contains a heap out-of-bounds write
in setCode() (src/encparse.c). The destination index is computed as (from
>> 8) * row_size + (from & 0xFF), where row_size is taken straight from the
SIZE line of the encoding file and is never bounded, while the destination
buffer is allocated at a constant cap of 0x10000 entries.

A crafted .enc file makes the index exceed the allocation and writes past
it. The Xorg/Xwayland X server links libfontenc via libXfont2 and parses
.enc files in its own process during font rasterization.

Where the X server runs as root, a local user that places a font file and
an encoding file on a server-read font path can trigger the OOB write, 
triggering potential local privilege escalation.

Fixed in: libfontenc-1.1.10
Fixes:
  - https://gitlab.freedesktop.org/xorg/lib/libfontenc/-/commit/TBD

Acknowledgements:
    Adam Bedard working with TrendAI Zero Day Initiative
    
* Patch
From 63bd5096e2f4889fc486a282fd5c1dfb93d559b0 Mon Sep 17 00:00:00 2001
From: Peter Hutterer <peter.hutterer>
Date: Wed, 16 Sep 2026 15:24:17 +1000
Subject: [PATCH libFontenc 1/1] encparse: fix heap out-of-bounds write in
 setCode()

setCode() computes a destination index from two attacker-controlled
values taken from the .enc encoding file:

    index = (from >> 8) * row_size + (from & 0xFF);

The "from" parameter is <= 0xFFFF (see the check a few lines above), so
from >> 8 can reach 0xFF. row_size comes straight from the SIZE line of
the encoding file.

The destination buffer is allocated with a size capped at 0x10000
entries. At row_size > 256, the index exceeds the allocation, causing a
heap out-of-bounds write.

For example, SIZE 256 258 and mapping 0xff00 -> 0 gives:
  index = 255 * 258 + 0 = 65790, allocation = 65536 entries

Additionally, the column bounds check incorrectly tested the global
variable "value1" instead of the function parameter "from".  For
CODE_LINE this happens to be the same value, but for CODE_RANGE_LINE
and CODE_UNDEFINE_LINE the loop calls setCode() with different values
of "from" while value1 remains unchanged.

This vulnerability was discovered by:
  Adam Bedard working with TrendAI Zero Day Initiative

CVE-2026-109908, ZDI-CAN-31888

Assisted-by: Claude:claude-opus-4-6

#+begin_src diff
---
 src/encparse.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git ./src/encparse.c ../src/encparse.c
index 39dbc89862f8..8949fd475b88 100644
--- ./src/encparse.c
+++ ../src/encparse.c
@@ -450,19 +450,21 @@ setCode(unsigned from, unsigned to, unsigned row_size,
     unsigned short *newenc;
 
     if (from > 0xFFFF)
         return 0;               /* success */
 
     if (row_size == 0)
         index = from;
     else {
-        if ((value1 & 0xFF) >= row_size)
+        if ((from & 0xFF) >= row_size)
             return 0;           /* ignore out of range mappings */
         index = (from >> 8) * row_size + (from & 0xFF);
+        if (index > 0xFFFF)
+            return 0;           /* ignore mappings that exceed the encoding size */
     }
 
     /* Optimize away useless identity mappings.  This is only expected
        to be useful with linear encodings. */
     if (index == to && (index < *first || index > *last))
         return 0;
     if (*encsize == 0) {
         *encsize = (index < 256) ? 256 : 0x10000;
-- 
2.56.0

#+end_src