5849 Commits

Author SHA1 Message Date
Nicolas Williams
305ab03155 krb5: Fix DNS SRV name collision handling 2024-09-03 15:14:42 -04:00
Jeffrey Altman
8d20888e09 krb5: Red Hat gssproxy FILE ccache remove cred compatibility
gssproxy stores its credentials to the ccache with endtime == 0.
Therefore, it is not safe to skip ccache entries unless authtime
is non-zero as well.
2024-09-03 14:19:20 -04:00
Jeffrey Altman
b7e699597e krb5: MIT krb5 FILE ccache remove cred compatibility
MIT commit d3b39a8bac6206b5ea78b0bf6a2958c1df0b0dd5 implemented
krb5_cc_remove_cred() for FILE ccaches by setting endtime to zero
and authtime to minus one and then filtering out those credentials
from get_next().

This change sets "authtime = -1" for the removed cred to permit
MIT krb5 to ignore removed credentials from a shared FILE ccache.

MIT commit 4c0838bb4c232866b95c9f2f72a55bf77cfc1308 modified the
cred_removed() check to restore compatibility with Heimdal.
2024-09-03 14:19:20 -04:00
Jeffrey Altman
68dbf1ba10 krb5: fcc_next_cred do not return removed creds
commit a9bd3c6e50 ("Fix racy file ccache
corruption in cred_delete()") implemented krb5_cc_remove_cred() for
"FILE" ccaches by overwriting the removed credential endtime value
with zero (Unix Epoch).  However, it did not modify fcc_get_next()
to filter out these deleted entries.  As a result, invalid credentials
can be returned from the FILE ccache where endtime < starttime.
RFC4120 requires endtime >= starttime for all tickets.

MIT Kerberos since d3b39a8bac6206b5ea78b0bf6a2958c1df0b0dd5
("Implement krb5_cc_remove_cred for remaining types") modifies a
removed cred by setting

  endtime = 0
  authtime = -1

and then filters out removed creds from the fcc_next_cred() results.

In 2013 Heimdal broke interop with MIT processes that share the
FILE ccache by implementing remove by setting "endtime = 0" and
now MIT has broken interop with the Heimdal implementation of
fcc_remove_cred() by checking for both "endtime = 0" and "authtime = -1".

This change filters results from fcc_get_next() when the "endtime == 0"
which is acceptable because a KDC is not permitted to return a
ticket with an endtime == 0.
2024-09-03 14:19:20 -04:00
Jo Sutton
99a53d76e6 krb5: Correct inverted conditions
Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
2024-09-03 13:35:38 -04:00
Jeffrey Altman
347822cf76 ENABLE_AFS_STRING_TO_KEY requires crypt()
If crypt() is unavailable then DES_AFS3_string_to_key() cannot be
implemented for passwords up to 8 characters in length.  Do not
advertise support for "afs3-salt" when crypt() is missing.
2024-09-03 13:31:34 -04:00
Robert Manner
78f017fe01 krb5/fast.c: fix copying source/dest for copy_KrbFastArmor
if using armoring service.
2024-09-02 14:01:39 -04:00
Stefan Metzmacher
ba8c3dbc62 lib/gssapi/krb5: implement GSS_C_CHANNEL_BOUND_FLAG for gss_init_sec_context()
This will force KERB_AP_OPTIONS_CBT to be sent.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15621

Signed-off-by: Stefan Metzmacher <metze@samba.org>
2024-07-06 16:14:43 -04:00
Ralph Boehme
a2a765f88e lib/krb5: initialize kdc_offset in the memory ccache from the krb5_context
This ensures we inherit the clock skew adjustment from the AS-REQ/REP into the
memory ccache in a similar way done for the file ccache.

This means krb5_cc_get_kdc_offset() will return the correct value and
_krb5_get_cred_kdc_any() uses the adjusted time in the authenticator of
subsequent TGS-REQ.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15676

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2024-07-06 16:07:17 -04:00
Ralph Boehme
c2e68593a5 lib/krb5: use check_fast() in _krb5_fast_unwrap_error()
At least Windows KDCs return KRB5KRB_AP_ERR_SKEW without edata in
response to TGS-REQ.

This ensures the callers see the KRB5KRB_AP_ERR_SKEW error and not
KRB5_KDCREP_MODIFIED "FAST fast response is missing FX-FAST".

For the response to an amored AS-REQ, we'll now return
KRB5KRB_AP_ERR_MODIFIED instead of KRB5_KDCREP_MODIFIED,
but if there's an attack the exact error code doesn't matter.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15676

Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2024-07-06 16:07:17 -04:00
Minsoo Choo
aff90c322e Fix spelling 2024-06-16 23:30:48 -04:00
Michael Tokarev
c80c04b235 spelling fixes (underun prefered relase encyption confunder)
[abartlet@samba.org: From Samba debian package at
 https://salsa.debian.org/samba-team/samba/-/blob/master/debian/patches/heimdal-spelling.patch?ref_type=heads]

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2024-06-16 23:28:43 -04:00
Nicolas Williams
2e94b7855c doc: Clarify kdc --ports / [kdc] ports (fix #1223) 2024-01-16 11:28:35 -06:00
Taylor R Campbell
e0aeef2bd3 krb5_sock_to_principal: Respect option [libdefaults] block_dns.
This fixes the one leaky part of:
https://github.com/heimdal/heimdal/issues/1214
2024-01-09 21:19:30 -06:00
Taylor R Campbell
f051c36471 Pass NI_NUMERICSERV|NI_NUMERICSCOPE if NI_NUMERICHOST to getnameinfo.
This addresses part of https://github.com/heimdal/heimdal/issues/1214
to audit potential network leaks with [libdefaults] block_dns = yes.

NI_NUMERICHOST is _probably_ sufficient -- we probably won't see many
systems using NIS to look up service names by number if we fail to
specify NI_NUMERICSERV, and such systems probably require careful
auditing of their own.  And I don't know of any way NI_NUMERICSCOPE
could trigger network leaks.  But named scope ids are such a niche
option with IPv6 that setting it to forestall concerns can't hurt
much, and it makes reviewing easier if we just unconditionally flip
on all the numeric-only options.
2024-01-09 21:19:30 -06:00
Taylor R Campbell
e75e549252 Use AI_NUMERICSERV if block_dns, and use local getaddrinfo to audit.
This change has two parts:

1. Provide our own local implementation of numeric-only getaddrinfo
   in auditdns.c used to audit for DNS leaks, rather than deferring
   to dlsym(RTLD_NEXT, "getaddrinfo"), in terms of inet_pton.

   To keep review and implementation simple, this is limited to
   AI_NUMERICHOST _and_ AI_NUMERICSERV -- this requires that we
   arrange to pass AI_NUMERICSERV in callers too.

2. Wherever we implement block_dns, set AI_NUMERICSERV in addition to
   AI_NUMERICHOST as needed by the new auditdns.c getaddrinfo.

   (In principle this might also avoid other network leaks -- POSIX
   guarantees no name resolution service will be invoked, and gives
   NIS+ as an example.)

   One tiny semantic change to avoid tripping over the auditor:
   kadmin(8) now uses the string "749" rather than the string
   "kerberos-adm".  (Currently we don't audit kadmin(8) for DNS leaks
   but let's avoid leaving a rake to step on.)  Every other caller I
   found is already guaranteed to pass a numeric service rather than
   named service to getaddrinfo.

fix https://github.com/heimdal/heimdal/issues/1212
2024-01-09 16:06:32 -06:00
Joseph Sutton
1d8f4347bb lib/krb5: Fix error message typo
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-01-09 16:06:06 -06:00
Taylor R Campbell
19505537fd Ensure all calls to rk_dns_lookup are headed by a block_dns check.
Exception: In lib/kafs/common.c, we don't have a krb5_context in
which to check.
2024-01-08 10:22:02 -06:00
Taylor R Campbell
fd77c4000d Ensure all calls to getaddrinfo are headed by a block_dns check.
If block_dns is set, call getaddrinfo with AI_NUMERICHOST set and
AI_CANONNAME clear.

Some paths may not have set AI_CANONNAME, but it's easier to audit
this way when the getaddrinfo prelude is uniform across call sites,
and the compiler can optimize it away.
2024-01-08 10:22:02 -06:00
Taylor R Campbell
fa4c4430f6 krb5.conf(5): New block_dns option.
Documented and verified, not yet implemented.
2024-01-08 10:22:02 -06:00
Taylor R Campbell
3171398867 krb5: Fix use-after-free when debug is enabled with http_proxy.
Instead of freeing host->ai on return from submit_request in the
http_proxy path, stash the proxy's ai in another member host->freeai
which will be freed when host is freed.

Assumption: All hosts created in submit_request cease to be used
before any of them are freed, so it's safe to pick one host to hang
the proxy's ai on and free the ai when that host is freed.

fix https://github.com/heimdal/heimdal/issues/1205
2024-01-04 14:00:18 -06:00
Joseph Sutton
1baceedb87 krb5: Clarify documentation for ‘pkinit_revoke’ parameter
If multiple valid CRLs are specified for a particular issuer, only the
first will be checked. The documentation didn’t really hint at this.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:39:18 -05:00
Joseph Sutton
13dbc0a667 krb5: Fix typos in documentation
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:39:18 -05:00
Daria Phoebe Brashear
3c62b6f5d7 kadm5: allow setting password_lifetime to 0 to clear
when [kadmin] password_lifetime is set to 0, it should clear the time
rather than making the freshly-changed password expire immediately
2023-11-28 21:38:17 -05:00
Joseph Sutton
744678eb03 krb5: Use NULL pointer constant
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
a4b4e982f3 krb5: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
7369cbd11c krb5: Fix spelling of error messages
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
30e3921ad1 krb5: Fix error condition
‘ret’ can only ever be equal to zero.

Found by Coverity (Samba CID 1518754).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
b1f7a63e41 krb5: Fix error code mapping
Found by Coverity (Samba CID 1518726).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
b0f196880c krb5: Check result of calling decode_Ticket()
Found by Coverity (Samba CID 241005).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
0334d9e55a krb5: Check function return values
Found by Coverity (Samba CID 240644).

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
e53d594d05 krb5: Check return value of RAND_bytes()
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Joseph Sutton
62e63b2da6 krb5: Fix unused variable
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-02 20:19:54 -05:00
Nicolas Williams
2a38fa17b5 kdc: Add global disable_pac config param 2023-06-23 13:44:13 -05:00
Joseph Sutton
8640c7c168 krb5: Return appropriate error code 2023-06-20 18:02:15 -05:00
Joseph Sutton
c1bd7772ed third_party/heimdal: Fix deprecation messages
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-06-20 18:02:15 -05:00
Taylor R Campbell
997916e3f6 krb5: Make heimdal_version and heimdal_long_version const.
Pretty sure it is not useful for applications to be able to write to
this.

However, caveat: this could break programs that expect to pass around
&heimdal_version or &heimdal_long_version to functions that expect
pointers to non-const objects even if they don't modify them.
2023-06-20 12:19:48 -05:00
Taylor R Campbell
c69ce29a31 krb5/constants.c: Make some constants constant.
This changes the public header file but I doubt it was ever intended
that applications could change these by writing to them.  (Not sure
why they're not declared as const arrays in any case.)
2023-06-20 12:19:48 -05:00
Taylor R Campbell
29b1faaef6 krb5/send_to_kdc.c: Constify plugin stuff. 2023-06-20 12:19:48 -05:00
Taylor R Campbell
c644d051d8 krb5/pcache.c: Constify plugin stuff. 2023-06-20 12:19:48 -05:00
Taylor R Campbell
1f870603a4 krb5/kuserok.c: Constify plugin stuff. 2023-06-20 12:19:48 -05:00
Taylor R Campbell
2e3dada6fd krb5/krbhst.c: Constify plugin stuff. 2023-06-20 12:19:48 -05:00
Taylor R Campbell
084d638906 krb5/db_plugin.c: Constify plugin stuff. 2023-06-20 12:19:48 -05:00
Taylor R Campbell
da5730a4b0 krb5/aname_to_localname.c: Constify plugin stuff. 2023-06-20 12:19:48 -05:00
Taylor R Campbell
6630cf5889 krb5/plugin.c: Constify. 2023-06-20 12:19:48 -05:00
Taylor R Campbell
b67a083a3c krb5/send_to_kdc.c: Sprinkle const on global data never changed. 2023-06-20 12:19:48 -05:00
Taylor R Campbell
796e420c11 libkrb5, libkdc: Constify salted s2k default iterator counts.
These externs should really be in a .h file shared by definition and
usage sites so the C compiler can verify that they match.
2023-06-20 12:19:48 -05:00
Taylor R Campbell
8f2f159f7f krb/pac.c: Sprinkle const on global data never changed. 2023-06-20 12:19:48 -05:00
Taylor R Campbell
c2c47aec6c krb5/init_creds_pw.c: Sprinkle const on global data not changed. 2023-06-20 12:19:48 -05:00
Taylor R Campbell
35688d030f krb5/get_in_tkt.c: Sprinkle const on global data never changed. 2023-06-20 12:19:48 -05:00