Skip to content

Fix java/regex-injection CodeQL alert in TargAttrFilters - #760

Merged
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix-codeql-java-regex-injection
Jul 25, 2026
Merged

Fix java/regex-injection CodeQL alert in TargAttrFilters#760
vharseko merged 1 commit into
OpenIdentityPlatform:masterfrom
vharseko:fix-codeql-java-regex-injection

Conversation

@vharseko

Copy link
Copy Markdown
Member

Summary

Fixes CodeQL java/regex-injection alert #88 in TargAttrFilters.decode().

The targattrfilters ACI decoder built opPattern — a regular expression used to split() the sub-expression — by concatenating the operation keyword captured from the user-supplied ACI expression. The captured group can in practice only ever be the literal "add" or "del" (it comes from the (add|del) capture group of keywordFullPattern), so this is not exploitable, but the user-tainted value still flows into a regex and is flagged by CodeQL.

Change

Wrap the captured operation in Pattern.quote() before embedding it into opPattern. For "add"/"del" this is a no-op at match time (\Qadd\E matches the literal add), so runtime behaviour is unchanged, while the regex-injection data flow is removed.

Notes

  • The related alert #87 (X-PATTERN in LDAPSyntaxDescriptionSyntaxImpl) is intentionally not addressed here: that value is a regular expression by design (an LDAP syntax definition writable only with schema-write/administrative privileges), so Pattern.quote() is not applicable there.

The targattrfilters ACI decoder embedded the operation keyword captured
from the user-supplied expression directly into a regular expression
(opPattern) used to split the sub-expression. Although the captured
group can only ever be the literal "add" or "del" (it comes from the
(add|del) capture group of keywordFullPattern), CodeQL flags the
user-tainted value flowing into a regex.

Wrap the captured operation in Pattern.quote() before embedding it into
opPattern. For "add"/"del" this is a no-op at match time, so behaviour is
unchanged, while the regex-injection data flow is removed.
@vharseko
vharseko requested a review from maximthomas July 24, 2026 15:08
@vharseko vharseko added java Pull requests that update java code ACI Access Control Instructions subsystem security Security fixes / CodeQL code-scanning alerts labels Jul 24, 2026
@vharseko
vharseko merged commit 23b57dc into OpenIdentityPlatform:master Jul 25, 2026
17 checks passed
@vharseko
vharseko deleted the fix-codeql-java-regex-injection branch July 25, 2026 04:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ACI Access Control Instructions subsystem java Pull requests that update java code security Security fixes / CodeQL code-scanning alerts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants