Repository navigation
FIX: Detect Boolean NOT and null byte truncation in LDAPInjectionOutputScorer (#3261) - #3262
Open
RohithPariki wants to merge 3 commits into
Open
RohithPariki wants to merge 3 commits into
RohithPariki wants to merge 3 commits into
Conversation
This branch has not been deployed
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.
Fixes #3261.
Description
LDAPInjectionOutputScorerflags LDAP injection search filter payloads in model responses (OWASP LLM02). However, its default patterns missed two RFC 4515 LDAP search filter injection primitives:!):Under RFC 4515 Section 3, LDAP search filters support three boolean grouping operators:
&(AND),|(OR), and!(NOT). Attackers commonly inject negation clauses (admin)(!(password=*)),admin)|(!(uid=*)),admin)&(!(objectClass=*)),*)((!(mail=*))),)(!(objectClass=void))) to bypass attribute and access control filters.Boolean Operator InjectionandFilter Break Sequencepreviously only recognized|and&, omitting the NOT operator!.Boolean Operator InjectionandFilter Break Sequenceto recognize!and compound negation clauses (such as)|(!or)(!(), while also supporting optional whitespace around the=operator (e.g.!(password = *)).%00,\x00,\0,\00):In directory services and C-based client libraries, a null byte terminates string parsing and causes trailing filter clauses (such as
(active=1)) to be dropped.Null Byte Filter Terminationpattern to flag filter breaks terminated by null bytes, supporting both wildcard breaks (admin*)%00,admin*)\x00,admin*)\0,*)(uid=*))%00) and standard filter closures (admin)%00,admin)\x00,admin)\0).Tests and Documentation
tests/unit/score/regex/test_ldap_injection_output_scorer.py:admin)%00,admin)\x00,admin)\0).=.Boolean Operator InjectionandNull Byte Filter Termination.python -m pytest tests/unit/score/regex/test_ldap_injection_output_scorer.py -q: 31 passed.python -m ruff check pyrit/score/true_false/regex/ldap_injection_output_scorer.py tests/unit/score/regex/test_ldap_injection_output_scorer.py: Clean.python -m ruff format --check pyrit/score/true_false/regex/ldap_injection_output_scorer.py tests/unit/score/regex/test_ldap_injection_output_scorer.py: Clean.