OAuth access token not invalidated on GitLab logout
Summary
The OAuth access token issued by GitLab to the gitlab-pages daemon (and stored in the gitlab-pages session cookie) is not invalidated when the user logs out of GitLab. The token, and therefore access to the protected Pages app, remains usable until the token's natural expiry (~2 hours).
This finding was identified during the AppSec review tracked in gitlab-com/gl-security/product-security/appsec/appsec-reviews#327 (T-02, Track 1: GitLab Pages Daemon).
Severity
Medium. The finding is reduced from a higher initial rating because of existing mitigations:
- The cookie is
HttpOnly. - The OAuth access token has a 2-hour expiry.
- Scope of impact is limited to the affected user's access to Pages content.
Risk
A stolen gitlab-pages cookie (via XSS in a Pages app, machine compromise, or shared-device scenarios) remains usable after the user logs out of GitLab. Any sensitive data contained in a Pages app will be available to the attacker until the OAuth token in the cookie is invalidated (~2 hours).
A user logging out of GitLab reasonably expects that their active sessions and tokens, including those issued to downstream services like Pages, are revoked. Today they are not.
Test steps
-
Attempt to access a Pages app while not authenticated on GitLab.
-
Get redirected to authenticate on GitLab.
-
Authenticate on GitLab.
-
Get redirected back to the Pages app, now authenticated.
-
Observe the
gitlab-pagescookie hasMax-Age=600(10 minutes). -
Copy the
gitlab-pagescookie value from the Pages app. -
Log out of GitLab.
-
Use the following
curlcommand, replacing the cookie header value and the URL for your page:curl --path-as-is -i -s -k -X $'GET' \ -H $'Host: <INSERT PAGES DOMAIN>' \ -b $'<INSERT COOKIE VALUE>' \ $'https://<INSERT PAGES DOMAIN>'
Expected: request is rejected / re-authentication is required. Actual: request succeeds and the protected Pages content is returned.
Recommended remediation
Invalidate the OAuth access token (and the associated gitlab-pages session) when the user logs out of GitLab, so that Pages access cannot outlive the originating GitLab session. Options to consider include token revocation on GitLab logout, server-side session tracking that can be invalidated on logout, and/or shortening the effective lifetime of the Pages session to track GitLab session state more closely.
References
- AppSec Review: gitlab-com/gl-security/product-security/appsec/appsec-reviews#327 (T-02)
- Related finding: gitlab-org/gitlab-pages#1183 (T-03: PKCE not implemented)