3667 Commits

Author SHA1 Message Date
Jeffrey Altman
ec37879038 appl/tests: auditdns eliminate use of 'restrict' keyword if !C99
The 'restrict' keyword was introduced in C99 and provides a hint to
the compiler that can be used to better optimized code.  The 'restrict'
keyword results in build failures when the compiler is not C99.

  auditdns.c:101:37: error: expected ‘;’, ‘,’ or ‘)’ before ‘hints’
     const struct addrinfo *restrict hints,
                                     ^
  auditdns.c:409:45: error: expected ‘;’, ‘,’ or ‘)’ before ‘sa’
     getnameinfo(const struct sockaddr *restrict sa, socklen_t salen,
                                                 ^

This change defines 'register' to nothing if the compiler does not
implement the C99 standard.

Observed with gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44).
2024-09-03 13:41:22 -04:00
Minsoo Choo
aff90c322e Fix spelling 2024-06-16 23:30:48 -04: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
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
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
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
1d2233f907 gssmask: Use asprintf to avoid having to think about max uname.
This way there is no truncation and no build failure due to
-Werror=format-truncation as is the default in some compilers, such
as gcc7.4 with -Wall -Werror.

This is presumably not space-constrained or performance-critical; the
very next thing it does is another asprintf and frees it immediately.
And uname is not usually under any adversary's control.

fix https://github.com/heimdal/heimdal/issues/1105
2023-06-20 23:18:08 -05:00
Nicolas Williams
cc631eb63f gssmask: Fix wrong sizeof() expression 2023-01-04 16:23:07 -06:00
Nicolas Williams
0bedcc5c62 appl: Fix warnings in test utils 2023-01-04 01:36:03 -06:00
Nicolas Williams
deb0c7f940 uu_server: Fix a few leaks 2022-02-11 15:19:58 -06:00
Jeffrey Altman
cd91a3a03e appl/afsutil: expand_cell_name return NULL if not found
In function ‘afslog_cell.isra’:
  afslog.c:144:13: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
  144 |            warnx("No cell matching \"%s\" found.", cell);
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

caused by expand_cell_name() returning the input pointer.
Alter the behavior of expand_cell_name() to match its usage.

Change-Id: I3b15c4b3e59b597af5351e5e62f5d7751be50feb
2022-01-21 08:51:28 -05:00
Jeffrey Altman
3a52803e19 appl/kf: doit close socket before returning
Change-Id: Ida564ea4c27c1bd50004340ac7dbab5f11dbf531
2022-01-17 16:50:42 -05:00
Nicolas Williams
d0f3d826dd otp: Fix warnings 2022-01-14 17:59:49 -06:00
Nicolas Williams
96b7ea671d gss: Fix warnings 2022-01-14 17:39:05 -06:00
Nicolas Williams
5f63215d0d Always perform == or != operation on cmp function result
Although not required to address bad code generation in
some versions of gcc 9 and 10, a coding style that requires
explicit comparison of the result to zero before use is
both clearer and would have avoided the generation of bad
code.

This change converts all use of cmp function usage from

```
    if (strcmp(a, b) || !strcmp(c, d)) ...
```

to

```
    if (strcmp(a, b) != 0 || strcmp(c, d)) == 0
```

for all C library cmp functions and related:

 - strcmp(), strncmp()
 - strcasecmp(), strncasecmp()
 - stricmp(), strnicmp()
 - memcmp()

Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
2021-11-24 22:30:44 -05:00
Luke Howard
014f16883c libhcrypto: UI_UTIL_FLAG_VERIFY_SILENT 2018-12-30 15:39:49 -06:00
Nicolas Williams
3f1451a4c3 Remove get_default_username() 2018-12-25 22:11:19 -06:00
Nicolas Williams
620862049e Use roken_get_*() instead of getpwuuid()
Using non-reentrant getpwuid() (or getpwnam(), or getspnam())  can be
dangerous.  We had a report of a login application / PAM that calls
those, and Heimdal, by calling them too, clobbered the cached struct
passwd used by the login app / PAM.
2018-12-25 22:11:19 -06:00
Nicolas Williams
8a77f45aff Remove appl/su 2018-12-25 22:11:19 -06:00
Jeffrey Altman
93518bfab4 use memset_s
lib roken includes support for memset_s() but it was not applied
to the Heimdal source tree.

Change-Id: I8362ec97a9be50205bb2d398e65b629b88ce1acd
2017-04-29 01:05:59 -04:00
Nicolas Williams
63a4c0d665 su also doesn't need issuid() 2017-04-17 18:02:30 -04:00
Nicolas Williams
8e5e8aacbc Misc fixes to man pages
Originally by Christos Zoulas.
2017-03-13 18:39:41 -04:00
Quanah Gibson-Mount
7c16ce3457 Minor typo/grammar fixes 2017-03-10 15:47:43 -05:00
Nicolas Williams
ecb0b6b590 Close stray unclosed .Bd roff directive 2016-12-14 22:05:58 -06:00
Nicolas Williams
52a562a3a4 Misc fixes (coverity) 2016-11-18 22:21:45 -06:00
Jeffrey Altman
d4622f12e5 gssmask: HandleOp unused var principal
Always NULL.

Change-Id: I65074562b029effcec62c4edb5d33e3289a634db
2016-11-18 21:59:18 -05:00
Jeffrey Altman
84e959a752 gssmask: log_function memory leak
Do not leak 'file' on error and reduce clutter. free() in common exit
path.

Change-Id: Icb187ea50e9c3d405076a192aa61cbade4b6d7d4
2016-11-14 17:02:02 -05:00
Jeffrey Altman
d3fc257245 gssmask: client_connect addrinfo leak
In client_connect() getaddrinfo() stores the head of the allocated
addrinfo structure list in 'res0'.  'res' is used to walk the list
and will be NULL at the end of the for() loop when freeaddrinfo(res)
is executed.  Pass 'res0' to freeaddrinfo() instead of 'res'.

