Commit Graph

1956 Commits

Author SHA1 Message Date
Nicolas Williams
8be05797cc httpkadmind: Use enum MHD_Result return type 2022-01-02 21:11:48 -06:00
Nicolas Williams
e328c0e496 bx509d: Use enum MHD_Result return type 2022-01-02 21:11:40 -06:00
Nicolas Williams
53e63d9ec9 kdc: Fix bx509d/httpkadmind (b1dcc1a47) 2022-01-02 21:11:07 -06:00
Luke Howard
957633b793 kdc: remove unused rx.h header
We no longer support Kerberos 4, remove rx.h.
2022-01-03 13:12:03 +11:00
Luke Howard
24c606719e kdc: fix _kdc_audit_addkv_bool wrapper copy paste
_kdc_audit_addkv_bool() should call heim_audit_addkv_bool() not
heim_audit_addkv_number(). Copy/paste error.
2022-01-03 09:36:50 +11:00
Luke Howard
52b9531cb5 kdc: note that GSS PA uses synthetic principals 2022-01-02 23:15:55 +11:00
Luke Howard
41ec5733ef kdc: document windc plugin entry points 2022-01-02 23:00:43 +11:00
Luke Howard
d683780b1d kdc: separate PKINIT/GSS authorization failure
Create a new audit event for PKINIT/GSS authorization (impersonation) failure
2022-01-02 15:25:52 +11:00
Luke Howard
a9c6bc2bf2 kdc: audit "yes" boolean values as booleans
Audit boolean values that were logged as "yes" as boolean values; this will
change audit log values to "true" instead, so this patch may be omitted.
2022-01-02 15:25:52 +11:00
Luke Howard
e15e711b13 kdc: remove auth_event_details audit key
The auth event details audit key (formerly, parameter to auth_status)
contained, variously, an encryption type name; a PKINIT client certificate
name; or, a GSS initiator name. Audit these instead using individual keys that
reflect the values' contents.
2022-01-02 15:25:52 +11:00
Luke Howard
93c8d57091 kdc: call HDB audit function in both AS and TGS
Call the HDB audit method, if present, in both AS and TGS, immediately prior to
generating an error response to send to the clinet.
2022-01-02 15:25:52 +11:00
Luke Howard
1e1c5dbbfc kdc: make error code available to audit function
Set r->ret in the request before calling the HDB audit method.
2022-01-02 15:25:52 +11:00
Luke Howard
cc0874d410 kdc: preserve value types in auditing
Preserve integer/boolean audit values as their native types; convert to strings
when logging only. This commit goes some way towards unifying the two auditing
APIs.
2022-01-02 15:25:52 +11:00
Luke Howard
b1dcc1a474 kdc: refactor Samba-specific auditing API in terms of existing API
Make Samba-specific HDB auth status API a wrapper on the existing auditing API,
with a view towards unifying the two APIs in a future commit.

The term "auth status" is replaced with "auth event", and the HDB auth_status
method is replaced with a more general purpose audit method which has access to
the entire request structure.
2022-01-02 15:25:52 +11:00
Luke Howard
d165e73fff bx509d: don't audit NULL message string
formatted can be NULL, it appeares the intention was to log msg instead
2022-01-02 15:25:52 +11:00
Luke Howard
52b1dffa63 kdc: return KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN (PA)
Return KRB5KDC_ERR_C_PRINCIPAL_UNKNOWN, not HDB_ERR_NOENTRY, if a client
principal could not be found during pre-authentication.

This fixes a regression introduced with synthetic principals in 00358252d3.
2022-01-01 08:41:13 -05:00
Luke Howard
0492729ba7 kdc: remove unused v4 hprop code 2021-12-30 20:42:18 +11:00
Luke Howard
486a1ea773 kdc: remove unnecessary cast in finalize() (windc.c) 2021-12-29 21:15:08 +11:00
Nicolas Williams
fb3ea5b943 kdc: Add ret to common svc req elements
We're logging SUCCESS even when the KDC sends error replies.  That's
because we're returning success to process_request() even when we send
errors to clients.  The error we want to send to the client, and that we
succeed or fail to send it, are different statuses.

Also, further move things into `r` and out of function arguments.
2021-12-27 10:16:58 +11:00
Nicolas Williams
833483137b kdc: Log more about KRB-ERROR failures 2021-12-23 21:06:38 -06:00
Nicolas Williams
eeba89a1af kdc: Stop confusing the compiler 2021-12-23 21:06:38 -06:00
Luke Howard
f49e99e15f kdc: remove e_text argument to _kdc_encode_reply()
e_text is part of astgs_request_t, so it doesn't need to be an explicit
argument to _kdc_encode_reply()
2021-12-23 17:49:36 -06:00
Luke Howard
b6be850e0d kdc: remove outpadata from astgs_request_t
Remove the outpadata field from astgs_request_t, because it's not something we
wish to expose publically (yet it is something that Samba needs in the
client_access plugin API, to add Windows error information).

Instead, allocate rep->padata at the start of AS/TGS request handling, and
ensure it is valid for the lifetime of the request until it is encoded (at
which point it will be freed and set to NULL if zero length, to avoid sending a
zero length METHOD-DATA to the client).

