Skip to main content
Menu
Advisories

WebSocket short tokens can access management APIs and renew after logout

GHSA-GP79-J356-RR7MPublished Updated GitHub

Description

Short tokens intended for WebSocket authentication are also accepted by the general AuthRequired middleware on management HTTP routes. A party who obtains a valid short token can therefore use it as an explicit Authorization credential on HTTP APIs.

Since v2.3.6, POST /api/token/short issues standalone short-token rows that are not associated with the parent JWT row. Logging out with the parent JWT does not remove these standalone rows. The mint endpoint checks only that the _nginx_ui_secure_session cookie is non-empty, not that it is bound to the authenticated session, so a holder of an unexpired short token can supply an arbitrary cookie value to mint another token.

Scope and prerequisites

The attacker must first obtain a valid short token; this is not unauthenticated login or escalation to a different user role. HTTP acceptance of short tokens was introduced in v2.1.10. The standalone-token logout and renewal chain was introduced in v2.3.6. Each short token has a 24-hour expiry unless renewed. Routes protected by RequireSecureSession still require fresh OTP or passkey step-up for accounts with 2FA enabled. The impact is broader for routes without that step-up and accounts without 2FA.

This is distinct from GHSA-wq4w-vwvq-q3x9, which addressed short-token cache resurrection after administrative revocation and account re-enablement.

Technical details

AuthRequired selects GetTokenUserByShortToken for a token of at most 16 characters without limiting that branch to WebSocket routes. GenerateShortToken stores a standalone AuthToken with an empty Token field and its own ShortToken. Logout calls DeleteToken with the Authorization header and deletes by the Token field, so deleting a parent JWT row does not match a standalone short-token row. IssueShortToken accepts any non-empty _nginx_ui_secure_session cookie and uses the authenticated user to create another standalone short token.

Reproduction outline

  1. Obtain a valid short token from an authorized test login and use it as an Authorization credential on GET /api/nginx/status. The ordinary HTTP route authenticates the short token.
  2. Issue a standalone token through POST /api/token/short. Log out using DELETE /api/logout with the parent raw JWT Authorization header. The standalone token remains usable. The paired short token created by login is a separate case and is normally removed with the JWT row.
  3. Before the standalone token expires, call POST /api/token/short with that token and Cookie: _nginx_ui_secure_session=arbitrary. A fresh standalone token is issued.

The reporter's original GET /api/nginx and POST /api/logout examples are not registered routes; the claimed 200 response for GET /api/nginx cannot be reproduced as written.

Impact

Disclosure of a WebSocket short token may expose non-WebSocket management APIs. An independently minted short token may survive ordinary JWT logout and can be renewed while valid. This does not by itself bypass routes protected by RequireSecureSession, and operating-system code execution is not asserted as a direct outcome.

Fix status

The fix was committed in 1b022804ea20e99053f1a0514416c851f1f34d1d. The commit is tagged in the public v2.7.0 and v2.8.1 releases. Versions v2.6.3 and earlier remain affected.

Affected versions

References

GitHub · 0xJacky/nginx-ui