CVE-2026-67448: Mailpit: WebSocket origin check bypass via percent-encoded path (regression of CVE-2026-22689)

Published Aug 20, 2026
·
Updated

Summary

The cross-site WebSocket hijacking fix was reimplemented as an origin check gated on a raw-URI prefix test, but Go's ServeMux routes on the percent-decoded path, so requesting /%61pi/events reaches the WebSocket handler while skipping the only origin control, and the upgrader itself accepts every origin. Confirmed at HEAD 408b30d. Affects 1.29.0 through 1.30.5.

The defect

Two halves that were each correct in isolation. server/websockets/client.go accepts any origin and delegates the check elsewhere:

go var upgrader = websocket.Upgrader{ // line 33 ... CheckOrigin: func( http.Request) bool { // line 37 // origin is checked via server.go's CORS settings return true // line 39 }, }

server/server.go performs that check but keys it on the RAW request target:

go if strings.HasPrefix(r.RequestURI, config.Webroot+"api/") || htmlPreviewRouteRe.MatchString(r.RequestURI) { // line 320 if allowed := corsOriginAccessControl(r); !allowed { http.Error(w, "Blocked due to CORS violation", http.StatusForbidden) return }

r.RequestURI is the untouched wire target; Go's ServeMux routes on the percent-DECODED path. So for /%61pi/events: strings.HasPrefix("/%61pi/events", "/api/") is FALSE (origin check skipped), ServeMux decodes %61 to "a" and routes to /api/events, and the upgrader's CheckOrigin returns true.

Measured, default config, no auth: /api/events with Origin: https://evil.example returns 403; /%61pi/events with the same Origin returns 101 Switching Protocols and begins streaming. With a message delivered over SMTP while the cross-origin socket was open, the attacker origin received the ID, Message-Id, From, To, Cc, Bcc, Subject ("SECRET password reset token abc123"), size, tags, and body Snippet, live. WebSockets are not subject to CORS response-header enforcement, so the absent Access-Control-Allow-Origin header provides no protection once the upgrade succeeds.

Regression provenance: commit 6f1f4f3 (2026-01-10, v1.28.2) fixed CVE-2026-22689 by DELETING CheckOrigin; commit a63bcd9 (2026-01-31, first in v1.29.0) reintroduced CheckOrigin returning true and replaced the protection with the bypassable raw-prefix test.

Attacker model and verification

Any website the developer visits while Mailpit is running. No credentials, no ability to send mail, no interaction beyond visiting a page. Requires Mailpit without --ui-auth-file (the default, and the same precondition as the original CVE). The bypass was measured live against a real Mailpit instance on loopback, including the 403-versus-101 control pair; authentication still holds (the encoded path returns 401 when --ui-auth-file is set); browser reachability was confirmed against the WHATWG URL parser, which preserves %61.

Suggested fix

Do not make security decisions on r.RequestURI. Key the check on r.URL.Path, the decoded value the router uses, so the gate and the route agree. Better, restore a real CheckOrigin on the upgrader so the WebSocket carries its own origin enforcement rather than depending on a middleware prefix match. Secondary (Low, not claimed as XSS): server/apiv1/message.go lines 154-155 echo an attacker-chosen Content-Type with Content-Disposition: inline; this is blocked today by the nonce CSP.

Tooling

I used AI assistance while investigating. The bypass was measured live against a real Mailpit instance on loopback, including the 403-versus-101 control pair and the authenticated 401 case, and I separately confirmed at HEAD the CheckOrigin returning true with its delegating comment and the RequestURI-keyed prefix gate.

Other sources

Mailpit is an email testing tool and API for developers. From 1.29.0 until 1.30.6, Mailpit's server/server.go origin middleware checks the raw RequestURI for the /api/ prefix while Go's ServeMux routes using the percent-decoded URL path, and server/websockets/client.go configures websocket.Upgrader.CheckOrigin to return true. A malicious website can request /%61pi/events, skip corsOriginAccessControl(), reach the /api/events WebSocket handler, and receive live message IDs, Message-Id values, sender and recipient fields, subjects, tags, and body snippets from an unauthenticated default Mailpit instance after the user visits the site. This is a regression of the earlier WebSocket origin protection and does not affect deployments protected by --ui-auth-file. This issue is fixed in version 1.30.6.

MITRE

Affected Software

1 affected componentFixes available
go/github.com/axllent/mailpit>=1.29.0<=1.30.5
1.30.6

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/github.com/axllent/mailpit to a version that resolves this vulnerability.

    Fixed in 1.30.6
  2. Upgrade

    Upgrade Mailpit to a version that resolves this vulnerability.

    Fixed in 1.30.6
  3. Configuration

    Ensure websocket.Upgrader.CheckOrigin returns an origin-validated result and keys the /api route gating on the decoded path (r.URL.Path, the value ServeMux routes on) so the origin check and the router agree; do not use the raw wire target (r.RequestURI / prefix test) for the /api prefix gate.

    Mailpit WebSocket upgrader (server/websockets/client.go) websocket.Upgrader.CheckOrigin = origin enforcement based on decoded URL path (r.URL.Path) rather than unconditional true
  4. Configuration

    Change the origin middleware check that currently evaluates strings.HasPrefix on r.RequestURI (raw, percent-encoded wire target) to instead evaluate strings.HasPrefix on r.URL.Path (decoded path) so that percent-encoded bypasses like /%61pi/events cannot skip the origin control.

    Mailpit server origin middleware (server/server.go) origin middleware /api prefix check input = r.URL.Path

Event History

Aug 20, 2026
CVE Published
via MITRE·09:29 PM
Data Sourced
via MITRE·09:29 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·09:34 PM
Data Sourced
via GitHub·09:34 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which versions require remediation?

Mailpit versions 1.29.0 through 1.30.5 are affected. The referenced fixed release is v1.30.6.

2

What does an exploit request need to do?

It must use a percent-encoded route such as /%61pi/events. ServeMux decodes that path to reach the WebSocket handler, while the raw-URI prefix check does not recognize it as an API route and skips the origin control.

3

Why does skipping the server-level check allow the WebSocket connection?

The WebSocket upgrader's CheckOrigin callback accepts every origin. It relies on the separate server-level CORS/origin check, which is bypassed by the encoded request path.

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