Aller au contenu principal
HDWSec
High CVE-2014-2013

MuPDF: Stack-based Buffer Overflow in xps_parse_color() leading to Remote Code Execution

Sévérité
High
Score CVSS
7.8CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
Identifiants CVE
CVE-2014-2013
Éditeur
Artifex Software (MuPDF)
Produit
MuPDF
Versions affectées
MuPDF <= 1.3 (version 1.3 and earlier)
Version corrigée
1.4 (upstream fix committed 2014-01-18)
Type de vulnérabilité
Stack-based Buffer Overflow (CWE-121; NVD classifies as CWE-119)
Chercheurs
Jean-Jamil KHALIFÉ

Presentation

MuPDF is a lightweight, open source C/C++ PDF and XPS viewing and rendering library maintained by Artifex Software. While auditing the source code of the product, our researcher Jean-Jamil Khalife discovered, within about two hours, both a denial of service and a stack-based buffer overflow. The overflow can be escalated to full remote code execution when a victim opens a malicious XPS document.

The flaw lives in the XPS parsing path. When MuPDF loads an XPS document it renders the first page and parses each element through xps_parse_element(), following the ECMA-388 (OpenXPS) specification. A crafted Path element whose Fill attribute carries a ContextColor value with too many color components overflows a fixed-size stack buffer, giving an attacker control over execution flow.

Issue(s)

  • Stack-based buffer overflow in xps_parse_color() (xps/xps-common.c): the function copies every floating point component of a ContextColor value into a fixed float samples[32] stack buffer declared in the caller xps_parse_path(), without ever checking the destination array bound.
  • The only loop guard is the number of commas parsed in the input string, never the capacity of samples, so an attacker fully controls how far past the buffer the write goes.
  • The condition is reachable purely from attacker-controlled document content (the Fill attribute of a Path), which turns a single crafted XPS file into a reliable memory-corruption primitive and, on the tested builds, remote code execution.

Full technical analysis

The complete write-up (root cause, exploitation, proof of concept) is available on the HDW Sec blog: https://www.hdwsec.fr/blog/20130126-mupdf/

References

Notre R&D traque les vulnérabilités.

Recherche de 0-day, reverse engineering, divulgation coordonnée : découvrez notre pôle R&D.