GHSA-hxgm-ghmv-xjjm

Suggest an improvement
Source
https://github.com/advisories/GHSA-hxgm-ghmv-xjjm
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/07/GHSA-hxgm-ghmv-xjjm/GHSA-hxgm-ghmv-xjjm.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-hxgm-ghmv-xjjm
Aliases
  • CVE-2024-39701
Published
2024-07-08T18:37:54Z
Modified
2024-11-18T16:26:49Z
Severity
  • 6.3 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:N/A:N CVSS Calculator
  • 7.0 (High) CVSS_V4 - CVSS:4.0/AV:N/AC:H/AT:N/PR:L/UI:N/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N CVSS Calculator
Summary
Directus incorrectly handles `_in` filter
Details

Summary

Directus >=9.23.0, <=v10.5.3 improperly handles in, _nin operators. It evaluates empty arrays as valid so expressions like {"role": {"in": $CURRENTUSER.somefield}} would evaluate to true allowing the request to pass.

Details

This results in Broken Access Control because the rule fails to do what it was intended to do: Pass rule if field matches any of the values. ref: https://docs.directus.io/reference/filter-rules.html#filter-operators In my example this would translate to "Pass rule if <collection>.role matches any of []". Which should fail. This instead passes in Directus <= v10.5.3, >=v9.23.0

PoC

{"role": {"in": $CURRENTUSER.somefield}} field validation would pass if $CURRENTUSER.some_field is null.

Real scenario: Using https://github.com/u12206050/directus-extension-role-chooser with the specified versions of Directus (I tested on 10.0.0) allows users with access to this feature set their role to whatever role if they don't have any roles assigned (user_roles.role is left with the default value, null) despite the validation rule being

validation:
    role:
      _in: $CURRENT_USER.user_roles.role

Latest version of Directus (v10.8.3 and above) handles the above validation rule correctly.

Impact

Permissions fail to open for setups relying on this filter and can lead to users getting access to things they're not supposed to.

Database specific
{
    "github_reviewed_at": "2024-07-08T18:37:54Z",
    "github_reviewed": true,
    "nvd_published_at": "2024-07-08T17:15:11Z",
    "cwe_ids": [
        "CWE-284"
    ],
    "severity": "HIGH"
}
References

Affected packages

npm / directus

Package

Affected ranges

Type
SEMVER
Events
Introduced
9.23.0
Fixed
10.6.0

Database specific

{
    "last_known_affected_version_range": "<= 10.5.3"
}