contents [10]
In this writeup, I present my research into a use-after-free (UAF) I found in librsvg, an SVG parser widely used across dozens of products and web applications. The flaw received CVE-2026-96889 in September.
Basically, a single SVG image could be used to get RCE on the targets, similar to other well-known flaws such as HEIF Heist and ImageTragick. During the research, I confirmed the exploitable chain in two Next.js routes. This led to two advisories that received broad coverage, including articles by The Hacker News that also cited me. The same flaw affected Ghost, which published CVE-2026-105642, and several other downstream products.
How an SVG reaches native code
Web applications often use Sharp to resize and convert images. Sharp uses libvips, which can load SVG through librsvg. librsvg uses libxml2 to read the image’s XML.
In practice, a short call such as sharp(buffer).png() can end up in this stack:
application → Sharp → libvips → librsvg → libxml2
An application might accept a profile picture, a bookmark image, or the contents of an OG image without ever mentioning SVG or librsvg in its own code. The bytes only meet the parser at the end of the pipeline.
The Next.js ImageResponse chain adds one more step. Satori turns JSX into SVG before Sharp rasterizes the result.

This meant that each target could also have a different path to reach the parser and exploit the flaw.
The use-after-free
SVG is XML, and its syntax can use entities and XInclude. An entity works as a name for a piece of XML. XInclude can load another document during parsing.
The input that triggers the flaw fits entirely inside one image. The first SVG uses XInclude to load a second document from a data: URL. This second SVG declares the active entity, and expanding it loads a third document:
<!DOCTYPE svg [
<!ENTITY active '<xi:include href="data:image/svg+xml,..." parse="xml"/>'>
]>
<svg xmlns:xi="http://www.w3.org/2001/XInclude">
&active;
</svg>
While libxml2 expands &active;, librsvg starts another parse to load the third SVG. That document declares a new entity with the same name:
<!DOCTYPE svg [
<!ENTITY active "R">
]>
Both parses use the same entity map in librsvg. When the second active enters the map, HashMap::insert() replaces the first one. Rust drops the old wrapper, and its Drop implementation calls xmlFreeNode():
impl Drop for XmlEntity {
fn drop(&mut self) {
unsafe { xmlFreeNode(self.0) }
}
}
pub fn entity_insert(&self, name: &str, entity: xmlEntityPtr) {
self.inner
.borrow_mut()
.entities
.insert(name.to_string(), XmlEntity(entity));
}
libxml2 is still expanding the first entity. It keeps a pointer to that xmlEntity even after librsvg frees it.
When the inner parse finishes, the outer parse continues and updates fields through the old pointer. By then, the memory may belong to another object. This is the use-after-free.

From freed memory to RCE
A UAF only gives access to memory that has already been freed. To reach RCE, another object had to take that space and turn writes through the old pointer into something controllable.
On the target used during the research, xmlEntity took 144 bytes. After the free(), an allocation for librsvg’s own Path.commands reused that chunk. This array stored the commands of an SVG <path> element.
When libxml2 wrote to the old xmlEntity again, it was actually changing the path data. One of those writes corrupted the discriminant of a PackedCommand. The optimized code trusted that value and ended up transferring control through coordinates supplied by the SVG.
In short, the UAF turned attacker-controlled bytes into memory corruption that redirected execution to a stack pivot and a ROP chain. A stack pivot changes the stack pointer to another place in memory, allowing execution to continue through a controlled payload.
The payload stored the ROP chain in the coordinates themselves. The official Node.js build used in the test was non-PIE, so its executable addresses stayed fixed even with ASLR. The chain performed the stack pivot, built the arguments in memory, and called:
execve("/bin/sh", ["/bin/sh", "-c", command], NULL)
In the exploit, each qword in the ROP chain became a valid number for the path’s d attribute:
coords = [number_from_bits(value) for value in rop]
path_commands[i] = (
f"M{coords[offset]} {coords[offset + 1]}"
)

