Commit Graph

29690 Commits

Author SHA1 Message Date
Eric Hawicz
526317e80e Initialize local variable in kimpersonate to avoid crash in krb5_free_principal() 2021-11-13 09:13:49 +11:00
Nicolas Williams
2f31063e97 spnego: Minor style cleanup 2021-11-11 22:41:13 -06:00
Nicolas Williams
7a19658c1f spnego: Fix NULL deref
Reported to Heimdal by Michał Kępień <michal@isc.org>.

From the report:

Acknowledgement
---------------

This flaw was found while working on addressing ZDI-CAN-12302: ISC BIND
TKEY Query Heap-based Buffer Overflow Remote Code Execution
Vulnerability, which was reported to ISC by Trend Micro's Zero Day
Initiative.
2021-11-11 22:41:13 -06:00
Nicolas Williams
6cbe35ad5d kadm5: Fix crash in principal creation
This manifests with an upcomming patch that adds support for
aliasing of namespaces.
2021-10-30 15:21:54 -05:00
Nicolas Williams
66dabe7d39 hdb: Fix bug in hdb_clear_extension() 2021-10-30 15:21:54 -05:00
Nicolas Williams
831a5f9db3 hdb: Fix crash when expected KR is missing 2021-10-30 15:21:54 -05:00
Nicolas Williams
2a9b57cdad kadmin: Add command aliases to man page 2021-10-30 15:21:54 -05:00
Robert Crowston
5d462795ce Add stub for gss_acquire_cred_impersonate_name(). 2021-10-19 20:45:40 +11:00
Robert Crowston
6d1e3c3d5b Fix spelling/grammar in various PKINIT messages
Only error messages and code comments touched.
2021-10-16 12:32:04 +11:00
Nicolas Williams
a7f0b14f59 kdc: Fix check-pkinit UPN test misquoting 2021-10-15 14:00:11 -05:00
Luke Howard
a8bd9b8c72 hdb: update HDB_F_SYNTHETIC_OK description
Note that HDB_F_SYNTHETIC_OK is also used for GSS-API pre-authentication as
well as PKINIT.

Fixes: #812
2021-10-15 11:12:06 +11:00
Nicolas Williams
341848a27b base: Fix leak on ENOMEM 2021-10-11 13:58:15 -05:00
Nicolas Williams
7672ad31db kdc: Fix leak and loss of kdc_check_flags() reason
We were losing and leaking the reason for which kdc_check_flags() was
rejecting any S4U requests, yielding incomplete error messages.

The issue is that kdc_check_flags() wants to check the client and server
principals in the input state structure, but doesn't know about
impersonated principal name, and so we want to pass it a state structure
that has the impersonated instead of the impersonator client name.  This
is a bad design, but I'm ignoring that for now and just fixing this one
leak.
2021-10-11 13:58:15 -05:00
Nicolas Williams
7e17db9f04 kdc: Fix leak on TGS referral 2021-10-11 13:58:15 -05:00
Nicolas Williams
54581d2d52 krb5: Fix PAC signature leak affecting KDC 2021-10-11 13:58:15 -05:00
Nicolas Williams
403a445f5b krb5: Document TGS HDB entry alias referral feature 2021-10-11 13:58:15 -05:00
Nicolas Williams
4e7c0fd129 kdc: Test referrals via HDB entry aliases
When a principal name is an alias of another in a different realm, the
KDC will return a referral to that realm.  Test that.
2021-10-11 13:58:15 -05:00
Nicolas Williams
ba98690a0a kadmin: Add add_alias, del_alias 2021-10-11 13:58:15 -05:00
Nicolas Williams
decd8f4102 hdb: Support referrals via aliases
The TGS will issue referrals based on [domain_realm] mappings.

With this change the TGS will also issue referrals based on HDB entry
aliases.

The TGS needed no changes for this, only support in lib/hdb was missing.

All we had to do was return HDB_ERR_WRONG_REALM from hdb_fetch_kvno()
when the given principal is an alias and its canonical name's realm is
different from the alias'.

This feature is important because the KDC currently does not re-read
krb5.conf and must be restarted for changes to e.g., [domain_realm]
mappings to take effect.  As well, making krb5.conf changes to all the
KDCs for a realm would need to be arranged.  But with aliases in the
HDB, these problems go away.

Relatedly, we should really have an option to store the KDC's entire
configuration in the HDB...

Futures:

 - Add support for aliasing of entire namespaces via HDB aliases with
   WELLKNOWN namespace name forms.  This will round out domain-to-realm
   mapping configuration support via HDB.
2021-10-11 13:58:15 -05:00
Nicolas Williams
a703bd1212 hdb: Deleting aliases corrupts iprop log
Deleting an alias causes the HDB_entry_alias entry value encoding to be
written to the iprop log, which later cannot be decoded as an HDB_entry.
Meanwhile, the alias is removed from the HDB but not from the list of
aliases in the canonical principal's HDB entry.

This commit makes deletion of alias names an error.
2021-10-11 13:58:15 -05:00
Nicolas Williams
8671858178 kadm5: Fix KRB5_TL_LAST_PWD_CHANGE handling 2021-10-11 13:58:15 -05:00
Nicolas Williams
fb298a023b kadm5: Teach perform_tl_data() about aliases
Sort of.  It already knew.

We have a mess where new things get sent to the server as
KRB5_TL_EXTENSION, but old things get sent to the client as whatever
appropriate KRB5_TL we have, and... we call perform_tl_data() on all TL,
but we don't remove unmodified TL on the client side, and...

Anyways.  This commit is a band-aid, but it works.
2021-10-11 13:58:15 -05:00
Nicolas Williams
838431d95e krb5: Fix krb5.conf.5 man page bug 2021-10-11 13:58:15 -05:00
Luke Howard
06e6113960 gss: _gss_spnego_set_sec_context_option return
Fix _gss_spnego_set_sec_context_option() to return GSS_S_UNAVAILABLE if no
context handle is provided, so that mechglue will skip to the next mechanism.
There are no globally settable options on SPNEGO itself.

Fixes: #803
2021-10-11 14:57:09 +11:00
Isaac Boukris
7f8bb85cf5 tests: fix recent test from using system klist
Closes: #842
2021-10-08 00:08:14 +11:00
Isaac Boukris
3e466caf10 krb5: skip cache check in S4U2Proxy requests 2021-09-28 10:19:08 +10:00
Luke Howard
85a5e5fb30 gss_preauth: remove protocol changes section from README
Heimdal implements draft-perez-krb-wg-gss-preauth-03 without protocol changes
(the draft was updated to match the implementation)
2021-09-24 07:38:58 +10:00
Isaac Boukris
e21e2b8d14 tests: ticket acquired by AS cannot be used as evidence 2021-09-23 22:35:54 +10:00
Isaac Boukris
d0e6ab43bc tests: check PAC client name in the non-canon case
and fixed the existing test to match the actual behavior,
I think it used to fail just because it used enterprise name
style without specifying it.
2021-09-23 22:35:54 +10:00
Luke Howard
fe71574be3 doc: add draft-perez-krb-wg-gss-preauth-03.txt
draft-perez-krb-wg-gss-preauth-03.txt documents the version of GSS-API
pre-authentication implemented by Heimdal at the point of this commit.
2021-09-23 19:16:35 +10:00
Luke Howard
e7863e2af9 kdc: correctly generate PAC TGS signature
When generating an AS-REQ, the TGS signature was incorrectly generated using
the server key, which would fail to validate if the server was not also the
TGS. Fix this.

Patch from Isaac Bourkis <iboukris@gmail.com>.
2021-09-23 17:51:51 +10:00
Luke Howard
fab07c4274 kdc: move _kdc_verify_checksum() to misc.c 2021-09-23 17:41:43 +10:00
Luke Howard
3b0856cab2 kdc: use ticket client name when signing PAC
The principal in the PAC_LOGON_NAME buffer is expected to match the client name
in the ticket. Previously we were setting this to the canonical client name,
which would have broken PAC validation if the client did not request name
canonicalization
2021-09-23 14:39:35 +10:00
Luke Howard
071b95e683 roken: fix theoretical leak introduced in 7fbe7be6
split_spec() should free output parameters if it fails. This was not a leak in
practice because its single caller cleaned up anyway, but cleaning up for good
hygiene.
2021-09-23 10:32:45 +10:00
Luke Howard
8fc67658a6 various: squash MSVC uninitialized variable warnings (C4701)
Initialize some variables to silence some false positive MSVC warnings.
2021-09-21 18:59:38 +10:00
Luke Howard
18a7562fa4 asn1: initialize L in ASN1_MALLOC_ENCODE
MSVC complains about uninitialized variables, set (L) to zero in failure case
from ASN1_MALLOC_ENCODE()
2021-09-21 18:59:38 +10:00
Luke Howard
cba3f9a563 krb5: return KRB5KRB_AP_ERR_INAPP_CKSUM if PAC checksum fails
Return KRB5KRB_AP_ERR_INAPP_CKSUM instead of EINVAL when verifying a PAC, if
the checksum is absent or unkeyed.
2021-09-21 18:17:00 +10:00
Luke Howard
fd3f463152 kdc: map KRB5_PROG_SUMTYPE_NOSUPP to KRB5KDC_ERR_SUMTYPE_NOSUPP
RFC4120 says KRB5KDC_ERR_SUMTYPE_NOSUPP should be returned if the KDC does not
support a given checksum type. Return this instead of KRB5_PROG_SUMTYPE_NOSUPP
by introducing a new wrapper function, _kdc_verify_checksum().
2021-09-21 18:17:00 +10:00
Luke Howard
85756bd228 krb5: make keyed checksums mandatory where possible
Make keyed checksums mandatory when generating and verifying checksums, with
the following exceptions:

