← 输入框|github.com|刷新
Skip to content

[web-console] Revoke the refresh token on sign-out - #7782

Closed
bestouff wants to merge 1 commit into
mainfrom
pentest-int-30989
Closed

bestouff wants to merge 1 commit into
mainfrom
pentest-int-30989

Conversation

@bestouff

@bestouff bestouff commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Fixes pentest finding INT-30989 (CWE-613, sign-out does not revoke the OIDC refresh token).

Problem

Sign Out cleared the console's local state and ended the provider's browser session, but the OIDC client was configured with logout_tokens_to_invalidate: [], so nothing was ever sent to the revocation endpoint. A copy of the refresh token kept minting access tokens after the user had signed out.

Change

File Change
js-packages/web-console/src/lib/compositions/@axa-fr/auth.ts logout_tokens_to_invalidate: ['refresh_token']
js-packages/web-console/src/lib/components/auth/ProfileButton.svelte aria-label on the signed-in profile button, which had no accessible name
scripts/dummy_oidc.py revocation_endpoint in discovery and POST /revoke (RFC 7009)
js-packages/web-console/tests/auth/logout.e2e.ts New auth e2e test

Access tokens are not revoked on purpose: Cognito's revoke endpoint only accepts refresh tokens, and the manager validates JWTs locally, so a revoked access token would keep working until it expires either way. Shortening the access token validity on the Cognito app client is an infra change outside this repo.

Test

The new e2e test signs in through the dummy provider, reads the refresh token from sessionStorage, clicks Sign Out, asserts the revoke request carried that token with token_type_hint=refresh_token, then replays the token against /token and expects invalid_grant.

Run locally against a manager with generic OIDC auth and scripts/dummy_oidc.py: the test passes with the fix and fails with a timeout waiting for the revoke request when the config line is reverted. The other four auth e2e tests still pass.

Sign Out cleared the console's local state and ended the provider's browser
session, but never called the token revocation endpoint: the OIDC client was
configured with `logout_tokens_to_invalidate: []`. A copy of the refresh token
kept minting access tokens after the user had signed out (pentest finding
INT-30989, CWE-613).

Sign-out now sends the refresh token to the revocation endpoint before the
local state is destroyed. Access tokens are not sent: Cognito rejects them,
and the manager validates the JWT locally, so revoking one at the provider
would not shorten its remaining lifetime anyway.

The dummy OIDC provider used by the auth e2e suite gains a `revocation_endpoint`
and `POST /revoke`. A new e2e test signs in, signs out, checks that the revoke
request carried the stored refresh token, and checks that the provider then
refuses a replay of that token. The signed-in profile button gets the same
`aria-label` as the signed-out one so the test can open it.
Comment on lines +31 to +42
const revokePromise = page.waitForRequest(
(req) => req.method() === 'POST' && /\/revoke$/.test(req.url())
)
await signOut(page)
const revoke = await revokePromise
const params = new URLSearchParams(revoke.postData() ?? '')
expect(params.get('token')).toBe(refreshToken)
expect(params.get('token_type_hint')).toBe('refresh_token')

// The provider has processed the revocation once the console is back on
// its login page. A replay of the refresh token must fail from then on.
await page.waitForURL((url) => url.pathname === '/authorize' || url.pathname === '/')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: possible flakiness (medium). loginAs leaves the page on the console, often at /. waitForURL checks the current URL first, so this predicate can pass straight away, before the redirect even starts. waitForRequest resolves once the request is sent, not once it has been handled. dummy_oidc.py runs a ThreadingHTTPServer, and the replay below goes out on its own connection, so it can race the /revoke handler. Waiting on the response removes the race and also checks the status:

const revokePromise = page.waitForResponse(
  (res) => res.request().method() === 'POST' && /\/revoke$/.test(res.url())
)
await signOut(page)
const revokeRes = await revokePromise
expect(revokeRes.status()).toBe(200)
const revoke = revokeRes.request()

With that change, the waitForURL is no longer needed.

@mythical-fred-oss

Copy link
Copy Markdown
Contributor

Review: revoke the refresh token on sign-out

The fix is correct. I read @axa-fr/oidc-client 7.26.4: logoutAsync revokes when a revocation_endpoint exists, sends client_id (needed for Cognito public clients), times out after 10s, and catches errors. So a revoke that fails or hangs cannot block sign-out. The Cognito path already sets oauth2/revoke, and generic OIDC gets the endpoint from discovery.

What I ran Result
pre-commit run --files <changed> ✅ pass
bun run test-unit ✅ 466/466 node tests pass. The browser project could not start because no chromium is installed here; this PR doesn't touch it.
Ran dummy_oidc.py by hand: code → token → refresh 200 → POST /revoke 200 (with CORS headers) → refresh replay returns 400 invalid_grant; unknown token → 200 ✅
Auth e2e suite ⚠️ not run, because it needs a manager with OIDC enabled
  • Flaky-test gate (medium): the new e2e test can race the /revoke handler. See the inline comment for a deterministic fix. This should be fixed before merge.
  • Missing coverage (medium): nothing checks that sign-out still finishes when revocation fails. Two cases would cover it: /revoke returns 4xx/5xx (the library ignores non-200 without even a warning), and the provider advertises no revocation_endpoint. You could add both with page.route('**/revoke', r => r.fulfill({ status: 500 })) / r.abort(), then assert that the console still lands on the login page.
  • Pitfall (medium): Cognito only honours /oauth2/revoke if "token revocation" is enabled on the app client (it is on by default only for clients created after 2021). If it is off, sign-out looks fine but the token is not revoked, and nothing gets logged. Please confirm the deployed app client has it enabled.

@Karakatiza666

Copy link
Copy Markdown
Contributor

Adopted and superseded by #7781

@Karakatiza666
Karakatiza666 deleted the pentest-int-30989 branch November 3, 2026 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants