Commit Graph

969 Commits

Author SHA1 Message Date
Nicolas Williams
313caed18a kinit: Try anon PKINIT armored FAST when possible 2021-12-14 17:32:20 +11:00
Luke Howard
2087e07c1e kdc: update PAC hooks for Samba
Samba includes the user's long-term credentials (encrypted in the AS reply key)
to allow legacy authentication protocols such as NTLM to work even if the
pre-authentication mechanism replaced the reply key (as PKINIT does).

Samba also needs to know whether the client explicitly requested a PAC be
included (or excluded), in order to defer PAC exclusion until a service ticket
is issued (thereby avoiding a name binding attack if the user is renamed
between TGT and service ticket issuance).

References:

https://bugzilla.samba.org/show_bug.cgi?id=11441
https://bugzilla.samba.org/show_bug.cgi?id=14561

Closes: #864

Original authors:
 - Joseph Sutton <josephsutton@catalyst.net.nz>
 - Andrew Bartlett <abartlet@samba.org>
 - Stefan Metzmacher <metze@samba.org>
2021-12-14 13:51:53 +11:00
Luke Howard
fcd8e33a98 tests: use KRB5_CALLCONV for windc test plugin 2021-12-14 13:51:53 +11:00
Joseph Sutton
814e58fda8 heimdal: Make _krb5_pac_get_kdc_checksum_info() into a global function
This lets us call it from Samba.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>

[abartlet@samba.org Similar to Samba commit 3bdce12789af1e7a7aba56691f184625a432410d
 but also fixed for caller in Heimdal windc plugin tests]
2021-12-14 13:44:01 +11:00
Nicolas Williams
52e5cba08b Fix tests/check-kdc.in (fix 6d1e3c3d5) 2021-11-14 17:50:33 -06:00
Nicolas Williams
a7f0b14f59 kdc: Fix check-pkinit UPN test misquoting 2021-10-15 14:00:11 -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
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
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
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
49f3f5bd99 kdc: support for GSS-API pre-authentication
Add support for GSS-API pre-authentication to the KDC, using a simplified
variation of draft-perez-krb-wg-gss-preauth-02 that encodes GSS-API context
tokens directly in PADATA, and uses FX-COOKIE for state management.

More information on the protocol and implementation may be found in
lib/gssapi/preauth/README.md.
2021-08-12 17:37:01 +10:00
Luke Howard
f86fccb344 gss: add split token test to check-negoex
Add test for split tokens to SAnon in NegoEx/SPNEGO
2021-08-08 18:16:17 +10:00
Luke Howard
06232dfcce gss: fix import/export of accumulating contexts
gss_{import,export}_sec_context did not work with partially accumulating
contexts, where the initial context token had not been completely accumulated,

Further, in gss_import_sec_context(), ctx->gc_input.value was not allocated to
a buffer sufficiently large to accumulate the target length.
2021-08-08 14:46:49 +10:00
Roland C. Dowdeswell
3a6229f64a gss_accept_sec_context: support reassembling split tokens.
Microsoft will sometimes split GSS tokens when they exceed a certain
size in some protocols.  This is specified in

	[MS-SPNG]: Simple and Protected GSS-API Negotiation
	Mechanism (SPNEGO) Extension

https://winprotocoldoc.blob.core.windows.net/productionwindowsarchives/MS-SPNG/%5bMS-SPNG%5d.pdf

sections 3.1.5.4 to 3.1.5.9.

We extend gss_accept_sec_context() to recognise partial tokens and
to accumulate the fragments until an entire token is available to
be processed.  If the entire token is not yet available,
GSS_S_CONTINUE_NEEDED is returned with a zero length output token.
This is specified in RFC2744 page 25-26 to indicate that no reply
need be sent.

We include updates to the test framework to test split tokens when
using SPNEGO.
2021-08-07 18:54:56 +10:00
Isaac Boukris
d83321fdf3 Add channel-bindings tests 2021-08-06 13:15:19 +10:00
Nicolas Williams
855b27ccfb httpkadmind: Allow host SPNs to fetch selves
Combined with the synthetic_clients feature, this will allow hosts that
have a PKINIT-worthy client certificate with a SAN with their host
principals to create their own principals and "extract" their host
keytabs.  Together with some other PKIX credential bootstrapping
protocol, this can help hosts bootstrap Kerberos host credentials.
2021-06-29 14:52:07 -05:00
Nicolas Williams
00358252d3 kdc: Add synthetic PKINIT principals option 2021-06-29 14:52:07 -05:00
Nicolas Williams
ae8908bf81 kadmin: Add disallow-client attribute
This is useful for services that need not be clients.  For example, an
untrusted service that need only accept authentication from clients,
but not initiate authentication to other services.
2021-06-22 13:01:24 -05:00
Nicolas Williams
1870584d22 kdc: Fix _kdc_audit_addaddrs() buglet 2021-06-21 23:38:16 -05:00
Nicolas Williams
9ce3cbbf2a kdc: Improve warn_ticket_addresses feature
- Don't log "Request from wrong address (ignoring)".
 - Add "wrongaddr=yes" kv to final log message.
 - Add request and ticket addresses (up to 3) to final log message.
