November 13, 2026
I Almost Didn’t Report This XSS. The Maintainer Fixed More Than I Asked.
By Jeg4nX19
By Jegann
6 min read
This is the story of a bug I nearly left sitting in a folder, a lot of grep, and a maintainer who turned out to be much nicer than the voice in my head expected.
Here's the short version. The API docs page generated by @elysiajs/openapi, the OpenAPI plugin for the Bun framework Elysia, could be tricked into running an attacker's JavaScript. It's fixed in 1.4.17, and there's a published advisory, GHSA-7p63-qhhv-4m99, so I can show you everything: how I found it, how I tested it, and the part where I nearly chickened out.
Grab a coffee. There are memes.
Step 1: I didn't find this bug. I copied someone else's homework.
I didn't wake up and decide to audit Elysia. It started with someone else's advisory.
A few weeks earlier I'd read CVE-2026-33331, an XSS in oRPC's API docs page. The root cause fits in one sentence: values from the OpenAPI document were dropped into an HTML page without escaping.
When I read an advisory, I don't think "cool, fixed." I think: who else wrote the same code?
Developers copy patterns. If one docs renderer builds its HTML with a big template string, there's a good chance five others do too. This is called variant hunting, and it's the laziest, most effective trick I know.
Step 2: Turning one bug into a search pattern
First I worked out what the bug looks like in code, so I could search for it anywhere. The dangerous shape is any of these:
`<title>${something}</title>` // raw value inside an HTML element
`<meta content="${something}">` // raw value inside an HTML attribute
`<script>init(${JSON.stringify(something)})` // JSON inside an inline <script>`<title>${something}</title>` // raw value inside an HTML element
`<meta content="${something}">` // raw value inside an HTML attribute
`<script>init(${JSON.stringify(something)})` // JSON inside an inline <script>The third one fools a lot of people, including past me. JSON.stringify makes valid JSON, so it feels safe. But it doesn't escape < or >, and the browser's HTML parser reads the page before JavaScript does. If your JSON contains </script>, the parser thinks the script is over, right there in the middle of your string.
So my search list was simple: template strings that build HTML, with a value that might come from the OpenAPI spec dropped inside.
Step 3: Make a list, then read what's actually shipped
Next I listed every Swagger UI or OpenAPI docs package I could think of across JavaScript frameworks: the Hono one, the Elysia ones, NestJS, Fastify, Express, hapi and more, plus standalone renderers like Redoc, RapiDoc and Scalar.
Then a detail that matters: I didn't read the GitHub source. I read the npm tarballs. What's on GitHub is what the authors meant to ship. What's on npm is what's actually running in people's apps. Sometimes they differ.
npm pack @elysiajs/openapi@1.4.16
tar -xzf elysiajs-openapi-1.4.16.tgz
grep -rn 'content="${\|<title>${\|JSON.stringify' package/dist/npm pack @elysiajs/openapi@1.4.16
tar -xzf elysiajs-openapi-1.4.16.tgz
grep -rn 'content="${\|<title>${\|JSON.stringify' package/dist/
Step 4: Most of them were fine (and that's useful too)
This is the part nobody puts in their blog post: most packages were safe. That's normal, and it's still useful, because knowing why something is safe makes you better at spotting when something isn't.
- NestJS puts the spec in a separate JavaScript file, not inside the HTML page, so there's no HTML parser to trick.
- Fastify and swagger-ui-express load the spec by URL instead of pasting it into the page.
- Redoc, RapiDoc and Scalar's standalone components pass data through properties, not strings.
And then a few lit up. @hono/swagger-ui had the same problem (fixed in 0.6.2, that's another story). One more is still going through disclosure, so I'm leaving it out. And Elysia had the most sinks of all.
Step 5: The bug itself
Here's the relevant part of the HTML @elysiajs/openapi 1.4.16 generated for its Swagger UI page, simplified:
return `<!DOCTYPE html>
<html>
<head>
<title>${info.title}</title>
<meta name="description" content="${info.description}" />
<meta name="og:description" content="${info.description}" />
...`return `<!DOCTYPE html>
<html>
<head>
<title>${info.title}</title>
<meta name="description" content="${info.description}" />
<meta name="og:description" content="${info.description}" />
...`No escaping at all. info.title goes straight into <title>. info.description goes straight into a double-quoted attribute, and it does that twice.
If the description contains a ", the attribute ends. A > closes the <meta> tag. Everything after that is brand-new HTML, and the browser happily runs any <script> it finds.
Step 6: Testing it for real
Reading code gives you a theory. I wanted proof, in three steps.
Test 1: a realistic app. I built a tiny Elysia app where the docs description comes from somewhere other than the developer's keyboard. Think of a multi-tenant API portal where each customer writes their own API description, or a value read from a database:
const untrusted = process.env.DESC ?? 'Development documentation'
new Elysia()
.use(openapi({
provider: 'swagger-ui',
documentation: { info: { title: 'Acme API', version: '1.0.0', description: untrusted } }
}))
.listen(8811)const untrusted = process.env.DESC ?? 'Development documentation'
new Elysia()
.use(openapi({
provider: 'swagger-ui',
documentation: { info: { title: 'Acme API', version: '1.0.0', description: untrusted } }
}))
.listen(8811)Test 2: does the payload come back unescaped? I set the description to this:
"><script>/* draw a big red banner */</script>"><script>/* draw a big red banner */</script>Then I asked the server with curl:
$ curl -s http://127.0.0.1:8811/openapi | grep -n 'content='
9: content=""><script>addEventListener("DOMContentLoaded",function(){...})</script>"
13: content=""><script>addEventListener("DOMContentLoaded",function(){...})</script>"$ curl -s http://127.0.0.1:8811/openapi | grep -n 'content='
9: content=""><script>addEventListener("DOMContentLoaded",function(){...})</script>"
13: content=""><script>addEventListener("DOMContentLoaded",function(){...})</script>"The payload is there, raw, in both meta tags. But I've learned the hard way that seeing a payload in a response isn't proof. Browsers are weird, and plenty of "XSS" reports die right here.
Test 3: does a real browser execute it? I loaded the page in a real Chromium browser and took a screenshot:
Two banners, because there are two sinks: each <meta> tag ran my script once. Swagger UI is complaining underneath because my test spec was junk, which doesn't matter. Those red boxes were drawn by injected JavaScript, running in the docs page's origin.
The control. I always run one boring test too: the same app with a normal description renders a normal page. That proves it's the payload doing the damage, not something odd in my setup.
Step 7: The part where I almost didn't send it
Here's the honest bit.
After building all of that, I finally read Elysia's SECURITY.md. Yes, after. In short, it says plugins should be reported to their own repo (this one had no private reporting), and that problems which need the developer to pass in their own schemas are generally out of scope unless end-user input crosses a trust boundary.
That described my bug almost perfectly. No Elysia app is vulnerable by default. You have to put untrusted data into info.title or info.description yourself.
I seriously considered not sending it. A lot of maintainers would reply "don't do that, then", and they'd have a point.
But I kept coming back to one idea: a library that writes HTML should escape what it writes. "Don't pass untrusted data" is a fine rule, but the page builder is exactly where one missing escapeHtml() protects everyone who breaks that rule by accident.
So I sent a short, polite email to the maintainer and framed it as hardening, not "your framework is broken". I included the PoC, said clearly that it needs attacker-influenced docs metadata, and said I'd understand if he called it out of scope.
Step 8: What happened next
The maintainer, SaltyAom, replied, confirmed it, and then fixed more than I reported:
- the Swagger UI title and description sinks I'd found
- the matching sinks in the Scalar provider, which I hadn't even tested
- provider configuration crossing script, attribute and style contexts
- regression tests for all of it
Version 1.4.17 shipped on November 4, 2026, and he published GHSA-7p63-qhhv-4m99 with credit to me. It covers three packages: @elysia/openapi, @elysiajs/openapi and the legacy @elysiajs/swagger.
Of course I re-ran the exact same payload against 1.4.17:
content=""><script>addEventListener("DOMContentLoaded" ...content=""><script>addEventListener("DOMContentLoaded" ...Every dangerous character is now an HTML entity. The browser sees text, not tags. No banners.
Should you care?
Be honest with yourself here, like the advisory is:
- You were fine if your docs title, description and provider config are static strings you wrote yourself. That's most apps.
- You were exposed if any of it comes from users, tenants, a database, or an upstream spec you don't control.
- Either way, upgrade to
@elysiajs/openapi1.4.17 or later. - Still on
@elysiajs/swagger? It won't get a fix. Move to@elysiajs/openapi.
What I took away
- Read other people's advisories. The best bug-hunting question is "who else wrote this?"
- Read what's shipped. The npm tarball is the truth, not the README.
- "Safe" results teach you things. Knowing why NestJS was fine helped me see why Elysia wasn't.
- Prove it in a real browser. A reflected payload is a hint. A running script is proof. Run a control, too.
- Read SECURITY.md first. I knew this and still did it in the wrong order.
- Be honest about preconditions. Don't oversell, don't hide the caveat, and let a good maintainer make the call.
- Say thank you. Fast, thorough fixes from volunteer maintainers aren't guaranteed. Thank you, SaltyAom.
There's no CVE ID on the advisory yet. I've requested one, so for now my CVE collection is still waiting patiently.
Disclosure timeline: reported privately on October 27, 2026. Confirmed and fixed, 1.4.17 released, and GHSA-7p63-qhhv-4m99 published on November 4, 2026. CVE requested.