* the checksum is being generated or verified as part of encrypting data for
  a legacy (DES) encryption type

* the KRB5_CRYPTO_FLAG_ALLOW_UNKEYED_CHECKSUM flag was set on the crypto
  context, used to allow unkeyed checksums in krb5 authenticators

By making unkeyed checksums opt-in, we eliminate a class of potential
vulnerabilities where callers could pass unkeyed checksums.

Any code that uses the mandatory checksum type for a given non-legacy
encryption type should not be affected by this change. It could potentially
break, say, a client trying to do FAST with DES keys but, that should not be
supported (because FAST KDCs also support AES).

Closes: #835
2021-09-21 18:02:25 +10:00
Luke Howard
7fbe7be675 roken: check strdup succeeds in roken_gethostby_setup()
Closes: #824
2021-09-20 17:58:19 +10:00
Isaac Boukris
6df8be5091 krb5: rework PAC validation loop
Avoid allocating the PAC on error.

Closes: #836
2021-09-20 11:29:11 +10:00
Isaac Boukris
b295167208 krb5: allow NULL parameter to krb5_pac_free() 2021-09-20 11:29:09 +10:00
Luke Howard
2acc4508d9 krb5: fix test_pac format string
Don't pass a potentially (although in reality, not) untrusted string to
krb5_err(); cleanup error handling.
2021-09-19 14:01:51 +10:00
Isaac Boukris
6c339fd5a5 krb5: add pac ticket-signature unit tests 2021-09-19 13:25:34 +10:00
Isaac Boukris
2ffaba9401 kdc: sign ticket using Windows PAC
Split Windows PAC signing and verification logic, as the signing has to be when
the ticket is ready.

Create sign and verify the PAC KDC signature if the plugin did not, allowing
for S4U2Proxy to work, instead of KRB5SignedPath.

Use the header key to verify PAC server signature, as the same key used to
encrypt/decrypt the ticket should be used for PAC server signature, like U2U
tickets are signed witht the tgt session-key and not with the longterm key,
and so krbtgt should be no different and the header key should be used.

Lookup the delegated client in DB instead of passing the delegator DB entry.

Add PAC ticket-signatures and related functions.

Note: due to the change from KRB5SignedPath to PAC, S4U2Proxy requests
against new KDC will not work if the evidence ticket was acquired from
an old KDC, and vide versa.

Closes: #767
2021-09-19 13:25:27 +10:00
Isaac Boukris
bb1d8f2a8c kdc: remove KRB5SignedPath, to be replaced with PAC
KRB5SignedPath was a Heimdal-specific authorization data element used to
protect the authenticity of evidence tickets when used in constrained
delegation (without a Windows PAC).

Remove this, to be replaced with the Windows PAC which itself now supports
signing the entire ticket in the TGS key.
2021-09-19 13:02:12 +10:00
Isaac Boukris
544515931b tests: default verify_pac to true in test_ap-req 2021-09-19 13:00:21 +10:00
Isaac Boukris
f4fcf8767c tests: fix a typo in test_ap_req 2021-09-19 13:00:04 +10:00
Isaac Boukris
152e28fc40 tests: add PAC test for CVE-2020-17049 (bronze bit) 2021-09-19 12:58:40 +10:00
Isaac Boukris
1ae7c61ef7 tests: add S4U2Proxy test with foreign client
Add S4U2Proxy test with foreign client and evidence ticket acquired via TGS
2021-09-19 12:58:18 +10:00