Stop rejecting long AD passphrases before the LDAP bind - #209
Merged
Conversation
The 72-byte password gate at the top of Login() is BCrypt's truncation limit, but it ran ahead of TryLdapLoginAsync. An AD account with a passphrase longer than ~72 ASCII characters got a generic 401 with the audit reason invalid_password_length and never reached the directory — the very orgs that deploy LDAP SSO are the ones handing out 12-word passphrases. The entrance now bounds the payload at 256 bytes (Active Directory's own maximum), which keeps the anonymous-endpoint amplifier closed alongside the existing 8 KiB request-size limit. The BCrypt-specific 72-byte reject moves to the local branch, ahead of the lockout reservation, so an unauthenticatable length still costs no throttle budget and still audits as invalid_password_length. The bootstrap path is unaffected: it already runs ValidatePasswordPolicy, which caps at the same 72 bytes and returns the descriptive 400. Closes #182
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.
The 72-byte password gate at the top of
Login()is BCrypt's truncation limit, but it ran beforeTryLdapLoginAsync. An AD account with a passphrase longer than ~72 ASCII characters received a generic 401 with the audit reasoninvalid_password_lengthand never reached the directory — and a ~12-word passphrase is exactly what the security-conscious orgs deploying LDAP SSO hand out. AD itself permits up to 256 characters, and a directory password never touches BCrypt.Change
MaxDirectoryPasswordBytes = 256bounds the login payload at the entrance. The anonymous-endpoint amplifier stays closed;[RequestSizeLimit(8 KiB)]on the endpoint already carried most of that weight anyway.invalid_password_length.ValidatePasswordPolicy, which caps at the same 72 bytes and returns the descriptive 400 instead of a bare 401.Tests
tests/NodePilot.Api.Tests/Controllers/AuthControllerLdapTests.cs:OverlongPassword_IsRejectedBeforeLdapOrThrottleWorknow pins the short-circuit at the directory maximum.LongPassphrase_PastBcryptsLimit_StillReachesTheLdapBind— a 100-byte passphrase reaches the bind and arrives unshortened (FakeLdapConnectionAdaptergainedLastPassword).OverlongPassword_AgainstLocalAccount_IsStillRejectedWithoutSpendingLockoutBudget— the local half still rejects, auditsinvalid_password_length, and leavesFailedLoginCountat 0.Run:
dotnet test tests/NodePilot.Api.Tests --filter "FullyQualifiedName~AuthControllerLdapTests"→ 21 passed.Docs updated in step:
docs/ldap-windows-sso.md(security invariants) and the docs-site security overview.Closes #182