Commit Graph

52 Commits

Author SHA1 Message Date
Luke Howard
317df4dbd4 kdc: remove pac_attributes_present field
Remove the unwieldy pac_attributes_present field from the request structure.

Instead, if PAC attributes are not present in the TGT, the default is to assume
they were set to KRB5_PAC_WAS_GIVEN_IMPLICITLY.
2021-12-23 13:26:40 +11:00
Luke Howard
f18c9e06a8 kdc: honor PAC_ATTRIBUTES in presented TGT
PACs are included when issuing TGTs, if there is no PAC_ATTRIBUTES buffer
(legacy behavior) or if the attributes buffer indicates the AS client requested
one.
2021-12-22 17:13:13 +11:00
Luke Howard
f7964251ff kdc: support for PAC_ATTRIBUTES_INFO
Add PAC_ATTRIBUTES_INFO to the PAC. This info buffer indicates whether the user
explicitly requested a PAC be present or absent.

Note: this changes the windc plugin ABI.
2021-12-22 10:36:26 +11:00
Luke Howard
e50033aec2 kdc: add canonical principal name to authz data
Use the UPN_DNS_INFO buffer of the PAC to include the canonical principal name.

Arguably we should use AD-LOGIN-ALIAS as defined in RFC6806, but we may not
always know all the principal's aliases, and this approach allows us to share
application service logic with Windows.
2021-12-22 10:36:26 +11:00
Joseph Sutton
f5823216d0 kdc: Return error code from _kdc_check_pac() with an armor ticket
This allows a TGT_REVOKED error to be returned to match Windows
behaviour.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2021-12-20 14:34:21 +11:00
Joseph Sutton
b16f93240e kdc: Fix NULL pointer dereference on failure to verify armor ticket PAC
r->client_princ and r->server_princ are only set in the AS-REQ case, but
we perform the PAC check in the TGS-REQ case, so calling
krb5_unparse_name() will dereference a NULL pointer. Instead, use
r->cname and r->sname.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2021-12-20 14:34:21 +11:00
Luke Howard
45ea54a44a kdc: audit armor client principal name 2021-12-19 21:06:08 +11:00
Luke Howard
a3392b099e kdc: allow cross-realm FAST armor TGT
08e0305b introduced a patch to validate armor ticket PACs, but required that
the armor client principal was in the local realm (as it did not allow
_kdc_db_fetch() to fail).

Allow cross-realm FAST armor clients by using the same logic to look up the
client principal as the TGS itself does, i.e. use db_fetch_client() which
handles the case where the client is not local to the KDC.

Note: the armor PAC is only required to be validated when issuing a final,
non-referral service ticket, as this is the only point upon which device claims
should be inserted (according to my understanding).

Closes: #901
2021-12-18 15:09:38 +11:00
Joseph Sutton
08e0305b26 kdc: Check PAC of armor tickets
Look up the client name of the armor TGT in the database, and check that
the PAC is valid.

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

Closes: #891
2021-12-17 13:34:58 +11:00
Luke Howard
4dc369ef8f Revert "kdc: Check PAC of armor tickets"
This reverts commit 83a80cd53b.
2021-12-16 16:45:10 +11:00
Luke Howard
a208b9dcb7 Revert "kdc: fix regression when validating armor client"
This reverts commit 6b635f66de.
2021-12-16 16:44:48 +11:00
Luke Howard
6b635f66de kdc: fix regression when validating armor client
Resolving the FAST armor client principal must use the same logic as the AS
itself. Allow synthetic client principals when validating FAST armor TGTs.
2021-12-16 16:05:07 +11:00
Joseph Sutton
83a80cd53b kdc: Check PAC of armor tickets
Look up the client name of the armor TGT in the database, and check that
the PAC is valid.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2021-12-16 12:59:01 +11:00
Joseph Sutton
717ad8b043 kdc: Add support for explicit armoring from MS-KILE
Normally when FAST is used with a TGS-REQ, the armor key is implicitly
derived from the TGT rather than armor being explicitly present, as for
AS-REQs. However, Windows allows a TGS-REQ to be explicitly armored with
a computer's TGT, so that the armor key also depends on the ticket
session key.

This is used for compound identity, where the computer's group
membership and claims are added to the PAC of the resulting ticket.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2021-12-14 16:19:01 +11:00
Joseph Sutton
96ee28c32c kdc: Allow RODC-issued armor tickets
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2021-12-14 14:30:00 +11:00
Joseph Sutton
2f21cf9933 kdc: Fix leak
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2021-12-14 13:24:02 +11:00
Luke Howard
007cc9fdc3 kdc: remove temporary krb5_context variable
Use r->context (from request) instead of a temporary context variable, where
available.
2021-12-14 09:03:42 +11:00
Luke Howard
2b95853df4 kdc: salt FAST cookie key with client name 2021-12-14 09:03:42 +11:00
Luke Howard
9b55215a2a kdc: sync KDC FAST with Heimdal-597.121.1
Import KDC FAST from Apple's Heimdal-597.121.1, adding support for:

  - PA-ENC-CHALLENGE
  - reply key strengthening
  - FAST authentication in TGS

kuser: Apple sync (squash)

