Repository navigation
Harden query parsing - #28521
Merged
Merged
Harden query parsing#28521
Conversation
…rectus-ghsa-mcgv-x48q-r8xf into harden-query-parsing
… past QUERY_FILTER_MAX_DEPTH
Co-authored-by: judda <44623501+ComfortablyCoding@users.noreply.github.com>
…rectus-ghsa-mcgv-x48q-r8xf into harden-query-parsing
ComfortablyCoding
approved these changes
Nov 16, 2026
1 of 13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What's Changed
Bounded the work that parsing a single query can cause, and reworked a number of patterns whose
worst-case cost grew faster than the length of their input.
Query parameters
filteranddeep, rejected with the existingInvalidQueryError, which names the limit it hit and its configured value. The allowance is spentacross a whole query, so a filter nested under
deepdraws on what is left rather than startingover.
$CURRENT_USER,$CURRENT_ROLE,$CURRENT_ROLESand$CURRENT_POLICIESpaths in a filter toMAX_RELATIONAL_DEPTH, the same bound as the fields they are fetched as.GraphQL
limitSelectionsvalidation rule that counts the fields an operation selects once itsfragments are expanded, and rejects it past
GRAPHQL_QUERY_SELECTION_LIMIT. It runs over HTTP andWebSocket, for the operation being executed.
an alias under an m2a member landing at the wrong
deeppath.deepin place instead of merging into a fresh copy ofeverything already under the path.
Environment variables
QUERY_FILTER_MAX_NODES10000filter/deepnodes across a queryQUERY_FILTER_MAX_DEPTH50deepGRAPHQL_QUERY_SELECTION_LIMIT10000Set any of them to
Infinityto opt out. An unusable value is logged once and the default used.WebSocket
MAX_PAYLOAD_SIZEon incoming messages. A larger message closes the connection with1009; before this, onlyws's own 100MB cap applied.client instead of escaping as an unhandled rejection that takes the process down.
Linear-time parsing
adjustDate,generateJoi's_ends_withfamily, XMP metadata parsing,deep-map-filter,use-promptsand the release-notes generator, and madeget()iterative.adjustDateandget()also take a hard cap on input length and path depth.regexp/no-super-linear-backtrackingas an error repo-wide.Tested Scenarios
Review Notes / Questions / Concerns
QUERY_FILTER_MAX_NODESis the one that will bind: every object, array and value counts, so an_inover 9997 values is rejected.{ ...F ...F }costsFtwice againstGRAPHQL_QUERY_SELECTION_LIMIT. The count matches exactly what the resolvers build.Checklist
@directus/specs)@directus/sdk) updated to reflect the changes@directus/types) updated to reflect the changes@directus/system-data) updated for changes to system collections/fields/relationsFixes CMS-3036
Fixes CMS-3045
Fixes CMS-3047
Fixes CMS-3046
Fixes CMS-3044