This part of the exploit depends on the build. The chain here was made for Node.js 24.20.0, Sharp 0.35.4, libvips 8.18.6, librsvg 2.62.91, and libxml2 2.15.3. Another binary may lay out memory differently and require another payload.
This build dependency is common in memory corruption flaws. Even when the impact is serious, they are not trivial to exploit, especially without a way to leak memory addresses. Many hosted applications use Node.js binaries compiled as PIE with ASLR enabled. These protections randomize the addresses of the executable and its libraries, while a ROP chain depends on known addresses to direct execution to the intended command.
The Next.js chain
The ImageResponse mentioned earlier generates images from JSX. In the Node.js runtime, Satori produces an SVG and Sharp converts it into the final image.
A vulnerable route could be as small as this:
import { ImageResponse } from 'next/og'
export const runtime = 'nodejs'
export async function POST(request) {
const value = await request.text()
return new ImageResponse(
<svg width="1200" height="630">
<title>{value}</title>
</svg>
)
}
Satori did not correctly escape some values before inserting them into the generated SVG. Instead of sending an image, the attacker could close the current element and add their own XML:
</title>
<xi:include href="data:image/svg+xml,..." parse="xml"/>
<title>
The chain combined two flaws. The injection in Satori let the attacker place controlled XML in the SVG through fields such as <title>, and the use-after-free in librsvg turned that XML into memory corruption and then command execution.
I reported the vulnerability to Vercel, which published it as CVE-2026-94545 and fixed the escaping in Satori 0.33.5.
PoC
This video shows the PoC for CVE-2026-94545. The script generates the body with the ROP chain. A single POST request then sends it to the ImageResponse route.
/og route in the test environment.The exploit replaces the Node process with /bin/sh, runs id > /tmp/vectorfreed-proof, and exits. This is why curl receives an empty reply. I then read the file from the stopped container. The uid=1000(node) output confirms that the code ran as the worker.
Reach beyond Next.js
ImageResponse was only the beginning, one of the paths that could take the SVG to the parser. I later reported a second path in Next.js to Vercel. It passed through the Image Optimization API without relying on Satori. An attacker-controlled image passed the SVG rejection and was later identified as SVG by Sharp.
Ghost was another product where I confirmed RCE. A Contributor could create a bookmark card for a page they controlled. Ghost fetched its og:image, converted the SVG with Sharp, and reached the same bug. This case became CVE-2026-105642.
Beyond the two Next.js paths, I confirmed the flaw through real product routes in 17 downstream applications. I list only the ones that, while I was writing this post, already used a fixed version or blocked the input before the parser:
- Lightdash
- Strapi
- PeerTube
- Reactive Resume
- Misskey
- Penpot
- Puter
- Payload CMS
- PostHog
The paths included avatar uploads, preview generation, image conversion, and metadata processing. In every case, attacker-controlled bytes reached an affected version of the parser.
Fix
The librsvg fix prevents an entity still in use by libxml2 from being freed during recursive parsing. It landed in commit 8a1b0cd and shipped in librsvg 2.63.2, with backports for maintained versions.
For Node.js applications that use Sharp’s prebuilt binaries, updating only the system copy of librsvg may change nothing. Sharp brings its own libvips and dependencies. Sharp 0.35.5 started shipping the fixed stack.
The VectorFreed PoC generates the minimum input for the use-after-free and different carriers for testing application routes. It can verify whether the bytes reach the parser. The full exploit must be treated as build-specific.
Timeline
| Date | Event |
|---|---|
| Sep 1, 2026 | I sent the use-after-free report to the librsvg maintainer. |
| Sep 18, 2026 | librsvg 2.63.2 was released with the fix. |
| Sep 19, 2026 | I reported the Satori and Next.js flaws by email. |
| Sep 22, 2026 | Next.js and Satori published the advisories for the ImageResponse chain. |
| Sep 23, 2026 | RustSec published RUSTSEC-2026-0305. |
| Sep 30, 2026 | I reported the second Next.js route, through the Image Optimization API, on HackerOne. |
| Oct 1, 2026 | Ghost published CVE-2026-105642. |
| Oct 14, 2026 | Vercel published the second Next.js path, through the Image Optimization API. |
Extras
This is the largest vulnerability chain I have found so far. It affected dozens of products used by thousands of people across the internet.
I especially want to thank the librsvg maintainer, who worked quickly on a fix after confirming the flaw. We spoke a few times over email, and I was able to help test the fix and improve the parser’s security. I also want to thank the Vercel team, which worked on patches in under a week in both cases I sent.
References
- VectorFreed
- CVE-2026-96889
- RUSTSEC-2026-0305
- librsvg fix
- CVE-2026-94545: Next.js ImageResponse
- Satori fix
- Next.js Image Optimization
- CVE-2026-105642: Ghost
- Sharp 0.35.5
- Critical Next.js ImageResponse Flaw Can Lead to Server Code Execution via Crafted SVG Input
- Next.js Ships Out-of-Band Patch for Two Critical RCE Flaws in Caching and SVG Processing
- HEIF Heist
- ImageTragick
