GHSA-cff8-x7jv-4fm8 CVE-2024-45596
Session is cached for OpenID and OAuth2 if `redirect` is not used
- Severity
- 0.0 / 10
- Medium · CVSS 4.0
- Exploit chance (EPSS)
- 0.66%
- Chance of exploitation in the next 30 days. Higher than 51.39% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Fix
- Available
- 2 packages have a fixed version
Description
Summary
Unauthenticated user can access credentials of last authenticated user via OpenID or OAuth2 where the authentication URL did not include redirect query string.
For example:
- Project is configured with OpenID or OAuth2
- Project is configured with cache enabled
- User tries to login via SSO link, but without
redirectquery string - After successful login, credentials are cached
- If an unauthenticated user tries to login via SSO link, it will return the credentials of the other last user
The SSO link is something like https://directus.example.com/auth/login/openid/callback, where openid is the name of the OpenID provider configured in Directus
Details
This happens because on that endpoint for both OpenId and Oauth2 Directus is using the respond middleware, which by default will try to cache GET requests that met some conditions. Although, those conditions do not include this scenario, when an unauthenticated request returns user credentials.
For OpenID, this can be seen here:
https://github.com/directus/directus/blob/main/api/src/auth/drivers/openid.ts#L453-L459
And for OAuth2 can be seen here
https://github.com/directus/directus/blob/main/api/src/auth/drivers/oauth2.ts#L422-L428
PoC
- Create a new Directus project
- Set
CACHE_ENABLEDto true - Set
CACHE_STOREtoredisfor reliable results (if using memory with multiple nodes, it may only happen sometimes, due to cache being different for different nodes) - Configure
REDISwith redis string or redis host, port, user, etc. - Set
AUTH_PROVIDERStoopenid - Set
PUBLIC_URLto the the main URL of your project . For example,PUBLIC_URL: http://localhost:8055 - Configure
AUTH_OPENID_CLIENT_ID,AUTH_OPENID_CLIENT_SECRET,AUTH_OPENID_ISSUER_URLwith proper OpenID configurations - Be sure that on OpenID external app you have configured Redirect URI to
http://localhost:8055/auth/login/openid/callback - Run Directus
- Open the SSO link like
http://localhost:8055/auth/login/openid/callback - Do the authentication on the OpenID external webpage
- Verify that it you got redirected to a page with a JSON including
access_tokenproperty - Be sure all anonymous mode windows are closed
- Open an anonymous window and go to the SSO Link
http://localhost:8055/auth/login/openid/callbackand see you have the same credentials, even though you don't have any session because you are in anonymous mode
Impact
All projects using OpenID or OAuth 2, that does not include redirect query string on loggin in users.
Affected versions
npm
| Package | Vulnerable | Fixed in |
|---|---|---|
| @directus/api | < 21.0.1 |
21.0.1 |
| @directus/api | >= 22.0.0, < 22.2.0 |
22.2.0 |
| directus | < 10.13.3 |
10.13.3 |
| directus | >= 11.0.0-rc.1, < 11.1.0 |
11.1.0 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
@directus/api npm → 21.0.1
- npm
npm install @directus/api@21.0.1- yarn
yarn add @directus/api@21.0.1- pnpm
pnpm add @directus/api@21.0.1
directus npm → 10.13.3
- npm
npm install directus@10.13.3- yarn
yarn add directus@10.13.3- pnpm
pnpm add directus@10.13.3
Severity breakdown
CVSS 4.0 0.0
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N
- Attack vector
- Network
- Attack complexity
- Low
- Attack requirements
- None
- Privileges required
- None
- User interaction
- Passive
- Confidentiality (vulnerable system)
- High
- Integrity (vulnerable system)
- None
- Availability (vulnerable system)
- None
- Confidentiality (subsequent systems)
- High
- Integrity (subsequent systems)
- None
- Availability (subsequent systems)
- None
CVSS 3.1 7.4
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- Required
- Scope
- Changed
- Confidentiality
- High
- Integrity
- None
- Availability
- None
Weakness
CWE-384: Session Fixation
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.
How to prevent it
- Architecture and Design: Invalidate any existing session identifiers prior to authorizing a new user session.
- Architecture and Design: For platforms such as ASP that do not generate new values for sessionid cookies, utilize a secondary cookie. In this approach, set a secondary cookie on the user's browser to a random value and set a session variable to the same value. If the session variable and the cookie value ever don't match, invalidate the session, and force the user to log on again.
- Operation: Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].
CWE-524: Use of Cache Containing Sensitive Information
The code uses a cache that contains sensitive information, but the cache can be read by an actor outside of the intended control sphere.
How to prevent it
- Architecture and Design: Protect information stored in cache.
- Architecture and Design: Do not store unnecessarily sensitive information in the cache.
- Architecture and Design: Consider using encryption in the cache.
References
Advisories
Packages
Other links
- github.com/directus/directus/security/advisories/GHSA-cff8-x7jv-4fm8
- github.com/directus/directus/commit/4aace0bbe57232e38cd6a287ee475293e46dc91b
- github.com/directus/directus/commit/769fa22797bff5a9231599883b391e013f122e52
- github.com/directus/directus/blob/main/api/src/auth/drivers/oauth2.ts
- github.com/directus/directus/blob/main/api/src/auth/drivers/openid.ts
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-c6w9-5g5j-jh2p Directus: Authorization-dependent response served from unsegmented cache key | High | Also affects directus |
| GHSA-j5h6-vqc3-phqh Directus: SSRF Protection Bypass via 0.0.0.0 in File Import | High | Also affects directus |
| GHSA-38hg-ww64-rrwc Directus: Authenticated Users Can Extract Concealed Fields via Aggregate Queries | High | Also affects directus |
| GHSA-6q22-g298-grjh Directus: Unauthenticated Denial of Service via GraphQL Alias Amplification of Expensive Health Check Resolver | High | Also affects directus |
| GHSA-ph52-67fq-75wj Directus: GraphQL Alias Amplification Denial of Service Due to Missing Query Cost/Complexity Limits | Medium | Also affects directus |
| GHSA-mvv8-v4jj-g47j Directus: Sensitive fields exposed in revision history | Medium | Also affects directus |
| GHSA-qqmv-5p3g-px89 Directus: TUS Upload Authorization Bypass Allows Arbitrary File Overwrite | High | Also affects directus |
| GHSA-wv3h-5fx7-966h Directus: SSRF Protection Bypass via IPv4-Mapped IPv6 Addresses in File Import | High | Also affects directus |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor