Repository navigation
Kerberos sign-in: bind the realm to the directory entry; no UPN-only or machine-account match (BACKLOG #4846) - #3255
wshallwshall wants to merge 4 commits into
Conversation
… machine matches The ticket's realm was checked against [auth].kerberos_realm and dropped, and the directory was then asked the password sign-in's wider question. resolve_principal and probe_principal take kerberos=True, which only the Kerberos sign-in passes. That lookup: - filters on objectCategory=person, objectClass=user and sAMAccountName only, with no userPrincipalName arm; - answers NOT_FOUND for a name ending in $ before any search (machine and interdomain trust accounts); - keeps only entries whose own sAMAccountName is the name and whose DN ends in the DC= RDNs of the realm's domain, up to ASCII case. The DN parser behind canonical_group_dn is split out as _canonical_rdns so _dn_realm reads a DN the same way. The realm is read from the authenticator's own settings and an unset one raises LdapError. test_ad_ambiguous_name's Windows SSO tie-break test now sets the realm to X, the domain its entries sit under. BACKLOG #4846
…gment SECURITY.md's Kerberos realm paragraph says what the narrowed lookup asks, what it refuses, and the Active Directory assumption it rests on. BACKLOG #4846
…use early Review round 1 on the realm binding: - the lookup takes kerberos_realm from the caller, the same settings value kerberos_principal checked the ticket against, instead of the authenticator's own copy; an empty or malformed one raises LdapError; - _dn_realm refuses a DC label holding a dot, escaped or not, and reads the domainComponent name and OID as dc; - the $ refusal and the realm check run in probe_principal before the service session opens; - one _search_user call site; docstrings, SECURITY.md and the changelog say what the lookup now reads, including that a ticket naming an implicit UPN finds nothing; - stale Kerberos wording in test_ad_ambiguous_name is corrected. BACKLOG #4846
…G drops Review round 2 on the realm binding: - _kerberos_lookup_realm checks the realm and refuses a $ name, asked by both probe_principal (before the session) and _lookup_by_name (where the filter is built), so neither guard rests on the call path; - _checked_kerberos_realm is the one ValueError-to-LdapError mapping; - _holds_name is the one sAMAccountName rule for the ambiguity check and the Kerberos narrowing; - a dropped entry logs at DEBUG: under the global catalog it is routine; - SECURITY.md, the changelog and the docstrings state the binding as the whole trailing DC= run equalling the realm, name the parser-refused DN case, and use the conditional for beta defects. BACKLOG #4846
|
QA -- korus roles/BUILDER.md step 11 (Builder E3, BACKLOG #4846) Open findings, unrepaired (the Builder reports none loosens a control):
|
|
Lander hand-over (Manager aebf32, batch 684)
Ledger ask after merge: banner for #4846, from the Builder, carried as written (the row stays PARTIAL): |
|
Lander hold on head 7239655. The QA covers this head (round-7771c07b, exit 0). The lookup only narrows; nothing weakens authentication. The two fail-closed behaviour findings, the Held on one false control claim this PR made stale. The
|
Merge danger
Reversible: yes -- reverting the squash on
mainrestores the previous directory lookup for Kerberos sign-in.Blast radius: Kerberos (Windows SSO) sign-in's directory lookup:
messagefoundry/auth/ldap.py, three lines at the Kerberos call inmessagefoundry/auth/service.py,docs/SECURITY.md(the Kerberos realm paragraph), a changelog fragment, and tests. The password/name lookup path is unchanged, shown by controls. No store, pipeline, connection or API shape change.Evidence
origin/main353b2183fe2, the Kerberos lookup matched a forest-wide name, accepted a UPN-only match, did not bind the entry tokerberos_realm, and did not exclude computer or managed service accounts.tests/test_kerberos_realm_binding.pycovers a forest-wide name collision both ways, a child realm, a child-only entry, UPN-only and machine-account entries, and a$name refused before any search; controls show the password/name lookup unchanged.pytestover 18 related files: 872 passed.Batch 684, BACKLOG #4846 (Builder E3)
Source branch
b684-4846-kerberos-realm, head7239655b6fd5781f5e3c0eaf3b2739168cb7104a. Its own PR because it changes a security control.What changed (all items re-measured at
353b2183fe2and still open):kerberos_realm, and Kerberos sign-in passes it. An entry is kept only when its DN's whole trailingDC=run equals the realm, compared case-insensitively. The new_dn_realmreads the DN with the group-DN parser, now split out as_canonical_rdns; it refuses a dotted label and reads the DC OID asdc.(&(objectCategory=person)(objectClass=user)(sAMAccountName=x)), with no UPN arm. Each entry is re-checked by_holds_name.objectCategory=personexcludes computers and managed service accounts. A name ending in$is NOT_FOUND before any search, because a trust account is a person-category user.Scope note: three lines in
messagefoundry/auth/service.py(the Kerberos call, about line 7080) passkerberos_realm; without them the control would be unused. Batch 684's #4276 Builder also editsservice.py, in a different region; whichever PR lands second may need a rebase.tests/test_ad_ambiguous_name.pywording was updated after it went red.Open question for the owner, not decided here: keep the realm compare case-insensitive, or make it case-sensitive per RFC 4120 section 6.1. The code stays case-insensitive, as before.
Checks run:
ruff checkandruff format --check; mypy linux onldap.pyandservice.py, win32 onldap.py, the tests leg on the two test files; pytest on 18 related files, 872 passed.Not run: the full suite and mypy on the full packages. Read the full pytest, Windows and mypy tests CI legs.
Review: code-review skill at xhigh, Rounds: 2 + 1 unrepaired. The QA line and open findings are in a comment below.