You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cf91195
Browse filesBrowse the repository at this point in the historyBrowse files
fix(kerberos): interoperate with MIT and Heimdal KDCs (#768)
## Summary
Two client fixes for password logons against MIT and Heimdal KDCs, found
while using `sspi` for SASL/GSSAPI binds to Active Directory and
MIT/Heimdal realms. Each currently makes every such logon fail.
- **Reuse the pre-authentication salt for AS-REP decryption.** MIT and
Heimdal send PA-ETYPE-INFO2 only in `KDC_ERR_PREAUTH_REQUIRED`, not in
the AS-REP. The client then derived the AS-REP key with an empty salt
and failed with `Bad integrity: calculated hmac is different than
provided`. The AS exchange now keeps the pre-authentication salt in the
PA-DATA options, and the client falls back to it when the AS-REP has
none.
- **Accept an AS-REP enc-part tagged `EncTGSRepPart`.** The MIT KDC
encodes the AS-REP enc-part with APPLICATION 26 for backwards
compatibility, and the client failed with `Expected Application number
tag 25 but got: 26`. It now accepts both tags.
### About the `EncTGSRepPart` fallback
I know this fallback was removed during the review of #681 ("We should
not expect `EncTgsRepPart` during AS exchange"). The MIT KDC however
always sends it, so without the fallback no AS exchange with an MIT KDC
can succeed:
- MIT krb5,
[`src/lib/krb5/asn.1/asn1_k_encode.c`](https://github.com/krb5/krb5/blob/master/src/lib/krb5/asn.1/asn1_k_encode.c):
"For backwards compatibility, we encode both EncASRepPart and
EncTGSRepPart with application tag 26. On decode, we accept either app
tag". The encoder is `MAKE_ENCODER(encode_krb5_enc_kdc_rep_part,
enc_tgs_rep_part)`, used for both reply types.
- [RFC 4120 section
5.4.2](https://www.rfc-editor.org/rfc/rfc4120#section-5.4.2): "Some
implementations unconditionally send an encrypted EncTGSRepPart
(application tag number 26) in this field regardless of whether the
reply is a AS-REP or a TGS-REP. In the interest of compatibility,
implementors MAY relax the check on the tag number of the decrypted
ENC-PART."
The fallback only applies after the enc-part decrypted with the AS-REP
key usage, and the TGS path is unchanged.
## Review and validation
- The test `KdcMock` gets two options reproducing each KDC behavior
(`omit_as_rep_etype_info2`, `tgs_rep_enc_part_in_as_rep`), each covered
by an end-to-end client/server authentication test. Without the fix,
each test fails with the error quoted above.
- Also verified against real MIT and Heimdal KDCs (LDAP SASL/GSSAPI
binds).
- `cargo test -q -p sspi -p kdc --features network_client,__test-data`
- `cargo check -q -p sspi --all-targets --features
network_client,dns_resolver,scard,__test-data` (`--all-features` also
enables `tsssp`, which only builds on Windows)
- `cargo clippy -q -p sspi -p kdc --features network_client,__test-data
--lib --tests -- -D warnings -A unreachable-pub -A
clippy::non-ascii-literal`
- `cargo clippy --manifest-path ffi/Cargo.toml -- -D warnings -D
clippy::print_stdout`
- `cargo fmt --all -- --check`
0 commit comments