[#673] Fix ArrayIndexOutOfBoundsException on truncated percent-encoding in LDAP URLs - #676
Merged
vharseko merged 1 commit intoJul 8, 2026
Conversation
…DAP URLs (OpenIdentityPlatform#673) A percent sign followed by fewer than two hexadecimal digits (e.g. the ACI userdn "ldap://cn=name%B") crashed instead of producing a decode error: - org.opends.server.types.LDAPURL.urlDecode: the bounds check allowed i+2 == length, so reading the second hex digit overran the array; use >= so a truncated sequence throws INVALID_ATTRIBUTE_SYNTAX, which UserDN.decode already converts into a clean AciException. - org.forgerock.opendj.ldap.LDAPUrl.percentDecoder had no bounds check at all and threw StringIndexOutOfBoundsException; throw ERR_LDAPURL_INVALID_HEX_BYTE instead. Tests: truncated "%" / "%B" cases in LDAPURLTestCase (server) and LDAPUrlTestCase (SDK), plus UserDNTestCase with the ACI reproducer from the issue.
maximthomas
approved these changes
Jul 3, 2026
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 #673.
Bug
A percent sign followed by fewer than two hexadecimal digits in an LDAP URL crashed with an uncaught runtime exception instead of producing a decode error. Reproducer from the issue:
Two instances of the same defect:
org.opends.server.types.LDAPURL.urlDecode— the bounds checkif (i+2 > length)allowsi+2 == length, so reading the second hex digit (stringBytes[++i]) overruns the array. Fixed to>=(as proposed in the issue). A truncated sequence now throwsDirectoryException(INVALID_ATTRIBUTE_SYNTAX, ERR_LDAPURL_PERCENT_TOO_CLOSE_TO_END), whichUserDN.decodealready converts into a cleanAciException.org.forgerock.opendj.ldap.LDAPUrl.percentDecoder(SDK) — no bounds check at all:decoded.charAt(srcPos + 1/2)threwStringIndexOutOfBoundsExceptionfor"...%"/"...%B". Now throwsLocalizedIllegalArgumentException(ERR_LDAPURL_INVALID_HEX_BYTE).Tests
LDAPURLTestCase(server) andLDAPUrlTestCase(SDK): truncated"%"/"%B"cases expect a clean decode error.UserDNTestCase: the exact ACI reproducer from the issue expectsAciException.All three test classes pass locally (
mvn -pl opendj-core test -Dtest=LDAPUrlTestCase;mvn -pl opendj-server-legacy verify -P precommit -Dit.test="LDAPURLTestCase,UserDNTestCase").