How a libheif RCE Was Found, Fixed, and Disclosed

Peter Bubenik · Vercel · · Source
Image for Reproducing, disclosing, and fixing the libheif vulnerability with Hacktron and the maintainers

After studying this material, you should be able to:

Understand how a supply chain vulnerability propagates through software dependencies, and explain the coordinated disclosure and remediation process used to fix it responsibly.

Specifically you should be able to:

  • Trace how a vulnerability travels through a dependency chain
  • Explain what coordinated vulnerability disclosure looks like in practice
  • Identify mitigation strategies at different layers of a stack
  • Understand the roles different parties play in fixing upstream vulnerabilities

Step-by-Step Teaching

Step 1: What Is a Dependency Chain?

Modern software rarely works alone. Applications rely on libraries, which rely on other libraries.

Think of it like a supply chain:

Your App
  └── Library A
        └── Library B
              └── Library C  ← vulnerability lives here

Key insight: A vulnerability deep in the chain can still be exploited through the top layer.

Real Example From the Article

User sends malicious AVIF image
        ↓
Next.js <Image> component
        ↓
/_next/image endpoint
        ↓
sharp (image processing)
        ↓
libvips (image processing engine)
        ↓
libheif ← VULNERABLE CODE LIVES HERE

Even though Next.js itself had no bug, it was still the entry point for the attack.


Step 2: What Was the Actual Vulnerability?

The vulnerability was a Remote Code Execution (RCE) in libheif, an AVIF image decoder.

Breaking Down the Terms

TermMeaning
AVIFA modern image format (like JPEG or PNG, but newer)
libheifA library that decodes AVIF images
RCERemote Code Execution — an attacker can run arbitrary code on your server
Heap buffer overflowWriting data beyond allocated memory, which can be exploited to hijack program execution

How the Attack Would Work

Attacker crafts a malicious AVIF image
        ↓
Sends it to a Next.js image optimization URL
        ↓
Next.js passes it through sharp → libvips → libheif
        ↓
libheif processes the malicious image
        ↓
Buffer overflow triggers → attacker executes code on the server

Why is RCE so serious? Because the attacker can do anything your server can do — steal data, install malware, pivot to other systems.


Step 3: How Was It Discovered and Verified?

The Discovery Process

  1. Hacktron (a security research firm) found the vulnerability
  2. They reported it privately to Vercel — this is called responsible disclosure
  3. Vercel and Hacktron worked together to reproduce the exploit with a working proof of concept

Why Reproduction Matters

Before acting, you must confirm:

  • ✅ The vulnerability is real (not a false positive)
  • ✅ It is actually exploitable in practice
  • ✅ You understand exactly how it works

Reproducing the exploit gives you the knowledge needed to build an effective fix.


Step 4: Immediate Mitigation — Stopping the Bleeding

Once confirmed, the priority is protecting users immediately, even before a full fix exists.

Vercel's Platform Mitigation (August 13)

Vercel controls a central Image Optimization Service that all Next.js apps on Vercel use.

Malicious AVIF image arrives
        ↓
Image Optimization Service
        ↓
❌ AVIF processing DISABLED
        ↓
Image never reaches libheif → No exploit possible

This was fast because: Vercel controls the infrastructure centrally. One change protected all hosted customers.

The Tradeoff

ActionBenefitCost
Disable AVIF optimizationBlocks the exploit immediatelyUsers lose AVIF support temporarily
Wait for upstream fixPreserves full functionalityUsers remain vulnerable longer

Lesson: In security, a temporary loss of features is almost always preferable to leaving users exposed.


Step 5: Coordinated Disclosure — Fixing It Properly

Mitigating Next.js alone was not enough because:

  • libheif is used by many other projects (WordPress, ImageMagick, sharp, etc.)
  • Those projects would remain vulnerable
  • Publishing the vulnerability without a fix would give attackers a roadmap

The Coordinated Disclosure Timeline

Aug 11-12  →  Hacktron reports to Vercel; RCE reproduced
Aug 13     →  Vercel applies platform mitigation
Aug 19     →  Next.js meets with libvips maintainer; coordination begins
Aug 24     →  Security partners notified
Aug 25     →  libheif v1.23.2 released (fix); Next.js security release published

Who Was Involved and How

PartyRoleCommunication Channel
HacktronDiscovered & reportedDirect report to Vercel
Vercel/Next.jsCoordinated responseEmail + GitHub Security Advisory
libheif maintainerWrote the actual fixGitHub Security Advisory
libvips maintainerCoordinated downstreamMeeting + email
sharp maintainerDownstream coordinationEmail
Security partnersNotified before public disclosurePrivate notification

Key principle: Everyone who needs to know is told privately first, so they can prepare before the vulnerability becomes public knowledge.


Step 6: The Upstream Fix vs. Downstream Mitigation

This is a critical distinction:

Downstream Mitigation (Next.js)

  • Disables AVIF in Next.js
  • Protects Next.js users
  • Does not fix the root cause
  • Other software using libheif is still vulnerable

Upstream Fix (libheif v1.23.2)

  • Fixes the actual bug in libheif
  • Protects every project that uses libheif
  • Takes longer to propagate down to end users
libheif fix released
        ↓
libvips updates its libheif dependency
        ↓
sharp updates its libvips dependency
        ↓
Next.js updates its sharp dependency
        ↓
Your app updates its Next.js dependency

Lesson: Downstream mitigations buy time. Upstream fixes solve the problem permanently.


Step 7: The Bigger Picture — Why This Is Getting More Common

The article notes a sharp rise in vulnerabilities:

  • 35,000+ CVEs published in 2026
  • GitHub private vulnerability reports grew 6x (500/week → 3,000/week) in just months
  • LLMs are accelerating vulnerability research — AI can find bugs faster than ever

What This Means

More software complexity
        +
AI-assisted vulnerability research
        =
More vulnerabilities discovered, faster

Organizations must:

  • Proactively hunt for vulnerabilities (don't wait to be attacked)
  • Have response processes ready before incidents happen
  • Collaborate with the open source community rather than working in isolation

Summary: The Full Mental Model

DISCOVERY
Researcher finds bug → Privately reports to vendor

VERIFICATION  
Vendor reproduces exploit → Confirms severity

IMMEDIATE MITIGATION
Protect users now → Accept temporary feature loss

COORDINATED DISCLOSURE
Notify all affected maintainers privately
Give them time to prepare fixes

UPSTREAM FIX
Root cause fixed in the vulnerable library

DOWNSTREAM PROPAGATION
Fix flows through dependency chain to end users

PUBLIC DISCLOSURE
Vulnerability details published → Community can verify they're protected

Key Takeaways

ConceptWhat to Remember
Dependency chainsVulnerabilities can be exploited through layers of software that aren't themselves vulnerable
RCEOne of the most severe vulnerability types — attacker runs code on your server
Responsible disclosureReport privately first, fix before going public
Mitigation vs. fixMitigation stops the bleeding; upstream fix cures the disease
CoordinationMulti-party vulnerabilities require organized communication across all affected projects
Defense in depthFixing at multiple layers (platform + framework + library) provides stronger protection

More to study