Commit Graph

29814 Commits

Author SHA1 Message Date
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
Isaac Boukris
7645f3c086 tests: add S4U2Proxy tests with TGS evidence ticket
This was broken with KRB5SignedPath but now that we switch to PAC
we get it fixed without KDC changes, so we can just test it.

See also PR #599 from where these tests were taken.
2021-09-19 12:58:04 +10:00
Luke Howard
b2f9bb67d7 krb5: specify krb5_enomem() calling convention
krb5_enomem() was lacking a calling convention decoration, breaking Windows
consumers if __cdecl was not the default calling convention. Add KRB5_LIB_CALL
to make it consistent with other library functions.

Closes: #834
2021-09-16 14:59:25 +10:00
Nicolas Williams
2f57f31cd7 roken: Improve test-getuserinfo 2021-09-15 16:05:30 -05:00
Nicolas Williams
0e8323ccee roken: Do not pass NULL to getpwnam_r() 2021-09-15 10:56:19 -05:00
Nicolas Williams
5702bd5b77 asn1: Also decode ProxyCertInfo 2021-09-15 10:56:19 -05:00
Luke Howard
7dce1b6111 kdc: don't leak sec_context_token on checksum fail
When validating the KDC-REQ-BODY checksum introduced in 0ed4d90a, don't leak
the sec_context_token retrieved from the FX-COOKIE if checksum verifications
fails.
2021-09-13 19:51:58 +10:00
Luke Howard
3ac48a8dfd krb5: KRB5_KRBHST_TKTBRIDGEAP
Add a new krbhst type, KRB5_KRBHST_TKTBRIDGEAP to krb5_krbhst_init_flags(),
that looks for the DNS SRV record kerberos-tkt-bridge. This is to support a new
PADL project.
2021-09-13 19:20:11 +10:00
Luke Howard
0ed4d90a7c kdc: validate KDC-REQ-BODY invariance in GSS preauth
Whilst channel bindings are used to bind the KDC-REQ-BODY to the GSS-API
context, we need to also bind the KDC-REQ-BODY across multiple requests in a
pre-authentication conversation.

Do this by making a digest of the first KDC-REQ-BODY (with the nonce zeroed, as
this may change), and verifying it in each subsequent request.
2021-09-13 17:08:32 +10:00
Luke Howard
207bfc066d krb5: add unkeyed SHA-2 checksum types
Add unkeyed checksum types for SHA-256, SHA-384 and SHA-512, for future
internal use. They are assigned private (negative) checksum types and must
never appear in cleartext on the wire.
2021-09-13 17:08:32 +10:00
Luke Howard
ebfd48e40a kdc: avoid re-encoding KDC-REQ-BODY
Use --preserve-binary=KDC-REQ-BODY option to ASN.1 compiler to avoid
re-encoding KDC-REQ-BODYs for verification in GSS preauth, TGS and PKINIT.
2021-09-13 13:50:45 +10:00
Luke Howard
908ef18c9f Revert "krb5: zero nonce before encoding for GSS preauth"
This reverts commit 34b374b5e4.

We are revising the GSS-API pre-authentication draft to include the nonce from
the first request in the GSS channel bindings, to avoid re-encoding issues that
may surface with Kerberos implementations that do not correctly implement DER.
2021-09-13 13:39:58 +10:00
heitbaum
c7bd01c62a yyerror: update to POSIX standard
To comply with the latest POSIX standard, in Yacc compatibility mode
(options `-y`/`--yacc`) Bison now generates prototypes for yyerror and
yylex.  In some situations, this is breaking compatibility: if the user
has already declared these functions but with some differences (e.g., to
declare them as static, or to use specific attributes), the generated
parser will fail to compile.  To disable these prototypes, #define yyerror
(to `yyerror`), and likewise for yylex.

refer: https://git.savannah.gnu.org/cgit/bison.git/tree/NEWS

GNU Bison 3.8
2021-09-10 09:11:23 +10:00
heitbaum
3afd037fa3 appveyor: Fix build
Update from bison 3.5 to 3.5.4 which is available at the repositories
2021-09-10 09:10:42 +10:00
Luke Howard
be9f26e064 doc: use top-level Wiki URL
Top-level Wiki URL at https://github.com/heimdal/heimdal/wiki is a better
starting point for build instructions.
2021-09-08 12:25:37 +10:00
Luke Howard
686e7905c7 doc: update build instructions URL
h5l.org no longer exists, update build instructions to point to GitHub Wiki

Closes: #773
2021-09-08 12:22:25 +10:00
Luke Howard
34b374b5e4 krb5: zero nonce before encoding for GSS preauth
Zero nonce before encoding KDC-REQ-BODY to be used as channel binding
application data in GSS-API pre-authentication. This is because the nonce may
change between AS-REQs and the channel binding data should be invariant between
calls to GSS_Init_sec_context().
2021-09-07 15:18:55 +10:00
Robert Crowston
be2c28cc34 Check CLANG_FORMAT is executable.
If clang-format is not available, AC_CHECK_PROG sets CLANG_FORMAT=no,
not empty string. This results in an error at build time for those
without clang-format installed. Instead check if the program is
executable.
2021-09-07 12:50:25 +10:00
Robert Crowston
9b46d6436f Only #include <malloc.h> if it is available.
e.g., OpenBSD does not provide this header.
2021-09-07 12:49:19 +10:00
Luke Howard
c3a5f20041 krb5: update krb5.conf(5) with RFC8009 enctypes
Add aes256-cts-hmac-sha384-192 and aes128-cts-hmac-sha256-128 to krb5.conf(5).

Closes #815.
2021-09-06 13:31:03 +10:00
Luke Howard
fc9f9b322a gss: implement gss_krb5_ccache_name()
Correctly implement gss_krb5_ccache_name() in terms of
gss_set_sec_context_option(GSS_KRB5_CCACHE_NAME_X). The previous implementation
was a NOOP.

Note: global ccache name should really be thread-specific rather than global.

Closes #803.
2021-09-06 13:26:55 +10:00
Luke Howard
971648b71e kdc: correct logic error in altsecid_gss_preauth_authorizer
check for the absence, not presence, of a GSS credential before acquiring one
2021-08-31 11:06:32 +00:00
Luke Howard
01ef38b743 kdc: add sample GSS preauth authorization plugin
Add a sample GSS preauth authorization plugin, which will be built and
installed if OpenLDAP is available, but otherwise not enabled (by virtue of not
being installed into the plugin directory).

The plugin authorizes federated GSS preauth clients by querying an Active
Directory domain controller for the altSecurityIdentities attribute.

Once the user entry is found, the name is canonicalized by reading the
sAMAccountName attribute and concatenating it with the KDC realm.
2021-08-31 11:00:13 +00:00
Nicolas Williams
7818f44659 gss_preauth: Fix build race 2021-08-29 13:50:39 -05:00
Luke Howard
f43dbb1d25 gss_preauth: fix header dependency 2021-08-28 16:35:05 +10:00
Luke Howard
f551ae3d82 gss_preauth: remove gss_preauth.h
Remove gss_preauth.h, it is now auto-generated.
2021-08-27 19:51:32 +10:00
Luke Howard
ed1ef5d776 asn1: correctly check gmtime_s() return value
gmtime_s(), used on Windows, returns an errno_t not a struct tm *.

The previous code caused strftime() to dereference a NULL struct tm *.
2021-08-27 16:10:03 +10:00