Skip to content

FIX: Detect Boolean NOT and null byte truncation in LDAPInjectionOutputScorer (#3261) - #3262

Open
RohithPariki wants to merge 3 commits into
microsoft:mainfrom
RohithPariki:fix/ldap-injection-negation-and-null-byte
Open

RohithPariki wants to merge 3 commits into
microsoft:mainfrom
RohithPariki:fix/ldap-injection-negation-and-null-byte

Conversation

@RohithPariki

@RohithPariki RohithPariki commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3261.

Description

LDAPInjectionOutputScorer flags LDAP injection search filter payloads in model responses (OWASP LLM02). However, its default patterns missed two RFC 4515 LDAP search filter injection primitives:

  1. RFC 4515 Boolean NOT Operator (!):
    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 Injection and Filter Break Sequence previously only recognized | and &, omitting the NOT operator !.
    • Updated Boolean Operator Injection and Filter Break Sequence to recognize ! and compound negation clauses (such as )|(! or )(!(), while also supporting optional whitespace around the = operator (e.g. !(password = *)).
  2. Null Byte Filter Truncation (%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.
    • Added Null Byte Filter Termination pattern 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

  • Updated tests/unit/score/regex/test_ldap_injection_output_scorer.py:
    • Added test cases covering negation filter break sequences, disjunction negation, conjunction negation, and null-byte filter truncation variants with and without wildcards (admin)%00, admin)\x00, admin)\0).
    • Added test cases verifying optional whitespace around =.
    • Added negative test cases verifying no false positives on normal multiplication or percentage expressions.
    • Verified rationale inclusion for Boolean Operator Injection and Null Byte Filter Termination.
  • Ran tests and lint checks:
    • 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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: LDAPInjectionOutputScorer misses RFC 4515 Boolean NOT (!) operator and null byte filter truncation

2 participants