# GHSA-J7QM-JHPC-MJ26: @fastify/swagger-ui vulnerable to documentation authentication bypass via the unprotected /static route

- Database: GitHub
- Severity: CVSS 3.7 (Low)
- Published: 2026-11-20
- Modified: 2026-11-20

## Tracked as

- [CVE-2026-133273](https://cve.now/CVE-2026-133273.md): Fastify Swagger UI auth bypass via unprotected static route in API docs

## Affected versions

- @fastify/swagger-ui (npm): from 2.1.0, fixed in 6.1.5

## Description

### Impact

`@fastify/swagger-ui` lets applications protect the documentation with `uiHooks` (the `onRequest` and `preHandler` authentication hooks described in the README). Those hooks are applied to every route the plugin adds except the `@fastify/static` instance mounted at `<routePrefix>/static/`. When `baseDir` is set, which the README recommends for bundling the UI, that instance serves every file in `baseDir`, so a file the operator protected at `<routePrefix>/<file>` is also reachable without credentials at `<routePrefix>/static/<file>`. An unauthenticated client who knows or guesses a file name can read specification files that were meant to stay behind the documentation login. Access is read-only, and the `/json`, `/yaml` and UI page routes stay protected. Versions 2.1.0 through 6.1.4 are affected.

### Patches

Upgrade to `@fastify/swagger-ui` 6.1.5 or later, which applies the `uiHooks` to the `/static` route as well. The bundled Swagger UI assets are now served behind the same hooks. Basic and cookie or session authentication keep working because the browser sends same-origin credentials for those requests; a header-only bearer scheme or a proxy that injects authentication may need the assets on a separate public path or an authentication-aware same-origin proxy.

### Workarounds

Enforce authentication in a Fastify hook registered before `@fastify/swagger-ui` so it also runs for the `/static` route, or do not set `baseDir` (without it, only the public bundled assets are served under `/static/`).

### References

- [GHSA-62jr-84gf-wmg4](https://github.com/fastify/fastify-swagger-ui/security/advisories/GHSA-62jr-84gf-wmg4) (CVE-2024-22207), an earlier file exposure in `@fastify/swagger-ui`'s static serving.

## References

- https://github.com/fastify/fastify-swagger-ui/security/advisories/GHSA-j7qm-jhpc-mj26

Page: https://cve.now/GHSA-J7QM-JHPC-MJ26