(The previous approach of setting rep->padata to point to &r->outpadata was
fragile, because it required clearing the pointer before freeing the KDC-REP.)
2021-12-23 17:49:36 -06:00
Luke Howard
64dad876a4 kdc: simplify client_access windc plugin API
Make client_access plugin API take a single argument, astgs_request_t. Note: in
order to avoid making r->outpadata public (it's an internal buffer), but allow
Samba to modify the reply pa data, some pointer magic is required.
2021-12-23 17:49:36 -06:00
Luke Howard
36fe09f433 kdc: remove unused padata field from astgs_request_t 2021-12-23 17:49:36 -06:00
Luke Howard
e81bcb71f3 kdc: add finalize_reply API to windc plugin
Allow a windc plugin to finalize the KDC reply (including the encrypted ticket
and reply parts) before encoding for transmission.
2021-12-23 17:49:36 -06:00
Luke Howard
6b312659cb kdc: use PAC from request in _kdc_gss_finalize_pac()
Pass astgs_request_t to _kdc_gss_finalize_pac() in order to harmonize with
other functions.
2021-12-23 17:49:36 -06:00
Luke Howard
d3549c4ab7 kdc: remove superflous request arg to _kdc_check_access()
KDC_REQ is accessible as r->req
2021-12-23 17:49:36 -06:00
Luke Howard
805ea5e0a0 kdc: use rep/et/ek fields in astgs_request_t
Use rep/et/ek fields in astgs_request_t that were previously present but not
globally used.
2021-12-23 17:49:36 -06:00
Luke Howard
e3a5169862 kdc: make common astgs_request_t elements public API 2021-12-23 17:49:36 -06:00
Luke Howard
2e8b172f38 kdc: move PAC into astgs_request_t structure 2021-12-23 17:49:36 -06:00
Luke Howard
d95be72681 kdc: separate astgs_request_t common elements
Separate out some astgs_request_t common elements with the intention of making
them public API.
2021-12-23 17:49:36 -06:00
Luke Howard
5b7cf5d56f kdc: centralize include PAC logic
Add a helper function that returns TRUE if a PAC should be included in ticket
authorization data, that can be called from both AS and TGS paths.

Per [MS-KILE] 3.3.5.3, PACs are always included for TGTs; for service
tickets, policy is governed by whether the client explicitly requested
a PAC be omitted when requesting a TGT, or if the no-auth-data-reqd
flag is set on the service principal entry.
2021-12-23 13:52:15 +11:00
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
ebd7092dff kdc: distinguish long-term key from replacing reply key
Distinguish pre-authentication mechanisms that replace the reply key from those
that use the client's long-term key. In the general case, one is the inverse of
the other, however KRB5_PADATA_ENCRYPTED_CHALLENGE replaces the reply-key with
one derived from the long-term key.

PA_REPLACE_REPLY_KEY indicates that the kvno should be set to zero in the
reply; the absence of PA_USES_LONG_TERM_KEY indicates that the client's
long-term key may be included in the PAC (PAC_CREDENTIAL_INFO with Samba only).

Corrects e8984871.
2021-12-23 11:24:35 +11:00
Luke Howard
bdb3e1020c Revert "kdc: distinguish long-term key from replacing reply key"
This reverts commit e89848719a.

(Reverting: typo.)
2021-12-23 11:24:00 +11:00
Luke Howard
e89848719a kdc: distinguish long-term key from replacing reply key
Distinguish pre-authentication mechanisms that replace the reply key from those
that use the client's long-term key. In the general case, one is the inverse of
the other, however KRB5_PADATA_ENCRYPTED_CHALLENGE replaces the reply-key with
one derived from the long-term key.

PA_REPLACE_REPLY_KEY indicates that the kvno should be set to zero in the
reply; the absence of PA_USES_LONG_TERM_KEY indicates that the client's
long-term key may be included in the PAC (PAC_CREDENTIAL_INFO with Samba only).
2021-12-23 11:21:30 +11:00
Luke Howard
357c73e013 kdc: avoid linear search of PA types
Store a dispatch table pointer for the used pre-authentication type to avoid
needing to traverse the table.
2021-12-23 11:04:38 +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
b4f3617964 kdc: don't add PAC_ATTRIBUTES PAC buffer for service tickets
Only include the PAC_ATTRIBUTES PAC info buffer if we are issuing a TGT, as its
contents are not relevant to application services. (The buffer contains a bit
indicating whether the client explicitly or implicitly requested a PAC.)
2021-12-22 16:38:52 +11:00
Luke Howard
b36ac3c15e kdc: don't add REQUESTOR_SID PAC buffer for service tickets
In the altsecid GSS pre-authentication authorizer plugin, don't add the
REQUESTOR_SID PAC info buffer unless the client requested a TGT. It is not
relevant to application services.
2021-12-22 16:37:32 +11:00
Luke Howard
8590499b53 kdc: include SID in PAC with GSS authorizer
Update the sample GSS pre-authentication authorizer plugin to allow the PAC to
be pinned to the authenticating user's SID.

There is still a race condition between the time the user authenticates and the
time the SID is looked up via LDAP, but it should be sufficient as an example;
if more security is required, then users should be enrolled with their SIDs.
2021-12-22 10:36:26 +11:00
Luke Howard
a2c225fe0a kdc: add PA PAC finalize callback
Note the selected pre-authentication mechanism, and add a callback to allow the
pre-authentication mechanism to update the PAC immediately prior to signing.
2021-12-22 10:36:26 +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
Luke Howard
e7588952ce kdc: add auth data type for synthetic principals
Add a new authorization data type to indicate a synthetic principal was used,
to allow synthetic clients acquired outside of PKINIT (e.g. with GSS-API
pre-authentication) to use the TGS.

Note: we continue to honor KRB5_AUTHDATA_INITIAL_VERIFIED_CAS to indicate that
it is OK for the client to be synthetic, even though it is only an indication
that the client *may* have been synthetic.
2021-12-18 15:09:38 +11:00