Ecosyste.ms: Advisories
An open API service providing security vulnerability metadata for many open source software ecosystems.
Security Advisories: GSA_kwCzR0hTQS1jZmY4LXg3anYtNGZtOM4AA_cb
Session is cached for OpenID and OAuth2 if `redirect` is not used
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
redirect
query 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_ENABLED
to true - Set
CACHE_STORE
toredis
for reliable results (if using memory with multiple nodes, it may only happen sometimes, due to cache being different for different nodes) - Configure
REDIS
with redis string or redis host, port, user, etc. - Set
AUTH_PROVIDERS
toopenid
- Set
PUBLIC_URL
to 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_URL
with 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_token
property - Be sure all anonymous mode windows are closed
- Open an anonymous window and go to the SSO Link
http://localhost:8055/auth/login/openid/callback
and 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.
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1jZmY4LXg3anYtNGZtOM4AA_cb
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: 5 months ago
Updated: 5 months ago
CVSS Score: 7.4
CVSS vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N
EPSS Percentage: 0.00045
EPSS Percentile: 0.17541
Identifiers: GHSA-cff8-x7jv-4fm8, CVE-2024-45596
References:
- https://github.com/directus/directus/security/advisories/GHSA-cff8-x7jv-4fm8
- https://github.com/directus/directus/commit/4aace0bbe57232e38cd6a287ee475293e46dc91b
- https://github.com/directus/directus/commit/769fa22797bff5a9231599883b391e013f122e52
- https://github.com/directus/directus/blob/main/api/src/auth/drivers/oauth2.ts#L422-L428
- https://github.com/directus/directus/blob/main/api/src/auth/drivers/openid.ts#L453-L459
- https://nvd.nist.gov/vuln/detail/CVE-2024-45596
- https://github.com/advisories/GHSA-cff8-x7jv-4fm8
Blast Radius: 15.2
Affected Packages
npm:@directus/api
Dependent packages: 9Dependent repositories: 95
Downloads: 32,304 last month
Affected Version Ranges: >= 22.0.0, < 22.2.0, < 21.0.1
Fixed in: 22.2.0, 21.0.1
All affected versions: 9.25.0, 9.25.1, 9.25.2, 9.26.0, 10.0.0, 10.1.0, 10.2.0, 11.0.0, 11.0.1, 11.1.0, 12.0.0, 12.0.1, 12.0.2, 12.0.3, 12.1.0, 12.1.1, 12.1.2, 12.1.3, 13.0.0, 13.1.0, 13.1.1, 13.2.0, 14.0.0, 14.0.1, 14.0.2, 14.1.0, 14.1.1, 14.1.2, 15.0.0, 16.0.0, 17.0.0, 17.0.1, 17.1.0, 18.0.0, 18.1.0, 18.1.1, 18.2.0, 18.2.1, 19.0.0, 19.0.1, 19.0.2, 19.1.0, 19.1.1, 19.2.0, 19.3.0, 19.3.1, 20.0.0, 20.1.0, 21.0.0, 22.0.0, 22.1.0, 22.1.1
All unaffected versions: 21.0.1, 21.0.2, 22.2.0, 23.0.0, 23.1.0, 23.1.1, 23.1.2, 23.1.3, 23.2.0, 23.2.1, 23.2.2, 23.3.0, 23.3.1, 23.3.2, 24.0.0
npm:directus
Dependent packages: 16Dependent repositories: 115
Downloads: 36,483 last month
Affected Version Ranges: >= 11.0.0-rc.1, < 11.1.0, < 10.13.3
Fixed in: 11.1.0, 10.13.3
All affected versions: 9.0.0, 9.0.1, 9.1.0, 9.1.1, 9.1.2, 9.2.0, 9.2.1, 9.2.2, 9.3.0, 9.4.0, 9.4.1, 9.4.2, 9.4.3, 9.5.0, 9.5.1, 9.5.2, 9.6.0, 9.7.0, 9.7.1, 9.8.0, 9.9.0, 9.9.1, 9.10.0, 9.11.0, 9.11.1, 9.12.0, 9.12.1, 9.12.2, 9.13.0, 9.14.0, 9.14.1, 9.14.2, 9.14.3, 9.14.5, 9.15.0, 9.15.1, 9.16.0, 9.16.1, 9.17.0, 9.17.1, 9.17.2, 9.17.3, 9.17.4, 9.18.0, 9.18.1, 9.19.0, 9.19.1, 9.19.2, 9.20.0, 9.20.1, 9.20.2, 9.20.3, 9.20.4, 9.21.0, 9.21.2, 9.22.0, 9.22.1, 9.22.3, 9.22.4, 9.23.1, 9.23.3, 9.23.4, 9.24.0, 9.25.0, 9.25.1, 9.25.2, 9.26.0, 10.0.0, 10.1.0, 10.1.1, 10.2.0, 10.2.1, 10.3.0, 10.3.1, 10.4.1, 10.4.2, 10.4.3, 10.5.0, 10.5.1, 10.5.2, 10.5.3, 10.6.0, 10.6.1, 10.6.2, 10.6.3, 10.6.4, 10.7.0, 10.7.1, 10.7.2, 10.8.0, 10.8.1, 10.8.2, 10.8.3, 10.9.0, 10.9.1, 10.9.2, 10.9.3, 10.10.0, 10.10.1, 10.10.2, 10.10.3, 10.10.4, 10.10.5, 10.10.6, 10.10.7, 10.11.0, 10.11.1, 10.11.2, 10.12.0, 10.12.1, 10.13.0, 10.13.1, 10.13.2, 11.0.0, 11.0.0-rc.1, 11.0.0-rc.2, 11.0.0-rc.3, 11.0.1, 11.0.2
All unaffected versions: 10.13.4, 11.1.0, 11.1.1, 11.1.2, 11.2.0, 11.2.1, 11.2.2, 11.3.0, 11.3.1, 11.3.2, 11.3.3, 11.3.4, 11.3.5, 11.4.0