Skip to content

fix: avoid out-of-range index for serverSaslCreds in saslBindTokenExchange - #609

Open
netliomax25-code wants to merge 2 commits into
go-ldap:masterfrom
netliomax25-code:sasl-bind-creds-bounds
Open

fix: avoid out-of-range index for serverSaslCreds in saslBindTokenExchange#609
netliomax25-code wants to merge 2 commits into
go-ldap:masterfrom
netliomax25-code:sasl-bind-creds-bounds

Conversation

@netliomax25-code

Copy link
Copy Markdown
Contributor
  1. saslBindTokenExchange reads serverSaslCreds at protocolOp.Children[3] for a saslBindInProgress (result code 14) response, but the length check ahead of it only required three children.
  2. serverSaslCreds is the optional [7] field that follows the three LDAPResult components, so a server that returns code 14 with only those components makes the index out of range and panics the bind goroutine mid GSSAPI handshake.

Require at least four children before reading the creds child, so a short response falls through to GetLDAPError instead of indexing past the slice. Added a regression test that drives the exchange with a three-child in-progress response.

@netliomax25-code
netliomax25-code force-pushed the sasl-bind-creds-bounds branch from fd1055d to 9d62ce7 Compare July 5, 2026 14:03
@netliomax25-code

Copy link
Copy Markdown
Contributor Author

pushed a fix for the lint failure. errcheck flagged the deferred Close calls in the new test, and the branch also needed a rebase onto master so the linter stopped attributing pre-existing lines to this diff. checks are green now.

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.

1 participant