Commit Graph

30837 Commits

Author SHA1 Message Date
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
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
12ed86de90 wind: Fix incorrect coding lines
Commit e172367898 converted all these
files to UTF-8, but didn’t change the coding lines.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
ff079377f2 wind: Do not use invalid escape sequences
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
a9f21ebdac roken: Const-qualify sys_errlist
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
db5c8711b4 kuser: Fix error produced by compiling with FORTIFY_SOURCE=2
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -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
0e9e1a4f31 kdc: Make parameter const
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
ffac143401 kdc: Finish incomplete log message
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
9ba687cf22 kdc: Fix log message
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
68b475fa2e kdc: Finish incomplete warning message
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
079088e543 kdc: Fix incorrect log message
‘list.len’ can be equal to zero.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
e8b42d9d42 hx509: Fix incorrect documentation comment
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
bbe9c83b19 hx509: Remove unused variable
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
59f89e4b15 hx509: Avoid misleading error message
If ‘keyid’ is an empty string, then the numeric error code that gets
appended to this error message may be mistaken for the key ID. Address
this by not mentioning any ID in such cases.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
df6c33ff1e hx509: Use NULL pointer constant
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
e9bc20f5da hcrypto: Fix errors produced by compiling with FORTIFY_SOURCE=2
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:37:56 -05:00
Joseph Sutton
1f88e8c919 wind: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -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
91d54fd4c9 kinit: Fix code spelling
This flag has no apparent relation to the process of converting
waterways into canals.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
fbe89adf27 kdc: Fix spelling of error and log messages
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
560c9da844 kdc: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
05602c2286 hx509: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
ef083a0e2c hx509: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
61bf5009a0 hx509: Fix spelling of error messages
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
d9d3dd448d hdb: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
7cb320b46a hdb: Fix error messages
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
551f0c32fa base: Fix code spelling
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-28 21:34:35 -05:00
Joseph Sutton
a3878d3e9d wind: Deny invalid UTF-8 encodings
Codepoints above U+10FFFF and overlong encodings are considered invalid.
Unpaired surrogates are not, as these are known to be generated on
occasion — by Windows, for example.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-08 14:58:21 -06:00
Joseph Sutton
bf25b38c0a wind: Support UTF-8–encoding non-BMP codepoints
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-08 14:58:21 -06:00
Joseph Sutton
ba63461cd4 wind: Support UTF-16–encoding non-BMP codepoints
View with ‘git show -b’.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-08 14:58:21 -06:00
Joseph Sutton
821fac3648 wind: Use portable integer types
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-08 14:58:21 -06:00
Joseph Sutton
db70a76074 wind: Do not perform arithmetic on a NULL pointer
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-08 14:58:21 -06:00
Joseph Sutton
ed798da1f2 wind: Fix documentation comment
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2023-11-08 14:58:21 -06:00
Nicolas Williams
d274f0e240 bx509: Test CSRs w/ BasicConstraints in extReq 2023-11-08 14:22:02 -06:00
Nicolas Williams
2ad736a579 hx509: Fix EACCES / ENOMEM confusion 2023-11-08 14:22:02 -06:00
Nicolas Williams
be0d1e68e5 hx509: Add support for CSRs w/ BasicConstraints 2023-11-08 14:22:02 -06:00
Taylor R Campbell
0f998cdbc2 ktutil: Avoid even doing arithmetic on res after realloc(res, ...).
Under C99, Sec 6.2.4, paragraph 2:

    The value of a pointer becomes indeterminate when the object it
    points to reaches the end of its lifetime.

`Indeterminate' (3.17.2) includes a trap representation, and any
reference to a trap representation is undefined behaviour.  Thus,
after realloc(res, ...) succeeds, any reference to res (or p) is
undefined behaviour.

So, instead of using `p - res` after res has been freed, use the
existing name for the value we know it has now: len.  (We could also
use alloced because p == end in this branch, and end = res + alloced,
and p = res + len.  Of course, we would have to move it up a line to
before we update alloced to have a different value.)

fix https://github.com/heimdal/heimdal/issues/1164
2023-11-07 14:20:40 -06:00