Commit Graph

29690 Commits

Author SHA1 Message Date
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
Luke Howard
774f50b28b gss: move GSS pre-auth helpers to convenience lib
GSS pre-auth helpers do not belong in libgssapi, so move them to a separate
convenience library.
2021-08-27 15:20:07 +10:00
Luke Howard
773802aecf kdc: fix _kdc_set_e_text argument in previous commit
"r" is the realm, not the TGS request; that is priv
2021-08-27 15:15:32 +10:00
Luke Howard
892a1ffcaa kdc: KRB5KDC_ERR_{C,S}_PRINCIPAL_UNKNOWN if missing field
If missing cname or sname in AS-REQ, return KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN and
KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN. This matches MIT behaviour.
2021-08-27 11:45:41 +10:00
Luke Howard
0417114794 kdc: validate sname in TGS-REQ
In tgs_build_reply(), validate the server name in the TGS-REQ is present before
dereferencing.
2021-08-27 11:45:41 +10:00
Nicolas Williams
a5378daa6c Revert "gss: Fix leak of output_token in GSS PA"
This reverts commit 041907d517.
2021-08-26 01:06:33 -05:00
Nicolas Williams
e6283e2d3f hx509: For times before 2050 use UTCTime (fix pasto) 2021-08-25 22:54:25 -05:00
Nicolas Williams
041907d517 gss: Fix leak of output_token in GSS PA 2021-08-25 22:53:52 -05:00
Andrew Bartlett
6f21611755 Avoid -Werror=address by skipping pointless _mg_buffer_zero()
We do not need to zero out the local variable output_token
if we do not later call gss_release_buffer() on it.

This aovids a -Werror=address compile failure under the
strict compiler options Samba uses when compiled on Ubuntu
20.04 with gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)

In file included from ../../source4/heimdal/lib/gssapi/preauth/pa_client.c:34:
../../source4/heimdal/lib/gssapi/preauth/pa_client.c:148:21: error: the address of ‘output_token’ will always evaluate as ‘true’ [-Werror=address]
  148 |     _mg_buffer_zero(&output_token);
      |                     ^
../../source4/heimdal/lib/gssapi/mech/mech_locl.h:72:7: note: in definition of macro ‘_mg_buffer_zero’
   72 |   if (buffer) {   \
      |       ^~~~~~

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2021-08-26 09:31:00 +10:00
Nicolas Williams
3f7972e6be hx509: Use preferred attribute string types
The DC (domainComponent) attribute wants to be an IA5String.

This really doesn't matter, but if we want to conform to the spec (RFC 4519,
referenced by RFC 5280), then we have to do this.
2021-08-25 17:00:12 -05:00
Nicolas Williams
f425e116b5 hx509: For times before 2050 use UTCTime 2021-08-25 16:48:10 -05:00
Nicolas Williams
edf259dac9 asn1: Update comment in rfc2459.asn1 2021-08-25 15:42:24 -05:00
Nicolas Williams
75449e1071 gss: Fix build for GSS preauth helpers 2021-08-25 15:41:35 -05:00
Luke Howard
76624dd4eb krb5: export krb5_set_log_dest()
krb5_set_log_dest() was not exported. Export it.
2021-08-24 21:16:10 +10:00
Luke Howard
b3511c145c gss: check for NULL before calling dlclose()
Calling dlclose(NULL) on some recent versions of Linux appears to cause the
process to segfault.
2021-08-20 00:07:12 +10:00
Luke Howard
a56c3ad819 krb5: fix prototype in pa_gss_finish()
Fix merge issue that arose after merging another fix from the
lukeh/gss-preauth-apple branch.
2021-08-18 08:17:04 +10:00
Luke Howard
1cdc9d5f3c krb5: export krb5_init_creds_step()
Public API included in headers but not exported.
2021-08-16 22:42:36 +10:00
Luke Howard
576ce5d663 kdc: remove unused label in _kdc_gss_mk_pa_reply()
_kdc_gss_mk_pa_reply() out: label was unused. remove it.
2021-08-15 20:56:34 +10:00
Luke Howard
5fb3cc998e kdc: check gcp != NULL
in _kdc_gss_rd_padata() failure path, check gcp != NULL before failing
2021-08-15 16:29:21 +10:00
Luke Howard
386b8d328a kdc: refactor/improve error handling in GSS pa 2021-08-15 16:07:46 +10:00
Luke Howard
a2538aeb38 kdc: fix leak in previous commit
Don't zero output_token unless it was moved to PA-GSS padata.
2021-08-15 15:52:08 +10:00
Luke Howard
df9e74b292 kdc: allow GSS error tokens in PA reply
If GSS_Accept_sec_context() returns an error status and error token, ensure we
include the error token in the PA-GSS padata in the KRB-ERROR reply, rather
than bailing out early.
2021-08-15 15:40:59 +10:00
Luke Howard
432fe0ad56 krb5: treat KRB5_NT_SRV_HST and KRB5_NT_SRV_INST identically
Update previous commit, mapping KRB5_NT_SRV_HST as well as KRB5_NT_SRV_INST to
GSS_C_NT_HOSTBASED_SERVICE.
2021-08-15 15:04:21 +10:00
Luke Howard
95d553e009 krb5: improve krb5 to GSS name conversion
First attempt to import krb5 names as GSS_KRB5_NT_PRINCIPAL_NAME; if that
fails, choose the most appropriate name form based on Kerberos name type.
2021-08-15 14:48:14 +10:00
Luke Howard
939cdbe4ad krb5: always canonicalize GSS federated name
When using WELLKNOWN/FEDERATED in GSS-API pre-authentication, always
replace with the cname in the AS-REP.
2021-08-15 13:50:21 +10:00