Change-Id: Ie1358c0356b6b0f98470e46e25216cfa0ab4adac
2016-11-14 16:56:08 -05:00
Viktor Dukhovni
bb507cd4d4 Goodbye push 2016-11-14 14:19:58 -05:00
Viktor Dukhovni
b77e701a22 Goodbye login 2016-11-14 02:59:12 -05:00
Viktor Dukhovni
63d2935c4f Goodbye FTP 2016-11-14 02:42:08 -05:00
Nicolas Williams
76c596ceb8 Complete support for --disable-afs-support 2016-08-10 19:51:11 -05:00
Jeffrey Altman
22c5327287 gssmask: check return of krb5_init_context
Check the return value so that a more obtuse error does not occur
later on.

Change-Id: I2115cc58e6fc24b63272b2ae811d64a4966de5d4
2016-04-17 15:11:14 -05:00
Nicolas Williams
490337f4f9 Make OpenSSL an hcrypto backend proper
This adds a new backend for libhcrypto: the OpenSSL backend.

Now libhcrypto has these backends:

 - hcrypto itself (i.e., the algorithms coded in lib/hcrypto)
 - Common Crypto (OS X)
 - PKCS#11 (specifically for Solaris, but not Solaris-specific)
 - Windows CNG (Windows)
 - OpenSSL (generic)

The ./configure --with-openssl=... option no longer disables the use of
hcrypto.  Instead it enables the use of OpenSSL as a (and the default)
backend in libhcrypto.  The libhcrypto framework is now always used.

OpenSSL should no longer be used directly within Heimdal, except in the
OpenSSL hcrypto backend itself, and files where elliptic curve (EC)
crypto is needed.

Because libhcrypto's EC support is incomplete, we can only use OpenSSL
for EC.  Currently that means separating all EC-using code so that it
does not use hcrypto, thus the libhx509/hxtool and PKINIT EC code has
been moved out of the files it used to be in.
2016-04-15 00:16:17 -05:00
Nicolas Williams
c6f24e99f0 Revamp cf/db.m4; test LMDB 2016-02-26 00:55:32 -06:00
vdukhovni
beb187b9ac Merge pull request #127 from jelmer/typo-fixes
Typo: enviroment -> environment.
2015-04-25 13:58:46 -04:00
Jelmer Vernooij
9eb31585c0 Typo: enviroment -> environment. 2015-04-25 17:37:17 +00:00
Nicolas Williams
73c4db7269 coverity 745505 2015-04-18 23:19:25 -05:00
Love Hörnquist Åstrand
920eccc59e X11 tools have outlived their usefulness, use SSH and pam with native locker 2015-03-04 19:18:00 -08:00
Viktor Dukhovni
a71fa7b04d Silence LLVM compiler warnings
Should we simply drop FTP from the source at some point?
2015-03-04 19:44:20 -05:00
Love Hörnquist Åstrand
37afa01be3 rename roken base64, fixes #107 2014-08-22 20:57:24 -07:00
Jelmer Vernooij
ea062e4bb2 Remove references to KRBTKFILE from login.1 and kinit.1. 2014-06-02 00:32:37 +02:00
Jelmer Vernooij
5a75d6fe43 afslog.1: Remove documentation for removed no-v4 argument. 2014-06-02 00:32:37 +02:00
Jelmer Vernooij
70e43e9808 Fix some typos. 2014-04-25 02:42:17 +02:00
Love Hörnquist Åstrand
9c560f8443 use noinst_HEADERS for login-protos.h 2014-02-16 10:04:49 -08:00
Love Hörnquist Åstrand
e55b0d0ca5 delete POP3, telnet and rsh/rcp support 2014-02-16 09:14:19 -08:00
Jeffrey Altman
dba026b5ef Introduce and apply krb5_storage_from_socket
On Windows a file descriptor is an int value allocated by the
local module instance of the C Run Time Library.  A socket handle is a
SOCKET value allocated by a Winsock Provider for the requested family and
protocol.   These two values cannot be mixed and there is no mechanism for
converting between the two.   The _get_osfhandle() and _open_osfhandle()
functions can work with a standard HANDLE (file, pipe, etc) but cannot be
used for a SOCKET.

The Heimdal krb5_storage_from_fd() routine counted on the osf conversion
functions working on SOCKET values.  Since they do not any attempt to call
krb5_storage_from_fd() on a socket resulted in an assertion being thrown
by the C RTL.

Another problem is SOCKET value truncation when storing a 64-bit value
into a 32-bit int.

To address these problems a new krb5_storage_from_socket() routine is
introduced.  This routine setups a krb5_storage that stores a socket value
as a rk_socket_t and provides a set of helper routines that always use
network ready functions.

The krb5_storage_from_fd() routines no longer use net_read() and
net_write() but provide helpers that follow their logic so that pipes can
be processed.

All call sites that allocate a socket now store the socket as rk_socket_t
and call krb5_storage_from_socket().

All locations that previously called the bare close() on a socket value
now call rk_closesocket().

Change-Id: I045f775b2a5dbf5cf803751409490bc27fffe597
2014-02-04 23:20:08 -05:00
Love Hornquist Astrand
2107924b37 catch error from krb5_ functions
Reported by http://www.forallsecure.com/bug-reports/2f227b78584144ab1f55549b36ea16ba2d1664e0/ via
Brian May <bam@debian.org>
2013-06-28 08:46:26 +02:00
Nicolas Williams
a53f3a49e2 Fix unused variable warnings 2013-06-02 15:52:41 -05:00