DEV-15456: Added validation methods for group and filter fields to prevent regex injection - #4703
Merged
Merged
Conversation
…event regex injection
…o fix validation logic when resolving more complex paths
sethstoudenmier
previously approved these changes
Jul 27, 2026
sethstoudenmier
left a comment
Contributor
There was a problem hiding this comment.
Overall LGTM! Ideally, we will move away from the v1 endpoints and replace with v2, but this is a great middle ground for now.
james-at-kc
reviewed
Jul 28, 2026
| if all(seg in allowed_lookups for seg in remaining_segments): | ||
| # All remaining segments are valid lookups, validation complete. | ||
| return | ||
| raise InvalidParameterException(f"Invalid field: {field_path}") |
Contributor
There was a problem hiding this comment.
Now uses f"" strings throughout per suggestion.
james-at-kc
approved these changes
Jul 28, 2026
james-at-kc
left a comment
Contributor
There was a problem hiding this comment.
LGTM. improved code by using f-strings as suggested in previous approval.
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.
Description:
DEV-15456: Sanitize Postgres input [f112]
Fixing a vulnerability that allowed unauthenticated attackers to inject arbitrary Django ORM lookup suffixes (particularly __regex/__iregex) into aggregate group parameters and filter field paths, enabling regex DoS attacks and schema enumeration.
AC: Implement model-based validation that validates field paths against Django model schemas.
Technical Details:
Changes:
common/mixins.py):_resolve_field_path()method to validate group parameter fields segment-by-segment._meta.get_field()API.treasury_account__federal_account_id).__fy) defined in_sql_function_transformations(line 78).InvalidParameterExceptionfor invalid field paths.common/api_request_utils.py):_validate_filter_field()and_resolve_field_path()methods toFilterGenerator._get_allowed_lookups()that derives safe Django lookups from operators dictionary.__regexand__iregexlookups to prevent ReDoS attacks.__len__gtfor ArrayField length checks).Requirements for PR Merge:
Explain N/A in above checklist: