Fix LDAP bind panic when userPassword attribute is missing#171
Merged
rhafer merged 2 commits intolibregraph:masterfrom Jul 1, 2025
Merged
Conversation
Fixes libregraph#114 This commit addresses two critical issues in LDAP bind operations: 1. **Silent panic recovery**: Panics during bind operations are now properly logged with context including panic reason and remote address 2. **Unsafe array access**: Fixed panic when user records lack userPassword field by adding proper null checks before accessing Values[0] Changes: - pkg/ldapserver/bind.go: Enhanced panic logging with error context - server/handler/ldif/entry.go: Added safe password validation with null checks - server/handler/ldif/entry_test.go: Comprehensive unit tests for edge cases The fix ensures: - No panics when processing entries without userPassword - Clear, actionable error messages in logs - Proper LDAP error codes (InvalidCredentials vs OperationsError) - No performance regression or timing attack vulnerabilities - Backward compatibility maintained Testing: - All existing tests pass - New unit tests cover missing password scenarios - End-to-end testing confirms proper error handling - No regressions in valid password scenarios
- Split long test functions to meet funlen requirements - Fix gofmt formatting issues - Remove var redeclaration in entry_test.go - Improve else-if flow in test conditions All tests pass and linter is now clean for the changed files.
rhafer
approved these changes
Jul 1, 2025
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.
Summary
Fixes #114 - Resolves LDAP bind panic and silent error handling when user records lack userPassword attributes.
This PR addresses two critical issues:
Changes Made
Core Fix
Key Improvements
"user has no password attribute")InvalidCredentialsvsOperationsError)Testing
Unit Tests
End-to-End Testing
Before/After Behavior
Before (Issue #114):
After (This Fix):
"ldap bind credentials error" error="user has no password attribute"Security Considerations
Backward Compatibility
Test Plan
Ready for review and merge.