2021-05-12 17:56:26 -05:00
Nicolas Williams
8807a0aad9 bx509d: Use /get-tgt lifetime q-param 2021-05-06 23:13:31 -05:00
Nicolas Williams
a4adb8354f bx509: Complete /get-tgt?cname= support 2021-04-22 17:02:18 -05:00
Nicolas Williams
f60300984e bx509d: /get-tgt add EKU to authorization check 2021-04-16 14:13:05 -05:00
Nicolas Williams
eb2d1029c2 kdc: Test warn_ticket_addresses and /get-tgt w/ addresses 2021-04-14 19:28:09 -05:00
Nicolas Williams
6633f6e525 bx509d: Implement /get-tgt end-point 2021-04-06 17:19:48 -05:00
Nicolas Williams
0205237a6e kdc: Add missing dep for tests/kdc/check-pkinit.in 2021-03-26 23:37:52 -05:00
Nicolas Williams
dc74e9d00c kdc: Add Heimdal cert ext for ticket max_life
This adds support for using a Heimdal-specific PKIX extension to derive
a maximum Kerberos ticket lifetime from a client's PKINIT certificate.

KDC configuration parameters:

 - pkinit_max_life_from_cert_extension
 - pkinit_max_life_bound

If `pkinit_max_life_from_cert_extension` is set to true then the
certificate extension or EKU will be checked.

If `pkinit_max_life_bound` is set to a positive relative time, then that
will be the upper bound of maximum Kerberos ticket lifetime derived from
these extensions.

The KDC config `pkinit_ticket_max_life_from_cert` that was added earlier
has been renamed to `pkinit_max_life_from_cert`.

See lib/hx509 and lib/krb5/krb5.conf.5.
2021-03-24 19:12:00 -05:00
Nicolas Williams
8e7c7209e8 kdc: Add param to derive max_life from client cert
This adds a KDC configuration parameter that can be used to indicate
that a PKINIT client's certificate's notAfter overrides the client
principal's HDB entry's max_life.  This parameter is a relative time
parameter, and it enables this only if set to a non-zero value (defaults
to zero).  The value of this parameter caps the max_life inferred from
the certificate.
2021-03-23 16:44:50 -05:00
Nicolas Williams
3f7868b969 httpkadmind: Fix error clobbering 2020-09-29 16:25:12 -05:00
Nicolas Williams
060ff3e09f httpkadmind: Check that host keys not vended 2020-09-25 11:10:09 -05:00
Nicolas Williams
0e09fa7fde iprop: Support hierarchical iprop 2020-09-18 14:31:43 -05:00
Nicolas Williams
9574783d04 kdc: Add httpkadmind
TBD:

 - improve error handling, logging, tracing!
 - move all REST services out of kdc/
2020-09-08 14:34:08 -05:00
Nicolas Williams
5447b81fb1 hdb: Move virtual principals into HDB layer
This is a large commit that adds several features:

 - Revamps and moves virtual host-based service principal functionality
   from kdc/ to lib/hdb/ so that it may be automatically visible to
   lib/kadm5/, as well as kadmin(1)/kadmind(8) and ktutil(1).

   The changes are backwards-incompatible.

 - Completes support for documenting a service principal's supported
   enctypes in its HDB entry independently of its long-term keys.  This
   will reduce HDB bloat by not requiring that service principals have
   more long-term keys than they need just to document the service's
   supported enctypes.

 - Adds support for storing krb5.conf content in principals' HDB
   entries.  This may eventually be used for causing Heimdal KDC
   services to reconfigure primary/secondary roles automatically by
   discovering the configured primary in an HDB entry for the realm.

   For now this will be used to help reduce the amount of configuration
   needed by clients of an upcoming HTTP binding of the kadmin service.
2020-09-08 00:25:36 -05:00
Nicolas Williams
ef06b94132 bx509: Fix minor test issues 2020-09-08 00:25:24 -05:00
Nicolas Williams
f5f63daa69 tests/kdc: Make make clean clean cleaner 2020-09-07 22:04:59 -05:00
Isaac Boukris
662dfbb38b Test including malformed krb5.conf file 2020-05-26 13:10:11 -04:00
Nicolas Williams
d1d900034f kinit: Make default-for-princ behavior optional
We can't just default to useing the krb5_cc_default_for() ccache for a
principal -- that breaks a number of uses of kinit.
2020-05-25 14:07:05 -05:00
Luke Howard
4a7eb74374 gss: SAnon - the Simple Anonymous GSS-API mechanism
Add support for SAnon, a simple key agreement protocol that provides no
authentication of initiator or acceptor using x25519 ECDH key exchange.
See doc/standardization/draft-howard-gss-sanon-xx.txt for a protocol
description.
2020-04-25 23:19:30 -05:00
Nicolas Williams
1a8855e6c4 spnego: Also use mechglue names 2020-04-25 21:22:32 -05:00
Luke Howard
846c839cbf gss: add tests for importing and exporting contexts
Add the --export-import-context flag to test_context, for validating that
security contexts round-trip through GSS_Export_sec_context() and
GSS_Import_sec_context().
2020-04-14 17:04:03 +10:00
Nicolas Williams
7055365f47 Expand tokens in gss cred store "ccache" value
This is needed so that sshd and such can get make practical use of the
"ccache" key in GSS cred stores.

This commit only changes the store path, not the acquisition path.
2020-03-18 13:37:13 -05:00