Skip to main content
Menu
Advisories

OAuth access tokens accepted in query strings were written to HTTP access logs; CLI printed token prefixes in debug output

GHSA-M54P-GWMP-Q2RRPublished Updated GitHub

Description

The Lightdash OAuth2 server was configured with allowBearerTokensInQueryString, so any API request could authenticate with '?access_token=<token>'. Two global express-winston middlewares log every request URL at the http level (the production default), routing req.url through sanitizeRequestUrl, which redacted only downloadtoken, code and state - not access_token or refresh_token. Live bearer tokens therefore landed in request logs readable by operators and log pipelines. Separately, the CLI printed the first ten characters of the OAuth authorization code, access token and personal access token in verbose output. The fix redacts access_token and refresh_token in logged URLs (including case, bracket and percent-encoded variants) and stops the CLI printing token prefixes.

Details

The OAuthService constructed its OAuth2Server with allowBearerTokensInQueryString: true unconditionally, and the authentication middlewares feed the raw Express request (query string included) to the OAuth2 server's authenticate handler, so GET /api/v1/<anything>?access_token=<token> both authenticated and flowed through request logging. Both express-winston middlewares are mounted before the API router, log the full req.url including the query string, and run at the http level, which is the production default log level with console output; POST bodies are whitelisted out of logging, so the token endpoint itself never leaked, but any query-string bearer request did. An earlier fix redacted code, state and downloadtoken but left access_token/refresh_token unredacted, so this exposure survived that change. The leaked access token is a live bearer credential for the victim's API access with read/write scope and a default one-hour lifetime; refresh tokens do not legitimately appear in request URLs, so that half of the redaction is defense in depth. In the CLI, oauthLogin printed 'Got authorization code <prefix>', 'OAuth access token: <prefix>' and 'PAT: <prefix>' when run with --verbose; tokens are a known prefix plus a 64-character nanoid, so the printed ten characters expose only a few secret characters - not usable alone, but a partial-secret disclosure into terminals and CI logs. The fix adds access_token and refresh_token to the redaction list with decoding for case variants, bracket notation and percent-encoded names, and replaces the CLI prints with value-free messages.

Impact

Anyone with read access to the instance's request logs (log aggregation platforms, ops tooling, support bundles, or raw log files - typically a wider audience than application administrators) could obtain live OAuth access tokens for users whose clients authenticate via query-string bearer tokens, and replay them for full API access as those users for up to the token lifetime. The CLI issue additionally leaks token prefixes into verbose terminal and CI output.

Attacker-controlled source: No crafted input is required for the server issue: any client legitimately authenticating with a query-string access_token (permitted by the server, RFC 6750 section 2.3 form) causes the token to be written to the access log under default configuration. Exploitation requires read access to the log store. For the CLI, a user running 'lightdash --verbose login' writes token prefixes to their own terminal or CI log.

Security boundary: Bearer tokens are meant to exist only in the authorization channel between client and server. Writing them into durable, broadly readable log storage moves live authentication credentials across the boundary to anyone with log read access, which is commonly granted to support and operations tooling well beyond the set of users trusted with account credentials.

Effective impact after existing controls: Passive disclosure of live OAuth access tokens (default one-hour lifetime, read/write capability, effectively session-equivalent under default scope enforcement) to readers of the instance's request logs, on the default configuration. Exploitation requires both a client using query-string bearer authentication and log read access; there is no integrity or availability impact beyond what the stolen token's capabilities permit, and no remote trigger against an arbitrary victim. The CLI component discloses only an unusable token prefix in opt-in verbose output.

Workaround

On affected versions, set LIGHTDASH_LOG_LEVEL to warn or higher so the http-level access log is not emitted, and restrict read access to log storage and aggregation. Avoid clients that pass access_token as a query parameter (use the Authorization header instead), and avoid running the CLI login flow with --verbose on shared machines or in CI.

Remediation

Upgrade to a release containing the fix, which redacts access_token and refresh_token values in logged request URLs as the application's query parser reads them and removes token values from CLI verbose output. Rotate OAuth tokens for any user whose tokens may have been captured in logs before upgrading.

Private review evidence

Fix commits:

Fix pull requests:

Changed-code evidence:

  • packages/backend/src/logging/winston.ts: Pre-fix sanitizeRequestUrl redacted only downloadtoken/code/state; both global express-winston middlewares log the full req.url at the http level. The fix adds access_token/refresh_token with encoded and bracket-form coverage.
  • packages/backend/src/services/OAuthService/OAuthService.ts: OAuth2Server configured with allowBearerTokensInQueryString: true unconditionally, so query-string tokens were honored for authentication.
  • packages/backend/src/controllers/authentication/middlewares.ts: allowOauthAuthentication/allowApiKeyAuthentication pass the raw request (query included) to the OAuth2 authenticate handler, making the query-string bearer a working credential.
  • packages/backend/src/logging/sanitizeRequestUrl.test.ts: Fix-commit tests pin redaction of access_token/refresh_token across case, bracket and percent-encoded variants and preservation of lookalike parameters.
  • packages/cli/src/handlers/oauthLogin.ts: Pre-fix printed the first ten characters of the authorization code, access token and PAT in verbose mode; the fix prints value-free confirmations.
  • packages/backend/src/config/parseConfig.ts: Production default log level is http, so the vulnerable logging is active in the default configuration.

Existing controls checked:

  • packages/backend/src/logging/winston.ts: The request whitelist (url, headers, method) keeps POST bodies out of logs, so the token endpoint was safe; only query-string tokens in URLs were exposed, and the pre-fix sanitizer did not cover access_token/refresh_token.
  • packages/backend/src/config/parseConfig.ts: LIGHTDASH_LOG_LEVEL falls back to http in production, so the access log carrying the tokens is enabled by default and could not redact the values through configuration.
  • packages/backend/src/routers/oauthRouter.ts: The authorize flow's code and state parameters were already redacted; no other path places refresh tokens in request URLs, bounding the refresh_token half of the fix to defense in depth.

Independent skeptical verification:

Independently verified by the security-finding-verifier agent against the vulnerable and fixed tags. It confirmed the pre-fix redaction list, both logging sinks and their global mounting, the production http-level default, and that the query-string bearer was actually accepted (server option plus library behavior plus middleware chain). It also established that no other realistic path places tokens in logged URLs, assessed the CLI print as a partial-secret disclosure only, and pinned the fix commit's first containing tag via git ancestry. Static analysis; not dynamically exercised against a live instance.

Verifier evidence:

  • packages/backend/src/logging/winston.ts: Verifier confirmed both express-winston sinks route req.url through sanitizeRequestUrl and that the pre-fix list lacked access_token/refresh_token while the fix covers case/bracket/encoded variants.
  • packages/backend/src/services/OAuthService/OAuthService.ts: Verifier confirmed allowBearerTokensInQueryString: true at the vulnerable tag and traced the library's query access_token extraction.
  • packages/cli/src/handlers/oauthLogin.ts: Verifier confirmed the verbose-mode token prefix prints pre-fix and their removal post-fix, and assessed the exposed prefix as not usable to authenticate alone.

Reviewer checklist

  • Confirm this is exploitable rather than defense-in-depth.
  • Recalculate CVSS and verify CWE identifiers.
  • Verify affected and patched version boundaries for every product.
  • Verify the workaround and fixed artifacts.
  • Request the CVE while this advisory is private.

<!-- lightdash-ai-security-draft:v1 fingerprint=1e51f8fecdcec34653edacc8cdf2fe27dc86e4b51ca5ecf1bc688aabbf9b992d release=2.537.1 -->

Affected versions

References

GitHub · lightdash/lightdash