Case Study for Improper Authentication in GitLab (CVE-2022-22213) #35
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We describe a vulnerability in GitLab's OAuth login flow (CVE-2021-22213) that caused GitLab to expose OAuth access tokens in the URL fragment when redirecting its users. Due to security policy violations in Safari, the token was also exposed in the URLs of sites controlled by attackers, making it easy for attackers to steal the token and impersonate users. GitLab resolved the bug by not putting the token in the URL visible in the browser and not sending the token except in server-side requests. GitLab uses the incident as a case study to teach CWE-287 (Improper Authentication) and stresses not putting OAuth tokens in URLs visible in the browser, using secure OAuth flows (e.g., Authorization Code with PKCE), testing browser behavior, using Content Security Policies, and automated leak detection.