# GHSA-JM5Q-PQ3R-26G9: Bitbucket OAuth refresh token exposed in request URL

- Database: GitHub
- Severity: CVSS 2.3 (Low)
- Published: 2026-09-01
- Modified: 2026-09-01

## Affected versions

- decap-cms-lib-auth (npm): from 2.5.0-beta.0, through 3.2.1
- decap-cms (npm): from 2.11.0-beta.0, through 3.15.1
- decap-cms-app (npm): from 2.16.0-beta.0, through 3.15.1

## Description

## Summary

In the non-implicit Bitbucket authentication flow, Decap CMS places the OAuth refresh token in the query string of a `POST /auth/refresh` request while sending an empty request body. HTTPS protects the request in transit from passive network observers, but the token remains visible in the HTTP request target to the authentication service, TLS-terminating proxies, and any logging or tracing system that records full URLs.

## Details

At revision `14c5d5183ffdaf9927d78f8b3f2ae7e745690252`, the non-implicit Bitbucket refresh path is:

1. `packages/decap-cms-backend-bitbucket/src/implementation.ts:303-320` detects a Bitbucket `401` response whose message begins with `access token expired`.
2. `implementation.ts:258-285` calls `getRefreshedAccessToken()`, creates a `NetlifyAuthenticator`, and passes the stored `this.refreshToken` to `.refresh()`.
3. `packages/decap-cms-lib-auth/src/netlify-auth.js:132-153` serializes the credential into the request URL:

```javascript
const url = `${this.base_url}/${this.auth_endpoint}/refresh?provider=${provider}&site_id=${siteID}&refresh_token=${refresh_token}`;
const refreshPromise = fetch(url, { method: 'POST', body: '' }).then(res => res.json());
```

The resulting request has this shape:

```http
POST /auth/refresh?provider=bitbucket&site_id=decapcms.example&refresh_token=leaked-refresh-secret HTTP/1.1
Host: api.decapcms.example
Content-Length: 0
```

Because the credential is part of the request target, changing the HTTP method to `POST` does not keep it out of URL-based telemetry. Percent-encoding the value would not solve the issue either, because a logged encoded token remains recoverable.

## PoC

The included PoC is loopback-only and uses synthetic credentials. It starts an ephemeral HTTP server, sends the same empty-body `POST` shape used by `NetlifyAuthenticator.refresh`, records the request target, extracts the demonstration refresh token from that log entry, and replays it against a mock refresh service.

From the finding directory in the scan bundle, run:

```mjs
import assert from 'node:assert/strict';
import http from 'node:http';

const REFRESH_TOKEN = 'leaked-refresh-secret ';
const ACCESS_TOKEN = 'repo-access-token-demo';
const accessLog = [];

let tokenIsActive = true;
let isFirstRequest = true;

const server = http.createServer((request, response) => {
  accessLog.push(request.url);
  console.log(`[access] ${request.method} ${request.url}`);

  response.setHeader('Content-Type', 'application/json');

  // 503 on first request: upstream fails before token is consumed.
  if (isFirstRequest) {
    isFirstRequest = false;
    response.statusCode = 503;
    response.end(JSON.stringify({ error: 'mock upstream unavailable' }));
    return;
  }

  if (request.method !== 'POST' || !tokenIsActive) {
    response.statusCode = 401;
    response.end(JSON.stringify({ error: 'invalid refresh token' }));
    return;
  }

  tokenIsActive = false;
  response.statusCode = 200;
  response.end(JSON.stringify({
    token: ACCESS_TOKEN,
    refresh_token: 'rotated-refresh-token-demo',
  }));
});

await new Promise((resolve, reject) => {
  server.once('error', reject);
  server.listen(0, '127.0.0.1', resolve);
});

try {
  const address = server.address();
  assert(address && typeof address === 'object');
  const origin = `http://127.0.0.1:${address.port}`;
  const vulnerableURL =
    `${origin}/auth/refresh?provider=bitbucket&site_id=cms.example` +
    `&refresh_token=${REFRESH_TOKEN}`;

  // Simulates NetlifyAuthenticator.refresh: token in URL, empty POST body.
  const victimResponse = await fetch(vulnerableURL, { method: 'POST', body: '' });
  assert.equal(victimResponse.status, 503);
  console.log(`[+] refresh failed before consumption: HTTP ${victimResponse.status}`);

  // Access-log reader recovers the secret from the logged URL.
  const loggedURL = new URL(accessLog[0], origin);
  const recoveredToken = loggedURL.searchParams.get('refresh_token');
  assert.equal(recoveredToken, REFRESH_TOKEN);
  console.log(`[+] access-log reader recovered: ${recoveredToken}`);

  // Replay: observer has every input needed to complete the refresh.
  const replayResponse = await fetch(new URL(accessLog[0], origin), { method: 'POST', body: '' });
  assert.equal(replayResponse.status, 200);
  const replayBody = await replayResponse.json();
  assert.equal(replayBody.token, ACCESS_TOKEN);
  console.log(`[+] replay returned access token`);
} finally {
  await new Promise(resolve => server.close(resolve));
}
```

```sh
node poc/refresh-token-url-leak.mjs
```

Node.js 18 or later is required. Expected output:

```text
[access] POST /auth/refresh?provider=bitbucket&site_id=cms.example&refresh_token=leaked-refresh-secret
[+] refresh failed before consumption: HTTP 503
[+] access-log reader recovered: leaked-refresh-secret
[access] POST /auth/refresh?provider=bitbucket&site_id=cms.example&refresh_token=leaked-refresh-secret
[+] replay returned access token
```

The first request deliberately receives `503` before token consumption. This demonstrates the conservative case where a TLS terminator or proxy logs the credential but the provider-side exchange fails. The second request proves that the complete client-visible replay input can be recovered from the log. It does **not** claim to reproduce Bitbucket's real token lifetime or rotation behavior.

## Impact

A Bitbucket OAuth refresh token can be exchanged for an access token carrying the victim's repository authorization, creating confidentiality and integrity impact against repositories accessible through the grant. Exploitation nevertheless requires access to an unredacted URL-bearing log or tracing surface and a refresh token that remains usable at the time of exchange.

The issue maps most closely to CWE-598 because sensitive information is placed in a query string. Although CWE-598's title refers to GET requests, the exposure mechanism is the same here: the secret is in the URI and is therefore captured by request-target logging even though the method is POST.

## References

- https://github.com/decaporg/decap-cms/security/advisories/GHSA-jm5q-pq3r-26g9

Page: https://cve.now/GHSA-JM5Q-PQ3R-26G9

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