krb5_init_creds_store_config/krb5_init_creds_warn_user in kinit
2021-12-14 09:03:42 +11:00
Joseph Sutton
9b62d72d51 heimdal:kdc: Match Windows error code for unsupported critical FAST options
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2021-12-07 15:31:58 +11: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
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
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
Andrew Bartlett
f03983b64d HEIMDAL: Require armor_server to be a krbtgt name, not just a server name
Samba has a different lookup path for krbtgt/ principals.

armor_server is in this case the same as the server in a normal
TGS-REQ, just inside the FAST armor, so needs to have the same
lookup properties as the TGS-REQ does.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2021-08-06 12:43:17 +10:00
Andrew Bartlett
61f1be93e3 kdc: Provide flag to hint to KDC that this is a FAST key lookup
For Samba the fast key is not stored in the replicated DB, so
this helps Samba find it in the Samba hdb module.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2021-08-06 12:43:17 +10:00
Luke Howard
3604497fda kdc: zero KDCFastState padata before free 2021-08-04 18:01:48 +10:00
Luke Howard
04e3ea4307 kdc: don't leak FAST req_body checksum buffer
The temporary buffer used to checksum the KDC-REQ body in
_kdc_fast_unwrap_request() was not freed.
2021-08-03 17:30:06 +10:00
Nicolas Williams
ff13573ce5 hdb: Do not apply new service key delay to clients
The new [hdb] new_service_key_delay parameter should not apply to
principal entries when used as clients.  Otherwise new passwords would
not take effect immediately, and that would be very confusing.
2020-09-09 21:48:29 -05:00
Roland C. Dowdeswell
05e8517542 kdc/fast.c: fix leak in unusual error path. 2019-12-05 00:05:56 -05:00
Roland C. Dowdeswell
7d353d0557 Generate a single summary audit line for AS/TGS.
We refactor the code a bit to extend kdc_request_t which until now
was only used for the AS.  We make the structure extensible and
start using it for the TGS as well.  We leave digest and kx509
alone for the time being.

We also define the concept of kv-pairs in our audit trail which
allows us to define a rigorous but extensible format:

type error from-addr client server key1=val1 key2=val2 ...
2019-12-05 00:05:56 -05:00
Roland C. Dowdeswell
c7d4682aed Define log levels in docs and change default to 0-3.
We define the meaning of the various log levels in the man page
for krb5_openlog(3).  If logging configured and levels are not
specified, we change the default levels to 0-3 which should exclude
debugging messages which are generally only desired in exceptional
circumstances.

We also go through the KDC and adjust the levels to be appropriate.
2019-10-21 13:43:01 +01:00
Viktor Dukhovni
8ec4f23701 Hide principal names in errors with FAST 2017-12-05 19:01:04 -05:00
Jeffrey Altman
cdf5d324e3 kdc: _kdc_fast_unwrap_request leaks 'buf'
Change-Id: If4d3852112dadc331db1d3601b2c7bd6b3129429
2016-11-18 23:59:47 -05:00
Stefan Metzmacher
a873e21d7c kdc: base _kdc_fast_mk_error() on krb5_mk_error_ext()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2015-07-31 17:30:23 +12:00
Nicolas Williams
c9609cdb37 Initial patch for dealing with AD x-realm key rollover
AD issues x-realm TGTs with kvno 0.  On key x-realm trust key change
    we need to be able to try current and previous keys for trust, else
    we will have some failures.
2011-11-15 21:53:33 -06:00
Love Hörnquist Åstrand
0941d6dbce add constant for WELLKNOWN:ORG.H5L realm 2011-07-24 21:29:27 -07:00
Love Hörnquist Åstrand
fb5e32e0f6 goto out 2011-07-24 21:23:53 -07:00
Love Hörnquist Åstrand
f0371bb2ee fast cookie expiration 2011-07-24 21:21:39 -07:00
Love Hörnquist Åstrand
46f285bcc9 encode fast state in the fast cookie 2011-07-24 21:16:42 -07:00
Love Hörnquist Åstrand
7f6f4206c6 make compile after rebase 2011-07-24 20:24:40 -07:00
Linus Nordberg
12203f0fab s/krb5_decode_EncryptedData/krb5_decrypt_EncryptedData/1.
Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
2011-07-24 20:24:39 -07:00
Linus Nordberg
294c2786fa Fix typo.
Signed-off-by: Love Hörnquist Åstrand <lha@h5l.org>
2011-07-24 20:24:39 -07:00
Love Hörnquist Åstrand
e5c66a70cd parse fast cookie 2011-07-24 20:24:39 -07:00
Love Hörnquist Åstrand
d99c2eda40 use else if 2011-07-24 20:24:39 -07:00
Love Hörnquist Åstrand
eaa23ce96f proxy request if needed 2011-07-24 20:24:39 -07:00
Love Hornquist Astrand
7e1468ca52 new call order too _krb5_fast_armor_key 2011-07-24 20:24:38 -07:00
Love Hornquist Astrand
99ed826f7f use _krb5_fast_armor_key() 2011-07-24 20:24:38 -07:00
Love Hornquist Astrand
333471097d break out fast unwrap 2011-07-24 20:24:37 -07:00
Love Hornquist Astrand
17d5f8d19e make AS work with FAST 2011-07-24 20:24:36 -07:00
Love Hornquist Astrand
a2bcf8bbdd break out mk_error 2011-07-24 20:24:36 -07:00