Commit Graph

30876 Commits

Author SHA1 Message Date
Florian Weimer
323d555c82 cf: Do not use headers and argument lists in AC_FIND_FUNC_NO_LIBS2
The callers of this macro generally do not supply this information.
Without it, the checks rely on compiler support for implicit function
declarations.  It would be possible to supply this information in
the callers.  But even then, with the existing macro interface, it
would be necessary to pass eg. null pointers where they trigger
undefined behavior.  Therefore, use the same kludge that autoconf
uses to make up prototypes, avoiding those implicit function
declarations.

The includes/arguments macro parameters are now ignored, but preserved
for interface compatibility.
2024-09-03 11:12:23 -04:00
Florian Weimer
c711cbf7cc cf: Include <string.h> for memset in AC_HAVE_STRUCT_FIELD
Otherwise, the check relies on an implicit function declaration,
and will fail unconditionally with compilers that do not support
them.
2024-09-03 11:12:23 -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
Jo Sutton
6b08c05258 kdc: Enforce hardware authentication for accounts requiring it
Signed-off-by: Jo Sutton <josutton@catalyst.net.nz>
2024-07-06 16:08:56 -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
Simon Wilkinson
2f7a9d9530 gssapi: Fix ordering logic in _gssapi_msg_order_check
A typo in _gssapi_msg_order_check means that sequence numbers
received out of sequence are not correctly added to the internal
order array.
2024-07-06 16:06:54 -04:00
Simon Wilkinson
05e292e1af gssapi: Sequence errors should not be fatal
Sequence errors are supplemental information in GSSAPI. This means
that they are not fatal, unless they are returned alongside a failure
error code. This change makes our behaviour the same as MIT's - sequence
errors are non-fatal, and return valid output information.
2024-07-06 16:06:54 -04:00
Bernd Kuhls
1b57b62d82 cf/largefile.m4: Fix build with autoconf-2.72
Fixes https://github.com/heimdal/heimdal/issues/1201
2024-06-16 23:31:51 -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
Jeffrey Altman
c753ed5b7f kdc: APPLE disable enable-pkinit by default as documented
commit 4d48b172ab ("add pkinit
configration for btmm") introduced automatic configuration of
the 'pkinit_kdc_identity' and 'pkinit_kdc_friendly_name' on macOS
but also modified the default for the 'enable_pkinit' setting
such that pkinit is enabled on all __APPLE__ platforms overriding
the [kdc] enable-pkinit setting obtained from the configuration.

This change modifies the enable-pkinit behavior on __APPLE__ platforms
to match those on every other platform.  __APPLE__ platforms will
continue to auto-configure the [kdc] pkinit_identity and
[kdc] pkinit_anchors if they are not specified in the configuration.
2024-06-16 23:27:37 -04:00
Jeffrey Altman
5ba8b7f177 gssapi/mech: -Wcalloc-transposed args
warning: 'calloc' sizes specified with 'sizeof' in the earlier argument
and not in the later argument [-Wcalloc-transposed-args].

Swap the args.
2024-06-04 06:22:37 -04:00
Jeffrey Altman
2d89b4c27c kdc: -Wcalloc-transposed args
warning: 'calloc' sizes specified with 'sizeof' in the earlier argument
and not in the later argument [-Wcalloc-transposed-args].

Swap the args.
2024-06-04 06:22:37 -04:00
Jeffrey Altman
1ffff7e4ff kadmin: ext.c -Wcalloc-transposed args
warning: 'calloc' sizes specified with 'sizeof' in the earlier argument
and not in the later argument [-Wcalloc-transposed-args].

Swap the args.
2024-06-04 06:22:37 -04:00
Jeffrey Altman
b74ab765c7 sl: osad -Wcalloc-transposed args
warning: 'calloc' sizes specified with 'sizeof' in the earlier argument
and not in the later argument [-Wcalloc-transposed-args].

Swap the args.
2024-06-04 06:22:37 -04:00
Jeffrey Altman
17402aef07 roken: warning: ‘line’ defined but not used [-Wunused-variable]
In rkpty.c line[] must be defined if defined(HAVE_OPENPTY),
defined(__osf__), or defined(STREAMSPTY).  Otherwise, it is unused.
2024-06-04 06:22:37 -04:00
Jeffrey Altman
17f31adbff gssapi/krb5: _gsskrb5_display_name return GSS_C_NT_ANONYMOUS
If the Kerberos v5 principal name is

  WELLKNOWN/ANONYMOUS@WELLKNOWN:ANONYMOUS

and the principal type is KRB5_NT_WELLKNOWN, then gss_display_name()
is expected to return GSS_C_NT_ANONYMOUS instead of
GSS_KRB5_NT_PRINCIPAL_NAME.  This change matches the behavior of
MIT Kerberos.
2024-06-04 06:22:37 -04:00
Daria Phoebe Brashear
d8c10e68a6 kdc: per-target CPPFLAGS do not have an _AM in the variable name
when microhttpd is present, bx509d does not build because the
automake-emitted makefile is wrong
2024-05-20 22:04:21 -04:00
Nicolas Williams
1b62220778 tests: Use here-doc kadmin in Java test 2024-01-20 16:13:21 -06:00
Nicolas Williams
366016b1f6 tests: Speed up tests/gss/check-gssmask 2024-01-17 16:55:35 -06:00
Nicolas Williams
1aa0a495c2 tests: Use kadmin w/ here-document to speed up tests 2024-01-16 16:28:35 -06:00
Nicolas Williams
016373931d tests: Kill daemons on ^C 2024-01-16 16:28:35 -06:00
Nicolas Williams
7a0915c630 tests: Make check-hdb-mitdb a bit more verbose 2024-01-16 16:28:35 -06:00
Nicolas Williams
408a62a7b4 cf: Add --with-mitdb=PATH option
OS X builds started thinking they have the mitdb backend and started
failing the tests/kdc/check-mitdb test.  This commit fixes that by
requiring explicit enablement of the mitdb HDB backend.
2024-01-16 16:28:35 -06:00
Nicolas Williams
2e94b7855c doc: Clarify kdc --ports / [kdc] ports (fix #1223) 2024-01-16 11:28:35 -06:00
Taylor R Campbell
cb9a130322 auditdns: Cover getnameinfo and gethostbyaddr too.
Fixes the final remaining part of:
https://github.com/heimdal/heimdal/issues/1214
2024-01-09 21:19:30 -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
4d39fe8d04 libroken: Fill in NI_NUMERICSCOPE as 0 if not defined.
This flag has defined by POSIX for years if not decades, but glibc
and Windows apparently still don't have it.

We will use it with getnameinfo, along with all other NI_NUMERICxxx
options, to minimize risk of network leaks with block_dns.
2024-01-09 21:19:30 -06:00
Taylor R Campbell
d73910c588 auditdns: Tidy up minor issues.
- Omit needless semicolon.
- Reject obscene service numbers in getaddrinfo.
- Fix mistake in comment about EAI_NONAME failure branch.

Leftovers from: https://github.com/heimdal/heimdal/pull/1213
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
Joseph Sutton
597b59dfb7 kdc: Return NEVER_VALID error code if ticket will never be valid
This matches the error generated by Windows.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2024-01-09 16:06:06 -06:00
Stefan Metzmacher
baf1930b6a kdc: don't fail salt_fastuser_crypto with r->req.req_body.cname == NULL for TGS-REQ 2024-01-09 16:06:06 -06:00
Joseph Sutton
4de8b3564e kdc: Fix leak with PK-INIT-Win2k
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2024-01-09 16:06:06 -06:00
Joseph Sutton
71fd391036 kdc: Fix spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2024-01-09 16:06:06 -06:00
Stefan Metzmacher
13d3bcf1d0 cf/make-proto.pl: make JSON:PP optional
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2024-01-08 10:23:25 -06:00
Taylor R Campbell
ad23636db8 Add a test for potential DNS leaks via symbol interposition.
We build variants of kinit and test_acquire_cred that define their
own symbols rk_dns_lookup, gethostbyname, gethostbyname2, and
getaddrinfo to print a message and abort.  For getaddrinfo, we abort
only if the caller failed to specify AI_NUMERICHOST; otherwise we use
dlsym(RTLD_NEXT, "getaddrinfo") instead.

The new test tests/gss/check-nodns is like tests/gss/check-basic, but
uses kinit_auditdns and test_acquire_cred_auditdns to verify that no
DNS resolution happens.

This test should work and be effective on ELF platforms where the
getaddrinfo function is implemented by the symbol `getaddrinfo'.  On
non-ELF platforms it may not be effective -- and on platforms where
the getaddrinfo function is implemented by another symbol (like
`__getaddrinfo50') it may not work, but we can cross that bridge when
we come to it.

Verified manually that the test fails, with the expected error
message and abort, without `block_dns = yes' in krb5-nodns.conf.  No
automatic test of the mechanism for now because it might not work on
some platforms.

XXX check-nodns.in is copypasta of check-basic.in, should factor out
the common parts so they don't get out of sync.
2024-01-08 10:22:02 -06:00
Taylor R Campbell
e2c0d98965 lib/roken/syslog.c: Initialize hostname to avoid DNS lookups.
Previously, the hostname was initialized to `localhost'.  If it was
not cleared by init_syslog, init_logger_addr (via openlog) would
query gethostbyname to find the IP address of `localhost', which will
essentially always be 127.0.0.1.  But if it was cleared by
init_syslog, init_logger_addr would return 127.0.0.1 anyway.

This way, it always returns 127.0.0.1 in the event of no init_syslog
call, and avoids a DNS lookup.  You can always force a DNS lookup by
passing `localhost' to init_syslog explicitly, of course.

I'm not sure if anything even uses this as a fallback in Heimdal, but
let's avoid leaving a rake to step on.
2024-01-08 10:22:02 -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
Nicolas Williams
42e23b1777 roken: Export rk_getpwnam_r() (fix #1097)
Bug and fix reported by https://github.com/esaaprillia.
2024-01-05 11:39:19 -06:00
Jan Palus
ff41f2ae7c cf: link libatomic if needed
heimdal uses 8-byte (64-bits) atomic operations for a while now (ie in
lib/krb5/krcache.c). however some platforms (ie i386, i486, ARM < 7)
don't support them natively and need to be linked against libatomic in
order to implement functionallity from <stdatomic.h>.

if the header was found check 64-bit atomics work without any additional
libraries. if not try to add linking with libatomic. if that fails as
well fallback to -DHEIM_BASE_ATOMICS_FALLBACK

no change for platfroms without <stdatomic.h>

Fixes: #1186
2024-01-04 14:23:17 -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
Nicolas Williams
f455ea9834 tests: Make make -j8 check work
In the future we should also make it so that `make check` for `tests/db`,
`tests/gss`, and `tests/kdc` first initializes all the realms and starts all
the daemons, then runs the actual checks possibly in parallel, then shuts down
the daemons.  This will require quite a bit of work, so for now we just disable
parallel make in those directories.
2024-01-03 18:48:02 -06:00
Nicolas Williams
3253c49544 hx509: Add support for CSRs w/ BasicConstraints (fix) 2023-11-29 13:16:16 -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