fixed potential sql injection with new tags feature#751
Merged
Bionic711 merged 1 commit intoDevelopmentfrom Mar 2, 2026
Merged
fixed potential sql injection with new tags feature#751Bionic711 merged 1 commit intoDevelopmentfrom
Bionic711 merged 1 commit intoDevelopmentfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens document tag filtering to prevent OData filter injection in Azure AI Search by validating tag filter inputs against the same whitelist used when tags are saved.
Changes:
- Added
sanitize_tags_for_filter()to normalize + validate tag filter inputs and drop invalid entries. - Updated personal/group/public document listing routes to use
sanitize_tags_for_filter()when parsingtagsfilters. - Hardened
build_tags_filter()infunctions_search.pyto validate tags before building OData filter expressions; added functional test + fix documentation + release notes; bumped version to0.238.025.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| functional_tests/test_tag_filter_sanitization.py | Adds a functional regression test covering valid/invalid tag filter inputs and injection-style payloads. |
| docs/explanation/release_notes.md | Documents the fix under v0.238.025 release notes. |
| docs/explanation/fixes/TAG_FILTER_INJECTION_FIX.md | Adds a dedicated fix write-up with root cause + validation notes. |
| application/single_app/route_backend_documents.py | Uses sanitize_tags_for_filter() when parsing tags query filter (personal docs). |
| application/single_app/route_backend_group_documents.py | Uses sanitize_tags_for_filter() when parsing tags query filter (group docs). |
| application/single_app/route_backend_public_documents.py | Uses sanitize_tags_for_filter() when parsing tags query filter (public docs). |
| application/single_app/functions_search.py | Validates tags via sanitize_tags_for_filter() before interpolating into OData filter expressions. |
| application/single_app/functions_documents.py | Introduces sanitize_tags_for_filter() to enforce the tag whitelist + length limit for filter inputs. |
| application/single_app/config.py | Version bump from 0.238.024 → 0.238.025. |
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.
Bug Fixes
sanitize_tags_for_filter()function to validate tag filter inputs against the same^[a-z0-9_-]+$character whitelist enforced when saving tags.normalize_tag()(strip + lowercase) without character validation, allowing arbitrary characters to reach OData filter construction inbuild_tags_filter().build_tags_filter()infunctions_search.pyto validate tags before interpolating into OData expressions, eliminating the OData injection vector.sanitize_tags_for_filter()for defense-in-depth.functions_documents.py,functions_search.py,route_backend_documents.py,route_backend_group_documents.py,route_backend_public_documents.py.TAG_FILTER_INJECTION_FIX.md,sanitize_tags_for_filter)