Skip to content

Directus incorrectly handles `_in` filter

Moderate severity GitHub Reviewed Published Jul 8, 2024 in directus/directus • Updated Aug 7, 2024

Package

npm directus (npm)

Affected versions

>= 9.23.0, <= 10.5.3

Patched versions

10.6.0

Description

Summary

Directus >=9.23.0, <=v10.5.3 improperly handles _in, _nin operators.
It evaluates empty arrays as valid so expressions like {"role": {"_in": $CURRENT_USER.some_field}} 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 .role matches any of []". Which should fail. This instead passes in Directus <= v10.5.3, >=v9.23.0

PoC

{"role": {"_in": $CURRENT_USER.some_field}} field validation would pass if $CURRENT_USER.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.

References

@br41nslug br41nslug published to directus/directus Jul 8, 2024
Published by the National Vulnerability Database Jul 8, 2024
Published to the GitHub Advisory Database Jul 8, 2024
Reviewed Jul 8, 2024
Last updated Aug 7, 2024

Severity

Moderate

EPSS score

0.043%
(10th percentile)

Weaknesses

CVE ID

CVE-2024-39701

GHSA ID

GHSA-hxgm-ghmv-xjjm

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.