Commit Graph

5905 Commits

Author SHA1 Message Date
Linar Galimov ac1c2d05bc krb5: Fix a double free when running into ENOMEM
In cred_delete(), sp is freed after returning from krb5_storage_to_data().
Between this point and the subsequent assignment to sp via krb_storage_emem()
there are two jumps to out, both are executed in an ENOMEM scenario: malloc fail
for cred_data_in_file and krb5_principal_set_realm() fail. In out, sp is freed
again.

This patch fixes the issue by freeing sp right before the krb5_storage_emem()
call.

Signed-off-by: Linar Galimov <galimovlz@sgu.ru>
Signed-off-by: Dmitry Mikhalchenko <tascad@altlinux.org>
2026-06-23 15:34:32 +01:00
Roland C. Dowdeswell 97b07c5632 krb5: skip vanished keyring ccache keys 2026-06-10 17:26:54 -05:00
Roland C. Dowdeswell 8a0fc8d032 Add credential cache coverage tests 2026-06-10 17:26:54 -05:00
Roland C. Dowdeswell f609aae209 krb5: avoid time-difference overflow
Use krb5_time_abs() rather than subtracting time_t values before passing the result to labs().  On signed 32-bit time_t platforms, subtracting far-apart times can overflow before labs() sees the value.
2026-06-10 09:39:19 -05:00
Roland C. Dowdeswell 9a9da70626 krb5: clean up get_cred_kdc on send context failure
Fixes #1207
2026-05-27 12:12:03 -05:00
Roland C. Dowdeswell 98d6fcacb4 krb5: fix ap_req_nofail documentation
Fixes #1371
2026-05-27 11:56:23 -05:00
Roland C. Dowdeswell 4f147f5e1b doc: trim krb5_verify_user xrefs
Fixes #1127
2026-05-27 16:01:16 +01:00
Roland C. Dowdeswell ef3860d6c3 doc: clean up krb5_init_context man page
Fixes #1125
2026-05-27 15:42:57 +01:00
Florian Best cdd22b6061 refactor(changepw): replace select() with poll()
Issue #1338
2026-05-27 14:16:23 +01:00
Florian Best 73acb1df8e refactor(send_to_kdc): replace select() with poll()
Issue #1338
2026-05-27 14:16:23 +01:00
Roland C. Dowdeswell a66cb84e70 In krb5.conf make underscores and dashes equivalent 2026-05-25 20:14:36 -05:00
Roland C. Dowdeswell e89417f2a1 tests: cover MEMORY ccache cursor invalidation for #547 2026-05-25 20:09:20 -05:00
Roland C. Dowdeswell 3ff4191ba9 krb5: fail krb5_verify_user() early if service key missing
Fixes #1157.
2026-05-25 19:42:40 -05:00
Jennifer Sutton f93aeb3f8f krb5: Correctly check if RC4 enctype is valid
krb5_enctype_valid() returns zero on success.
2026-05-20 11:45:57 -05:00
Jennifer Sutton dafc36e26c krb5: Promote AES SHA2 enctypes to preferred 2026-05-20 11:45:57 -05:00
Jennifer Sutton b7f4f62dfa krb5: Fix non‐RC4 build
The function _krb5_usage2arcfour() is only declared if Heimdal is built with
RC4. Put calls to this function behind #ifdef guards so that the build can
succeed.
2026-05-20 11:43:53 -05:00
Roland C. Dowdeswell e4a885074b krb5: make KRB5_TRACE default to tracing not just debugging 2026-05-19 12:01:42 -05:00
Nicolas Williams 609e36de13 krb5: Only lock keytabs to write to them (fix #1319) 2026-02-08 01:30:28 -06:00
Nicolas Williams 26dca502be kpasswdd: Allow password changes through NATs (fix #1286 again) 2026-01-23 00:37:44 -06:00
Nicolas Williams cc272a4838 krb5: Try up to all kpasswdd IPs (fix #1304) 2026-01-22 23:38:42 -06:00
Nicolas Williams 961370d49f krb5: Add support for "Directional" host address type
Currently the Directional host address type is pretty useless,
since it's only useful in application protocols that a) use
KRB-PRIV/KRB-SAFE messages (so: not GSS-API applications), and b)
state in their specs to use Directional, or otherwise provide for
negotiation of host address types.  There are no such protocols
that we care about except -since we control it- iprop.  But even
for iprop it'd be better to switch to GSS-API.
2026-01-22 22:26:10 -06:00
Nicolas Williams c83b1a12aa roken: Use OFD locks, flock, or POSIX locking, same as MIT 2026-01-22 18:06:28 -06:00
Nicolas Williams 7772534587 krb5: Add missing hunk for #1204 (fix #1305) 2026-01-22 17:39:19 -06:00
Nicolas Williams f47b578ce2 krb5: Add MEMORY threaded test (and fix bugs) 2026-01-22 14:05:26 -06:00
Nicolas Williams f11debe689 krb5: Make socksdrawer setprogname() 2026-01-21 11:45:45 -06:00
Taylor R Campbell 253a001ebc Fix use of accept() in test socks4a proxy.
The read() in readall() to read the SOCKS4a request was sometimes
failing with EAGAIN, which it wasn't prepared for, causing the
request to be rejected and the test to fail.

I wrote this code specifically under the assumption the fd would be
in blocking mode, and in the original draft I wrote with stdin/stdout
under socat that was true.  But when I adapted this to do its own
bind/listen/accept logic, I broke it, because POSIX leaves it
unspecified whether accept() inherits the O_NONBLOCK setting or not:

https://pubs.opengroup.org/onlinepubs/9799919799/functions/accept4.html

And the traditional BSD semantics is to inherit O_NONBLOCK.

So, just explicitly clear O_NONBLOCK on the fd returned by accept().
2026-01-21 10:35:22 -06:00
Nicolas Williams b02d4d4569 krb5: Add SOCKS4a test 2026-01-20 12:57:01 -06:00
Nicolas Williams 31651f8e61 krb5: Add socksdrawer for testing SOCKS4 2026-01-20 12:57:01 -06:00
Taylor R Campbell c768567929 krb5_set_password: Use target principal for SOCKS4a userid.
This enables Tor stream isolation.
2026-01-20 12:57:01 -06:00
Taylor R Campbell 5c5cb66c05 krb5: Set principal as proxy userid when getting creds.
This enables Tor stream isolation.
2026-01-20 12:57:01 -06:00
Taylor R Campbell 7321fd71c6 krb5: Default TCP transport to KDC when SOCKS4a proxy is configured.
Default of UDP transport doesn't work over SOCKS4a anyway, so this
makes configuration with socks4a_proxy easier.
2026-01-20 12:27:05 -06:00
Taylor R Campbell 3b0d00c743 New option [libdefaults] socks4a_proxy.
All network traffic to KDC goes through the SOCKS4a proxy if it is
configured.

This is deliberately kept simple -- and is not generalized to SOCKS4
or SOCKS5 or other types of proxies -- so it is easy to audit for
network and DNS leaks.  (SOCKS4 works in IP addresses, and so invites
DNS leaks.  SOCKS5 can be OK, if used judiciously, but takes more
work to implement.)

This only affects krb5_sendto -- the other initiator of network
traffic in libkrb5, krb5_change_password, will be fixed to respect
socks4a_proxy in a subsequent commit.

XXX Need to figure out where the socks4a.c code should go.

fix https://github.com/heimdal/heimdal/issues/1151
2026-01-20 12:27:05 -06:00
fossdd d233bf84d7 Use <poll.h> insted of <sys/poll.h>
Acording to POSIX <poll.h> should be used instead of <sys/poll.h>.

Libcs like musl libc added a redict due maintain compat with older
glibcs and added the following warning:

	/usr/include/sys/poll.h:1:2: warning: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Wcpp]
	    1 | #warning redirecting incorrect #include <sys/poll.h> to <poll.h>
	      |  ^~~~~~~

Ref: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/poll.h.html
2026-01-18 23:27:57 -06:00
Nicolas Williams a1dfcc8453 krb5: Constify krb5_kuserok() 2026-01-18 19:06:17 -06:00
Taylor R Campbell 5589cf96c7 Sprinkle const and rk_UNCONST throughout the tests. 2026-01-18 19:06:17 -06:00
Taylor R Campbell 9c1b2e963b krb5: Sprinkle const and rk_UNCONST to pacify -Wwrite-strings.
Mostly for read-only iov or krb5_data.
2026-01-18 19:06:17 -06:00
Taylor R Campbell d17fed0c7f krb5/log: Note strict aliasing violation. 2026-01-18 19:06:17 -06:00
Taylor R Campbell c199e31fcd krb5/init_creds_pw.c: Label unconst abuse.
API is just not type-safe here, bummer.
2026-01-18 19:06:17 -06:00
Taylor R Campbell 18dcaf1ca7 krb5/get_cred: Sprinkle const and label & comment unconst abuse. 2026-01-18 19:06:17 -06:00
Taylor R Campbell 4cb23c61c7 krb5/fcache: Sprinkle const; note strict aliasing violation. 2026-01-18 19:06:17 -06:00
Taylor R Campbell 7726409b5c krb5/store: Label unconst abuse for read-only krb5_data. 2026-01-18 19:06:17 -06:00
Taylor R Campbell 9907e29baa krb5/pac: Label unconst abuse for iov. 2026-01-18 19:06:17 -06:00
Taylor R Campbell 270e0d819c krb5/deprecated: Nix const abuse. 2026-01-18 19:06:17 -06:00
Taylor R Campbell 7ec6b6220d krb5/crypto: Label unconst abuse for iov. 2026-01-18 19:06:17 -06:00
Taylor R Campbell 6da033336e krb5/context: Sprinkle const and note strict aliasing violation. 2026-01-18 19:06:17 -06:00
Taylor R Campbell 5c694deee9 _krb5_load_plugins: Sprinkle const. 2026-01-18 19:06:16 -06:00
Nicolas Williams dafe6323fb krb5: Restore 1DES and 3DES 2026-01-18 19:06:16 -06:00
Nicolas Williams cbe156d927 Use OpenSSL 3.x _only_ and implement RFC 8636
- No more OpenSSL 1.x support
 - Remove 1DES and 3DES
 - Remove NETLOGON, NTLM (client and 'digest' service)
2026-01-18 19:06:16 -06:00
Nicolas Williams 7439820618 hcrypto, otp: Remove hcrypto and otp!
We must switch to OpenSSL 3.x, and getting lib/hcrypto to provide
OpenSSL 3.x APIs is too large an undertaking.  Plus the hcrypto backend
is not safe, not secure (probably has timing leaks galore), and no one
has the resources to make it a world-class crypto library, so it just
has to go.
2026-01-18 16:09:31 -06:00
Nicolas Williams 8a52ba7e0f krb5: Free context at exit time in test_set_kvno0.c 2026-01-18 16:08:40 -06:00