OpenAI Hacked with a 1-Year-Old Bug
Transcript
In a previous video, I introduced you to the story of how a one year old vulnerability in an image
parser library was used to hack into OpenAI. And now that we have the high level story out
of the way, let's start digging into the technical details. In this short series, you will see AI is really good at exploitation, but there still seems to
be a very human skill in prioritizing and following real intuitions from experiences.
At least, that's what it looks like. AI doesn't seem to be really good at that part yet. Otherwise, OpenAI wouldn't have been hackable with a known vulnerability, right? But Harsh, a human who started this research,
is really good at that. So let's see how he did it.
First of all, he selected Discourse as a good target, because it's open source and so much
easier to look into for vulnerabilities. But he very quickly did not look
for vulnerabilities in Discourse directly, but went for dependencies.
And Discourse uses ImageMagick, which is historically a dangerous piece of software.
As mentioned before, ImageMagick is a program to convert lots of different image formats, and it
does that by delegating it to other programs, or integrating libraries of other formats.
And parsing file formats is one of those very high risk areas. History has shown us that over and over again, we get vulnerabilities in parsing.
And I like to refer to the whole idea of langsec language theoretic security.
And there's even this famous xkcd. Two, three, four, seven about dependencies,
how our whole technology stack depends on some obscure library, but it even
directly mentions ImageMagick. Some day. ImageMagick will finally break for good,
and we will all have a long period of scrambling as we try to reassemble civilization from the rubble. So, of course, when looking for vulnerabilities,
it can be a very good idea to look for any kind of image handling.
And some image formats are easier to exploit than others. For example, there have been lots of XML parsing issues, or command injections in
ImageMagick that can be easily exploited remotely. However, in the last 10 to 15 years before AI
memory Corruption vulnerabilities have gotten very complex to exploit, especially on remote.
And so we would often see memory corruptions only used in very targeted attacks against
high value individuals or organizations. And that has changed now, as you will see.
So, let's head back to the drawing board and look for what to actually target in ImageMagick.
Looking through the sources, you can see that ImageMagick has tons of dependencies,
and any of those could be a good target. For JPEG, it would be Turbo-jpeg.
For PNG, it's Libpng. For SVG, it can be Librsvg.
But Harsh felt like all those implementations felt more mature.
They have been battle tested and fussed a lot more, except HEIF images.
Libheif somehow felt more promising to him. Also, he remembered seeing that Discourse
treated HEIF images differently. FastImage was used for several checks
if the image format was supported, but HEIF images were directly parsed into ImageMagick.
So this seems like a good target. But where do you start now? I guess first, we need to know which version of Libheif is actually used by Discourse,
because maybe we don't need a zero day. We can use a bug fixed in later
versions. Oh. What's happening? Welcome to Can You Beat the Machine?
Sponsored by Hextree.io, our wonderful cybersecurity learning platform.
So can you answer this question, or do I need to ask the machine?
Take a moment and pause the video to think about this. And then let's see what the AI answers. Of course, the best method to figure out
the Libheif version used by Discourse is to look into the running Docker container,
because it contains the complete build and all the installed dependencies.
And I think all of you actually got this right, because you learned this from the last video where
I mentioned this already. So even in 2026, you can still learn stuff. Good job. And that's, of course, also why you should check out Hextree.io, our online training platform. AI is changing cybersecurity dramatically,
but a strong understanding of the fundamentals remains very valuable.
Harsh actually set up this course using the Discourse Docker images for local testing.
And then he just used this prompt here for the agent in this Docker container.
Given the Docker container ID, check the installed Libheif package and determine whether it contains
any security vulnerabilities that provide out-of-bounds, read, or write primitives.
And then the agent started looking around for a bit and came back with results.
The agent identified a commit that looks suspicious.
Simplify overlay, overlap area computation. Well, the text is not suspicious,
but the code it touches does look suspicious. First, the code checks that Rd is not negative,
and right after, it claims that we know Rd is always positive.
So something is fishy in this code, but more about the actual vulnerability in the next video.
Because I want to first talk about the issue with vulnerable dependencies,
because I think it's kind of weird why you could hack OpenAI with a
vulnerability that was fixed one year ago. Shouldn't it have been patched a long time ago?
The dependency tree for OpenAI basically looks like this. OpenAI uses Discourse. Discourse. Used Debian 12 as the Docker base
image, and Debian 12 installs the Libheif dependency from Debian package registry.
So, let's see how vulnerability fixes travel upstream.
Looking at the release cadence of Libheif, it can sometimes take a few months before you have a new release. The fix for the vulnerability we are talking
about was in a commit in May 2025, but then it was part of the release version 1.2 in July 2025, and,
of course, only after Libheif release. Debian can pick it up.
The Debian version used by Discourse was version 12, originally released in 2023, and by default,
it came with Libheif version 1.15.1, but eventually, Backports were released in 2024
and 2025, bringing the version up to 1.19.7. Unfortunately, not containing the fixes yet.
In August 2025, Debian 13 was released basically one month after the fixed release in Libheif,
but it was still the vulnerable version. 1.9.8. And here, it's important to understand,
it's not like Debian is checking the day before a Debian release which version to use.
Debian 13 was in development for two years, where they had to make sure
that packages don't break other stuff. So, at some point, which I guess was 3
to 4 months before the release, they froze the Libheif version.
But don't complain about Debian maintainers, because they have thousands of packages
they somehow need to manage, and they definitely want to bring security fixes.
Unfortunately, in this case, the fix seemed unintentional, and it never received a CVE.
So, how would Debian know that this is an important release that they need to bring into the newest version? Now, there was another known CVE of Libheif at the
time, but that one was labeled as a minor issue. So maybe that's why it wasn't prioritized.
This CVE, by the way, reads like the vulnerability we are looking at. It's in the same function, but it's actually not. We will take a brief look at it next. Video.
When we look at the vulnerability details, then you will understand the differences to our vulnerability. Anyway, Auerbach never got a CVE.
There was only a minor issue, so Debian didn't prioritize to bring this new version of Libheif
for the latest Debian release. Then, in May and July of 2026,
Libheif received a lot of vulnerability reports, and several CVEs were issued.
This was also the time when more capable cyber models got released. So, I guess it makes sense that we got a flood of vulnerabilities. And now that more security relevant fixes have accumulated.
Eventually, a Debian maintainer named Aron Xu worked on bringing those fixes to Debian 13,
and we finally receive a backport for Debian 13 in August 2026, which means,
even if Discourse had used Debian 13. This was still too late to
prevent the hack of OpenAI. In July 2026, and now we come to Discourse.
In August 2024, they updated the Debian version of their base Docker image to Debian 12, codenamed
bookworm, and then they didn't think of updating it when Debian 13 Codeword tricksy got released.
But I also don't think it's obvious that updating a base image for a web
application can be important. Discourse is a web app, and you write all your code in a high level programming language, and install
all the dependencies when you build the image. Why would the base image matter? Well, Discourse.
Implementing an image conversion feature. Used. ImageMagick, which is using dependencies to
other image formats controlled by the Linux distribution.
So you are getting old libraries, but even updating to Debian 13 would have
not helped this course, because the Libheif backports came in August, one month too late.
So, you can see, if we think about the release cadence of the different dependencies in this
chain, it can take a long time until fixes travel upstream, leaving applications exposed
to serious vulnerabilities for quite a long time. So, how do you prevent this from happening again?
Well, this course fixed this by installing Libheif version very deliberately,
not relying on the distribution, which they were also already doing for other image libraries.
So they get the latest versions. But now you also need to maintain this
yourself and pay attention to updating it. Otherwise, you will end up with outdated
dependencies again. I think this example shows that managing dependencies is probably one of the most important tasks right now
for defenders in application security. Now, you have seen the way how we can
approach a target and do some research on the versions installed, and use an agent to help
us dig through lots of code and commits to find the vulnerability that still affects our target.
And then, next video, we will finally look at the vulnerability itself.





