]> git.ipfire.org Git - thirdparty/krb5.git/log
thirdparty/krb5.git
7 months agoFix minor logic errors 1392/head
Greg Hudson [Sun, 17 Nov 2024 18:54:12 +0000 (13:54 -0500)] 
Fix minor logic errors

In k5_externalize_auth_context(), serialize the correct field when
remote_port is set.  This is not a reachable bug because the function
is only accessible via gss_export_sec_context(), and the GSS library
does not set a remote port.

In generic_gss_oid_to_str(), remove an inconsistently-applied test for
a null minor_status.  Also remove minor_status null checks from
generic_gss_release_oid() and generic_gss_str_to_oid(), but add output
initializations and pointer checks to the API functions in g_oid_ops.c
in a similar manner to other GSSAPI functions.  Remove
gssint_copy_oid_set() and replace its one call with a call to
generic_gss_copy_oid_set().

In the checksum functions, avoid crashing if the caller passes a null
key and checksum type 0.  An error will be returned instead when
find_cksumtype() can't find the checksum type.
(krb5_k_verify_checksum() already had this check.)

In pkinit_open_session(), remove an unnecessary null check for
ctx->p11_module_name, and add a check for p11name being null due to an
asprintf() failure.

In profile_add_node(), add a check for null ret_node in the duplicate
subsection check.  This is not a reachable bug because the function is
currently never called with null ret_node and null value.

In ksu's main(), check for krb5_cc_default_name() returning NULL
(which only happens on allocation failure).  Also clean up some
vestiges left behind by commit
9ebae7cb434b9b177c0af85c67a6d6267f46bc68.

In ksu's get_authorized_princ_names(), close login_fp if we fail to
open k5users_path.

In the KDC and kpropd write_pid_file(), avoid briefly leaking the file
handle on write failure.

Reported by Valery Fedorenko.

7 months agoFix Windows regression in k5_make_uri_query() 1399/head
Ken Hornstein [Wed, 4 Dec 2024 02:54:35 +0000 (21:54 -0500)] 
Fix Windows regression in k5_make_uri_query()

Commit d035119c3b2b402f3ad49a4c7b6264826ea923bb introduced an extra
parameter to the function k5_make_uri_query(), but did not add that
parameter to the Windows stub version of this function, causing a null
pointer exception when this function was called.  Add the parameter
now.

[ghudson@mit.edu: edited commit message]

7 months agoFix LDAP module leak on authentication error 1395/head
Feng Guo [Thu, 28 Nov 2024 13:32:37 +0000 (21:32 +0800)] 
Fix LDAP module leak on authentication error

In initialize_server(), unbind the server handle if authenticate()
fails.

[ghudson@mit.edu: rewrote commit message]

ticket: 9153 (new)

8 months agoCheck for sys/random.h 1397/head
Ken Hornstein [Fri, 29 Nov 2024 21:32:06 +0000 (16:32 -0500)] 
Check for sys/random.h

The function getentropy() is supported on newer versions of MacOS X,
but requires the include file sys/random.h.  Check for that and include
it where getentropy() is used.

ticket: 9149

8 months agoConstify some socket-utils.h functions
Greg Hudson [Mon, 18 Nov 2024 23:45:16 +0000 (18:45 -0500)] 
Constify some socket-utils.h functions

Accept constant pointers in sa_getport(), sa_is_inet(),
sa_is_wildcard(), and sa_socklen().

Make sa2sin() and sa2sin6() accept and return constant pointers.  For
the most part we write to sockaddr_storage and read from sockaddr.
The biggest exception is udppktinfo.c; adjust its internal APIs to use
sockaddr_storage for output and inferred lengths for input.  All of
the other exceptions use sa_setport().

8 months agoAdd kadmind support for disabling listening
Andreas Schneider [Fri, 8 Nov 2024 08:57:59 +0000 (09:57 +0100)] 
Add kadmind support for disabling listening

Currently setting kdc_listen or kdc_tcp_listen to the empty string
disables listening for UDP and TCP connections respectively, but
setting kadmind_listen or kpasswd_listen to the empty string listens
on the wildcard address.  Make the behavior consistent by changing
loop_add_addresses() to add no listeners when the string contains no
tokens.  Remove the conditionals from the KDC code.

Document the new behavior of kadmind_listen and kpasswd_listen, and
the existing behavior of kdc_listen.

[ghudson@mit.edu: simplified loop_add_addresses(); combined several
commits and rewrote commit message]

ticket: 9151 (new)

8 months agoRemove missing SecurID header file 1390/head
Ken Hornstein [Wed, 13 Nov 2024 18:48:28 +0000 (13:48 -0500)] 
Remove missing SecurID header file

It turns out the SecurID SDK no longer provides sdi_athd.h, so
remove our include of it.

8 months agoUpdate upload-artifact version in cifuzz.yml
Greg Hudson [Thu, 14 Nov 2024 04:13:37 +0000 (23:13 -0500)] 
Update upload-artifact version in cifuzz.yml

Commit 177d750222b758f5f5769c727340d12bfcd79488 missed a use of
upload-artifact@v3.  Update it now.

8 months agoRemove ovload.c 1388/head
Greg Hudson [Fri, 1 Nov 2024 17:45:15 +0000 (13:45 -0400)] 
Remove ovload.c

Commit 23b93fd48bc445005436c5be98a7269b599b1800 removed the only
caller of process_ov_record(), but left behind the code.  Remove it
now.

8 months agoFix various small logic errors
Greg Hudson [Fri, 1 Nov 2024 17:42:44 +0000 (13:42 -0400)] 
Fix various small logic errors

Correct five logic errors (all unlikely to manifest as user-visible
bugs) found by static analysis.  Reported by Valery Fedorenko.

8 months agoPrevent undefined shift in decode_krb5_flags() 1389/head
Greg Hudson [Wed, 6 Nov 2024 22:31:37 +0000 (17:31 -0500)] 
Prevent undefined shift in decode_krb5_flags()

In the statement "f |= bits[i] << (8 * (3 - i))", bits[i] is
implicitly promoted from uint8_t to int according to the integer
promotion rules (C99 6.3.1.1).  If i is 0 and bits[i] >= 128, the
result cannot be represented as an int and the behavior of the shift
is undefined (C99 6.5.7).  To ensure that the shift operation is
defined, cast bits[i] to uint32_t.

(f and the function output are int32_t, but the conversion of uint32_t
to int32_t is implementation-defined when the value cannot be
represented, not undefined.  We check in configure.ac that the
platform is two's complement.)

(Discovered by OSS-Fuzz.)

8 months agoUse getentropy() when available 1387/head
Greg Hudson [Wed, 30 Oct 2024 21:08:00 +0000 (17:08 -0400)] 
Use getentropy() when available

When available, use getentropy() in preference to SYS_getrandom or
/dev/urandom.  This binding is present in glibc 2.25 and the BSDs.

ticket: 9149 (new)

8 months agoFix krb5_ldap_list_policy() filtering loop 1384/head
Greg Hudson [Sun, 27 Oct 2024 23:01:51 +0000 (19:01 -0400)] 
Fix krb5_ldap_list_policy() filtering loop

The loop at the end of this function is intended to ignore ticket
policy DNs that can't be converted to names.  But it instead leaves a
hole in the output list if that happens, effectively truncating the
list and leaking any subsequent entries.  Use the correct index for
the output list.

ticket: 9148 (new)

8 months agoFix type violation in libkrad 1385/head
Greg Hudson [Mon, 28 Oct 2024 15:51:54 +0000 (11:51 -0400)] 
Fix type violation in libkrad

remote.c uses casts to cover up a signature difference between
iterator() and krad_packet_iter_cb.  The difference is unimportant in
typical platform ABIs, but calling the function this way is undefined
behavior (C99 6.3.2.8).  Fix iterator() to conform to
krad_packet_iter_cb and remove the casts.

8 months agoAdd new OSS-Fuzz targets 1366/head
Arjun [Fri, 11 Oct 2024 06:28:06 +0000 (11:58 +0530)] 
Add new OSS-Fuzz targets

[ghudson@mit.edu: made minor style edits; edited commit message]

bigredbutton: whitespace

8 months agoAdd coverage to existing OSS-Fuzz targets
Arjun [Mon, 30 Sep 2024 11:44:10 +0000 (17:14 +0530)] 
Add coverage to existing OSS-Fuzz targets

Also fix the dependencies of fuzz_chpw, remove NDROBJ from Makefile in
favor of including ndr.c from fuzz_ndr.c, and add one new corpus for
fuzz_gss.

[ghudson@mit.edu: added initializers to variables used in cleanup
handlers; edited commit message]

9 months agoAdd numeric constants to krad.h and use them 1381/head
Greg Hudson [Thu, 17 Oct 2024 00:26:57 +0000 (20:26 -0400)] 
Add numeric constants to krad.h and use them

ticket: 9147 (new)

9 months agoUse size_t indexes for null-terminated arrays 1373/head
Greg Hudson [Sat, 14 Sep 2024 22:14:51 +0000 (18:14 -0400)] 
Use size_t indexes for null-terminated arrays

When operating on arrays that don't have a specified integer bound,
use size_t indexes for improved safety.  Reported by James Watt.

9 months agoAllow null keyblocks in IOV checksum functions 1382/head
Greg Hudson [Sun, 20 Oct 2024 06:09:26 +0000 (02:09 -0400)] 
Allow null keyblocks in IOV checksum functions

Null keyblocks are allowed by the libk5crypto checksum functions when
the checksum type is not keyed.  However, krb5_c_make_checksum_iov()
and krb5_c_verify_checksum_iov() crash on null keyblock inputs because
they do not check before converting to krb5_key as their non-IOV
variants do.  Add the missing null checks.

ticket: 9146 (new)

9 months agoPrevent late initialization of GSS error map 1383/head
Greg Hudson [Mon, 21 Oct 2024 23:04:08 +0000 (19:04 -0400)] 
Prevent late initialization of GSS error map

Some of the peripheral libgssapi_krb5 utility functions, such as
gss_str_to_oid(), do not access the mechanism list and therefore do
not reach any of the calls to gssint_mechglue_initialize_library().
If one of these functions is called early and produces an error, its
call to map_error() will operate on the uninitialized error map.  When
the library is later initialized, any entries added to the error map
this way will be leaked.

To ensure that the error map is initialized before it is operated on,
add library initialization calls to gssint_mecherrmap_map() and
gssint_mecherrmap_get().

ticket: 9145 (new)

9 months agoFix unlikely password change leak
Andreas Schneider [Fri, 11 Oct 2024 10:45:13 +0000 (12:45 +0200)] 
Fix unlikely password change leak

In kpasswd_sendto_msg_callback(), if getsockname() does not reveal the
local address, a copy of the first local address's contents is made
and never freed.  Instead of making an allocated copy of the address
contents, make a shallow copy of the whole address.  Delay freeing the
address array until the end of the function so that alias pointer made
by the shallow copy remains valid.

[ghudson@mit.edu: further simplified code; rewrote commit message]

9 months agoFix libkadm5 parameter leak
Andreas Schneider [Fri, 11 Oct 2024 09:38:03 +0000 (11:38 +0200)] 
Fix libkadm5 parameter leak

Commit aa91cb5dbbd4356c7a9069f4f52a10f70d91bc00 added kadmind_listen,
kpasswd_listen, and iprop_listen fields to kadm5_config_params, but
did not add them to the fields freed in kadm5_free_config_params().
Add them now.

[ghudson@mit.edu: rewrote commit message]

9 months agoGenerate and verify message MACs in libkrad 1370/head
Julien Rische [Thu, 22 Aug 2024 15:15:50 +0000 (17:15 +0200)] 
Generate and verify message MACs in libkrad

Implement some of the measures specified in
draft-ietf-radext-deprecating-radius-03 for mitigating the BlastRADIUS
attack (CVE-2024-3596):

* Include a Message-Authenticator MAC as the first attribute when
  generating a packet of type Access-Request, Access-Reject,
  Access-Accept, or Access-Challenge (sections 5.2.1 and 5.2.4), if
  the secret is non-empty.  (An empty secret indicates the use of Unix
  domain socket transport.)

* Validate the Message-Authenticator MAC in received packets, if
  present.

FreeRADIUS enforces Message-Authenticator as of versions 3.2.5 and
3.0.27.  libkrad must generate Message-Authenticator attributes in
order to remain compatible with these implementations.

[ghudson@mit.edu: adjusted style and naming; simplified some
functions; edited commit message]

ticket: 9142 (new)
tags: pullup
target_version: 1.21-next

9 months agoFix potential PAC processing crash 1378/head
Arjun [Fri, 11 Oct 2024 03:22:52 +0000 (08:52 +0530)] 
Fix potential PAC processing crash

An input to krb5_pac_parse() with a zero-length buffer at the end of
the PAC can cause an assertion failure in k5_pac_locate_buffer() due
to an off-by-one error.  Correct the assertion.

[ghudson@mit.edu: edited commit message]

ticket: 9144 (new)
tags: pullup
target_version: 1.21-next

9 months agoFix memory leak in PAC checksum verification
Arjun [Thu, 10 Oct 2024 19:25:59 +0000 (00:55 +0530)] 
Fix memory leak in PAC checksum verification

If the server checksum length is invalid, do proper cleanup in
verify_pac_checksums() before returning.

[ghudson@mit.edu: edited commit message]

ticket: 9143 (new)
tags: pullup
target_version: 1.21-next

9 months agoDisable include and includedir in fuzzing build
Arjun [Thu, 10 Oct 2024 19:07:52 +0000 (00:37 +0530)] 
Disable include and includedir in fuzzing build

When building for fuzz teting, ignore "include" and "incluedir"
directives in the profile library's parse_line(), to prevent it from
trying to open non-existent paths generated by the fuzzing library.

[ghudson@mit.edu: edited commit message]

9 months agoRemove ancient platforms from shlib.conf 1372/head
Greg Hudson [Thu, 19 Sep 2024 06:26:02 +0000 (02:26 -0400)] 
Remove ancient platforms from shlib.conf

Remove the shared library settings for DEC OSF (last release in 1992),
SINIX (1995), AIX 4 (1999), BSD/OS (2003), and IRIX (2006).

9 months agoUpdate upload action versions in CI scripts 1377/head
Greg Hudson [Tue, 8 Oct 2024 02:22:40 +0000 (22:22 -0400)] 
Update upload action versions in CI scripts

Increment the versions of the upload actions in doc.yml and cifuzz.yml
as documented in:

https://github.blog/news-insights/product-news/get-started-with-v4-of-github-actions-artifacts/
https://github.blog/changelog/2024-01-12-code-scanning-deprecation-of-codeql-action-v2/

Also fix the conditional in cifuzz.yml to react to changes in itself,
not in build.yml.

9 months agoAvoid mutex locking in krb5int_trace() 1375/head
Alexey Tikhonov [Fri, 4 Oct 2024 16:00:21 +0000 (18:00 +0200)] 
Avoid mutex locking in krb5int_trace()

Trace logging doesn't need unique timestamps, so the locking within
krb5_crypto_us_timeofday() makes trace logging slower for no reason.
Add a new helper k5_us_timeofday(), which is merely a wrapper around
the existing get_time_now(), and use it in krb5int_trace().

[ghudson@mit.edu: edited commit message]

9 months agoFix krb5_crypto_us_timeofday() microseconds check 1374/head
Alexey Tikhonov [Thu, 3 Oct 2024 16:40:04 +0000 (18:40 +0200)] 
Fix krb5_crypto_us_timeofday() microseconds check

Commit a60db180211a383bd382afe729e9309acb8dcf53 mistakenly reversed
the sense of the krb5_crypto_us_timeofday() conditional that enforces
fowards movement of the microseconds value within a second.  Moreover,
the macros ts_after() and ts_incr() should not have been applied to
non-timestamp values.  Revert the incorrect changes.

[ghudson@mit.edu: rewrote commit message]

ticket: 9141 (new)
tags: pullup
target_version: 1.21-next

10 months agoFix various issues detected by static analysis 1371/head
Julien Rische [Fri, 6 Sep 2024 15:18:11 +0000 (17:18 +0200)] 
Fix various issues detected by static analysis

In klists's show_credential(), ensure that the column counter doesn't
decrease if printf() fails.

In process_k5beta7_princ(), bounds-check the e_length field.

In ndr_enc_delegation_info(), initialize b so it is always valid for
the cleanup handler.

In krb5_dbe_def_decrypt_key_data(), change the flow control so ret is
always set by the end of the function.  Return KRB5_KDB_INVALIDKEYSIZE
if there isn't enough data in the first key_data_contents field or if
the serialized key length is invalid.

In svcauth_gss_validate(), expand rpchdr to accomodate the header plus
MAX_AUTH_BYTES.

In svcudp_reply(), change slen to unsigned to match the return type of
XDR_GETPOS() and eliminate an unnecessary check for slen >= 0.

In krb5int_pthread_loaded()(), remove pthread_equal() from the weak
symbol checks.  It is implemented as an inline function in some glibc
versions, which makes the comparison "&pthread_equal == 0" always
false.

[ghudson@mit.edu: further modified krb5_dbe_def_decrypt_key_data() for
clarity; added detail to commit message]

10 months agoBlock library unloading to avoid finalizer races 1368/head
Greg Hudson [Thu, 29 Aug 2024 19:25:54 +0000 (15:25 -0400)] 
Block library unloading to avoid finalizer races

Library finalizers can run due to the library being unloaded or the
process exiting.  If the library is being unloaded, global memory
resources must be released to avoid memory leaks.  But if the process
is exiting, releasing memory resources can lead to race conditions if
another thread invokes functions from the library during or after
finalizer execution.  Most commonly this manifests as an assertion
error about trying to lock a destroyed mutex.

We can block unloading of our library on ELF platforms by passing "-z
nodelete" to the linker.  Add a shell variable "lib_unload_prevented"
to the shlib.conf outputs, set it on platforms where we can block
unloading, and suppress finalizers when it is set.

On Windows we can detect if the process is exiting by checking for a
non-null lpvReserved argument in DllMain().  Do not execute finalizers
when the process is executing.

ticket: 9139 (new)

11 months agomake regen
Greg Hudson [Tue, 20 Aug 2024 20:45:56 +0000 (16:45 -0400)] 
make regen

11 months agoUpdate config.guess, config.sub
Greg Hudson [Tue, 20 Aug 2024 20:44:44 +0000 (16:44 -0400)] 
Update config.guess, config.sub

11 months agoUpdate features list for 1.22
Greg Hudson [Tue, 20 Aug 2024 20:43:07 +0000 (16:43 -0400)] 
Update features list for 1.22

11 months agoReplace Windows installer FilesInUse dialog text 1367/head
Greg Hudson [Thu, 15 Aug 2024 15:30:07 +0000 (11:30 -0400)] 
Replace Windows installer FilesInUse dialog text

Windows installers must provide a FilesInUse dialog, with the intent
of minimizing the need to restart the system after software
installations.  For reasons related to the LSA cache, the KfW
installer always schedules a post-installation reboot (see commit
50a3c3cbeab32577fba2b21deb72a64015c48ec7).  Reword the FilesInUse
dialog text to recommend clicking Ignore, causing the conflicting
files to replaced on the reboot.  (The affected files are likely C
runtime DLLs, and the existing versions will almost certainly suffice
if KfW programs are run prior to a reboot.)

ticket: 9135 (new)

11 months agoDocument dns_lookup_realm relation 1365/head
Greg Hudson [Mon, 5 Aug 2024 21:37:06 +0000 (17:37 -0400)] 
Document dns_lookup_realm relation

ticket: 9134
tags: pullup
target_version: 1.21-next

11 months agoRefactor GSS per-message token parsing 1362/head
Greg Hudson [Mon, 24 Jun 2024 19:46:50 +0000 (15:46 -0400)] 
Refactor GSS per-message token parsing

Replace kg_unseal_v1() and gss_krb5int_unseal_token_v3() with new
functions using current coding practices.  Notable differences
include:

* The new functions use k5input for improved safety.
* The new functions do not modify the input buffer.
* The new functions will never try to allocate zero bytes of memory.
* There are separate functions for unwrap and verify_mic, which means
  there is no message_buffer parameter acting conditionally as an
  input or output.

11 months agoUpdate k5_sendto() comment 1363/head
Greg Hudson [Thu, 1 Aug 2024 06:41:15 +0000 (02:41 -0400)] 
Update k5_sendto() comment

Edit the block comment above k5_sendto() to take into account commits
802318cda963456b3ed7856c836e89da891483be (which added request_timeout)
and 6436a3808061da787a43c6810f5f0370cdfb6e36 (which made the open TCP
connection wait indefinite).

12 months agoRestore test coverage for old session key types 1361/head
Greg Hudson [Mon, 29 Jul 2024 16:34:10 +0000 (12:34 -0400)] 
Restore test coverage for old session key types

Commit 1b57a4d134bbd0e7c52d5885a92eccc815726463 made the KDC stop
issuing des3 and rc4 session keys by default.  To make the des3 and
arcfour passes of the test suite work, it added aes256-sha1 to the
permitted enctypes for those passes.  Negotiating AES session keys
reduces coverage of pre-CFX GSSAPI code and other uses of the older
enctypes.  Instead set the enable_des3 and enable_rc4 variables.

12 months agoRefactor GSS token header parsing 1353/head
Greg Hudson [Wed, 19 Jun 2024 22:55:35 +0000 (18:55 -0400)] 
Refactor GSS token header parsing

Rewrite g_verify_token_header() to use k5input and not to handle
two-byte token IDs (which are specific to the krb5 mechanism).  Add a
more general g_get_token_header() which can handle detached wrappers
and cases where the mech is not known in advance.  Adjust all current
callers, and get rid of the duplicate DER parsing code added in commit
b0a2f8a5365f2eec3e27d78907de9f9d2c80505a.

In k5-input.h, split out tag and length parsing into
k5_der_get_taglen(), needed by g_get_token_header().

12 months agoAdd fortify flag to gcc CI build 1360/head
Greg Hudson [Fri, 19 Jul 2024 22:07:46 +0000 (18:07 -0400)] 
Add fortify flag to gcc CI build

12 months agoRemove unused files 1358/head
Greg Hudson [Thu, 11 Jul 2024 19:15:46 +0000 (15:15 -0400)] 
Remove unused files

12 months agoAdd acceptor-side IAKERB realm discovery 1357/head
Greg Hudson [Tue, 9 Jul 2024 19:14:03 +0000 (15:14 -0400)] 
Add acceptor-side IAKERB realm discovery

draft-ietf-kitten-iakerb-03 section 3.1 specifies a way for the
initiator to query the acceptor's realm.  Implement this facility in
the IAKERB acceptor.

ticket: 9133 (new)

12 months agoMake krb5_get_default_config_files() public 1356/head
Greg Hudson [Mon, 8 Jul 2024 23:19:40 +0000 (19:19 -0400)] 
Make krb5_get_default_config_files() public

Add krb5_get_default_config_files() to the public API; it was already
in the library export list and the DLL export list.  Also add
krb5_free_config_files().

ticket: 9130

12 months agoRemove unused GSS code 1355/head
Greg Hudson [Tue, 2 Jul 2024 02:58:45 +0000 (22:58 -0400)] 
Remove unused GSS code

Commit b0031448502561da31fb8c2543c8b01d7df9a872 removed the only
consumers of util_set.c.  Also remove declarations for g_strdup() and
g_local_host_name(), which were unused as far back as krb5-1.0.

13 months agoChange krb5_get_credentials() endtime behavior 1354/head
Greg Hudson [Thu, 27 Jun 2024 11:25:21 +0000 (07:25 -0400)] 
Change krb5_get_credentials() endtime behavior

Historically, krb5_get_credentials() uses in_creds->times.endtime both
as the TGS request endtime and as a cache lookup criterion.  These
uses are in conflict; setting a TGS request endtime can only serve to
limit the maximum lifetime of the issued ticket, while a cache lookup
endtime restricts the minimum lifetime of an acceptable cached ticket.
The likely outcome is to never use a cached ticket, leading to poor
performance as we add an entry to the cache for each request.

Change to the Heimdal behavior of using in_creds->times.endtime only
as the TGS request endtime.

ticket: 9132 (new)

13 months agoAdjust removed cred detection in FILE ccache 1352/head
Greg Hudson [Mon, 24 Jun 2024 00:10:44 +0000 (20:10 -0400)] 
Adjust removed cred detection in FILE ccache

In the FILE ccache, consider a cred to be removed if it has endtime 0
and authtime non-zero, instead of specifically authtime -1.  This
change will let us filter out normal credentials deleted by Heimdal,
although not synthetic credentials such as config entries.

ticket: 9131 (new)

13 months agoFix vulnerabilities in GSS message token handling
Greg Hudson [Fri, 14 Jun 2024 14:56:12 +0000 (10:56 -0400)] 
Fix vulnerabilities in GSS message token handling

In gss_krb5int_unseal_token_v3() and gss_krb5int_unseal_v3_iov(),
verify the Extra Count field of CFX wrap tokens against the encrypted
header.  Reported by Jacob Champion.

In gss_krb5int_unseal_token_v3(), check for a decrypted plaintext
length too short to contain the encrypted header and extra count
bytes.  Reported by Jacob Champion.

In kg_unseal_iov_token(), separately track the header IOV length and
complete token length when parsing the token's ASN.1 wrapper.  This
fix contains modified versions of functions from k5-der.h and
util_token.c; this duplication will be cleaned up in a future commit.

CVE-2024-37370:

In MIT krb5 release 1.3 and later, an attacker can modify the
plaintext Extra Count field of a confidential GSS krb5 wrap token,
causing the unwrapped token to appear truncated to the application.

CVE-2024-37371:

In MIT krb5 release 1.3 and later, an attacker can cause invalid
memory reads by sending message tokens with invalid length fields.

ticket: 9128 (new)
tags: pullup
target_version: 1.21-next

13 months agoUpdate copyright years to 2024
Greg Hudson [Mon, 24 Jun 2024 23:28:54 +0000 (19:28 -0400)] 
Update copyright years to 2024

13 months agoCorrect IAKERB protocol implementation 1345/head
Greg Hudson [Tue, 16 Apr 2013 17:32:04 +0000 (13:32 -0400)] 
Correct IAKERB protocol implementation

The initial implementation of IAKERB in MIT krb5 mistakenly used
draft-zhu-ws-kerb instead of draft-kitten-ietf-iakerb, and
additionally used the wrong ASN.1 tag value for the target-realm field
of the IAKERB-HEADER sequence.  Correct the following aspects of the
protocol implementation:

* Require and use framing on all messages, not just the initial
  context token.
* Use extension value 2 for the finish message instead of 1.
* Use key usage value 41 instead of 42 for the finish message
  checksum.
* Use UTF8String (12) for target-realm instead of OCTET STRING (4).

With these changes, the IAKERB implementation is interoperable with
other krb5 implementations, but not with the implementation before
these changes.

ticket: 9123 (new)

13 months agoAdd cifuzz workflow for PR fuzzing 1350/head
Arjun [Tue, 4 Jun 2024 06:05:14 +0000 (11:35 +0530)] 
Add cifuzz workflow for PR fuzzing

14 months agoHandle empty initial buffer in IAKERB initiator 1342/head
Andreas Schneider [Wed, 8 May 2024 08:10:56 +0000 (10:10 +0200)] 
Handle empty initial buffer in IAKERB initiator

Section 5.19 of RFC 2744 (about gss_init_sec_context) states,
"Initially, the input_token parameter should be specified either as
GSS_C_NO_BUFFER, or as a pointer to a gss_buffer_desc object whose
length field contains the value zero."  In iakerb_initiator_step(),
handle both cases when deciding whether to parse an acceptor message.

[ghudson@mit.edu: edited commit message]

ticket: 9126 (new)

14 months agoFix formatting error in realm_config.rst 1349/head
Jon Moore [Sat, 25 May 2024 21:15:08 +0000 (17:15 -0400)] 
Fix formatting error in realm_config.rst

Commit 10eb93809b1af06e2b1147aee2e3e50058ba1bbd introduced a
formatting error in the SRV record descriptions.  Fix it now.

[ghudson@mit.edu: wrote commit message]

ticket: 9125
tags: pullup
target_version: 1.21-next

14 months agoFix recently-introduced profile parsing bugs 1348/head
Greg Hudson [Tue, 21 May 2024 23:10:50 +0000 (19:10 -0400)] 
Fix recently-introduced profile parsing bugs

When parsing a "}", do not ascend to the parent node if we are still
within a discarded section after decrementing group_level, as we did
not descend into a child node at the beginning of the subsection.
(Discovered by OSS-Fuzz.)

Also adjust the level check to take into account the shifted meaning
of state->group_level, so that we properly reject a "}" within a
top-level section.

Both bugs were introduced in commit
f951625e6bd3ff44f1056958b56e35a1a043e362.

14 months agoAdd OSS-Fuzz targets and corpora 1346/head
Arjun [Thu, 9 May 2024 15:43:03 +0000 (21:13 +0530)] 
Add OSS-Fuzz targets and corpora

[ghudson@mit.edu: style adjustments]

bigredbutton: whitespace

14 months agoFix Python regexp literals 1344/head
Arjun [Thu, 9 May 2024 15:17:08 +0000 (20:47 +0530)] 
Fix Python regexp literals

Add missing "r" prefixes before literals using regexp escape
sequences.

[ghudson@mit.edu: split into separate commit; rewrote commit message]

14 months agoFix more non-prototype functions
Arjun [Thu, 9 May 2024 15:17:08 +0000 (20:47 +0530)] 
Fix more non-prototype functions

Add "void" designations to more function declarations and definitions
not changed by commits 3ae9244cd021a75eba909d872a92c25db490714d and
4b9d7f7c107f01a61600fddcd8cde3812d0366a2.

[ghudson@mit.edu: change additional functions; split into two commits;
rewrote commit message]

14 months agoSupport site-local KDC discovery via DNS 1183/head
Nicolas Williams [Thu, 13 May 2021 05:43:26 +0000 (00:43 -0500)] 
Support site-local KDC discovery via DNS

Add the sitename realm variable.  If set, service location via DNS
will be attempted using the site name as specified in [MS-ADTS]
6.3.2.3, falling back to regular discovery on failure.

[ghudson@mit.edu: made this strictly a realm variable; moved
k5_get_sitename() to locate_kdc.c and made it take a krb5_data input;
fixed a memory leak; corrected documentation changes; fleshed out
commit message]

ticket: 9124 (new)

14 months agoAdd GSS flag to include KERB_AP_OPTIONS_CBT 1329/head
Stefan Metzmacher [Fri, 1 Mar 2024 13:23:47 +0000 (14:23 +0100)] 
Add GSS flag to include KERB_AP_OPTIONS_CBT

The Microsoft KERB_AP_OPTIONS_CBT extension (defined in [MS-KILE]
3.2.5.8) allows the client to request strict enforcement of GSS
channel bindings.  Client support for this extension was added in
commit 225e6ef7f021cd1a8ef2a054af0ca58b7288fd81 (ticket 8900) but it
requires a configuration variable to be set.  The choice to include
the extension should be made by the client application code, as it is
a promise to include channel bindings when operating within TLS.

In libkrb5, add an option AP_OPTS_CBT_FLAG to make
krb5_mk_req[_extended]() include KERB_AP_OPTIONS_CBT.  In the GSS
initiator code, set this flag when the GSS_C_CHANNEL_BOUND flag is
included in the request options.  GSS_C_CHANNEL_BOUND was introduced
in commit 429a31146083fac21958631c2af572b08ec91022 (ticket 8899) as an
acceptor output flag.

[ghudson@mit.edu: rewrote commit message; adjusted some names;
simplified GSS initiator bookkeeping; added documentation]

ticket: 9122 (new)

15 months agoDon't flush libkrb5 context profiles 1340/head 1341/head
Greg Hudson [Wed, 3 Apr 2024 18:20:53 +0000 (14:20 -0400)] 
Don't flush libkrb5 context profiles

The profile library has two deconstructors, profile_release() and
profile_abandon().  profile_release() flushes in-memory changes to
backing files, while profile_abandon() does not.  If a krb5_context
profile contains in-memory changes, they were copied from a profile
supplied to krb5_init_context_profile(), and the caller can decide
whether to flush them.

As profile_copy() is now a public function, remove the include of
prof_int.h and the associated LOCALINCLUDES setting in Makefile.in.

ticket: 9121 (new)

15 months agoMake profile_copy() work on dirty profiles 1339/head
Greg Hudson [Wed, 3 Apr 2024 18:13:50 +0000 (14:13 -0400)] 
Make profile_copy() work on dirty profiles

Replace the current implementation of profile_copy() with one that
copies the in-memory tree structure of non-shared data objects.  Make
profile_copy() a public function.

ticket: 9119 (new)

15 months agoDo not reload a modified profile data object 1337/head
Greg Hudson [Tue, 16 Apr 2024 06:14:29 +0000 (02:14 -0400)] 
Do not reload a modified profile data object

The profile library normally attempts to reload a profile data tree if
the backing file has changed.  Reloading a dirty profile object
discards any modifications made by the caller.  If we assume that the
modifications are destined to be flushed back out to the backing file,
then there is no good answer--one or the other set of changes will be
lost.  But the caller may have a different intended use for the
modified tree (profile_flush_to_file(), profile_flush_to_buffer(),
krb5_init_context_profile()), for which the caller's modifications may
be critical.  Avoid discarding in-memory edits to ensure the
correctness of these use cases.

ticket: 9118

15 months agoImprove profile final flag support 1336/head
Greg Hudson [Mon, 15 Apr 2024 22:47:27 +0000 (18:47 -0400)] 
Improve profile final flag support

When parsing a file, ignore sections appearing after a final-flagged
section of the same name.  Adjust the meaning of group_level in the
parser state so that it is 1 inside of top-level sections instead of
0, and simplify the addition of top-level sections to the tree by
relying on profile_add_node()'s section merging.

Make the final flag work for relations as well as sections.  Check it
while parsing via a new check_final parameter in profile_add_node(),
and during iteration.

Output final flags for relations in dump_profile().  Make the final
flag available to it via a new output parameter in
profile_find_node_relation().

ticket: 9120

15 months agoAllow modifications of empty profiles 1334/head
Greg Hudson [Sun, 31 Mar 2024 16:30:18 +0000 (12:30 -0400)] 
Allow modifications of empty profiles

Add the notion of a memory-only prf_data_t object, indicated by an
empty filespec field and appropriate flags (do not reload, always
dirty, not part of shared trees).  Do nothing when flushing a
memory-only data object to its backing file.  When setting up an empty
profile for read/write access, create a memory-only data object
instead of crashing.

Move prf_data_t mutex initialization into profile_make_prf_data(),
simplifying its callers.

ticket: 9110

16 months agoFix OpenSSL 1.0 and 1.1 support in PKINIT 1333/head
Greg Hudson [Thu, 21 Mar 2024 23:04:13 +0000 (19:04 -0400)] 
Fix OpenSSL 1.0 and 1.1 support in PKINIT

Commit f745c9a9bd6c0c73b944182173f1ac305d03dc3a uses ECDSA_SIG_set0(),
which was added in OpenSSL 1.1.  Add a compatibility version for
OpenSSL 1.0.

Commit bdcd6075bd4593c8f67722ce075c9519faec58b7 uses
EVP_PKEY_get_base_id(), which was added in OpenSSL 3.0.  Add a
compatibility macro to use the old name for OpenSSL 1.0 and 1.1.

Commit 0f870b1bcad960fd5319a3f97aafd7f4a289e2fb added ECDH support,
but did not change the OpenSSL 1.0 versions of encode_spki(),
decode_spki(), or generate_dh_pkey() to work with elliptic curve
public keys.  In each function, check the key type and skip the
DH-specific handling for key types other than DH.

16 months agoImprove error message for DES kadmin/history key 1332/head
Greg Hudson [Wed, 20 Mar 2024 21:17:50 +0000 (17:17 -0400)] 
Improve error message for DES kadmin/history key

If the kadmin/history entry contains an unsupported encryption type,
produce a better error message than "Bad encryption type".  Reuse the
error code KADM5_BAD_HIST_KEY (unused since release 1.8).  Non-updated
kadmin clients will report the message "Password history principal key
version mismatch", which at least points in the direction of password
history.

ticket: 9116 (new)

16 months agoFix type mismatches detected by LTO 1331/head
Greg Hudson [Tue, 12 Mar 2024 16:45:24 +0000 (12:45 -0400)] 
Fix type mismatches detected by LTO

Building with link-time optimization reveals some type mismatches in
the interface between libkrb5 serialization and the profile library,
as well as in consumers of the SS library.  Fix them.  Reported by Eli
Schwartz.

ticket: 9114

16 months agoFix two unlikely memory leaks 1330/head
Greg Hudson [Wed, 6 Mar 2024 00:53:07 +0000 (19:53 -0500)] 
Fix two unlikely memory leaks

In gss_krb5int_make_seal_token_v3(), one of the bounds checks (which
could probably never be triggered) leaks plain.data.  Fix this leak
and use current practices for cleanup throughout the function.

In xmt_rmtcallres() (unused within the tree and likely elsewhere),
store port_ptr into crp->port_ptr as soon as it is allocated;
otherwise it could leak if the subsequent xdr_u_int32() operation
fails.

16 months agoFix leak in KDC NDR encoding
Greg Hudson [Tue, 5 Mar 2024 22:38:49 +0000 (17:38 -0500)] 
Fix leak in KDC NDR encoding

If the KDC tries to encode a principal containing encode invalid UTF-8
sequences for inclusion in a PAC delegation info buffer, it will leak
a small amount of memory in enc_wchar_pointer() before failing.  Fix
the leak.

ticket: 9115 (new)
tags: pullup
target_version: 1.21-next

16 months agoImprove PKCS11 error reporting in PKINIT 1328/head
Greg Hudson [Fri, 23 Feb 2024 18:51:26 +0000 (13:51 -0500)] 
Improve PKCS11 error reporting in PKINIT

Create a helper p11err() to set extended error message for failed
PKCS11 operations, and use it instead of pkiDebug() and pkcs11error().

ticket: 9113 (new)

16 months agoSupport PKCS11 EC client certs in PKINIT
Greg Hudson [Wed, 21 Feb 2024 20:29:02 +0000 (15:29 -0500)] 
Support PKCS11 EC client certs in PKINIT

Move the digest computation and DigestInfo encoding from
cms_signeddata_create() to pkinit_sign_data_pkcs11(), and
conditionalize the DigestInfo encoding on the key type.  Use CKM_ECDSA
instead of CKM_RSA_PKCS for EC keys, and convert the resulting
signature from the PKS11 encoding to the ASN.1 encoding required by
CMS.

Regenerate the test certificates with an additional EC client cert.
Add test cases for EC client certs with and without PKCS11.

ticket: 9112 (new)

16 months agoCorrect PKINIT EC cert signature metadata
Greg Hudson [Fri, 9 Feb 2024 22:57:40 +0000 (17:57 -0500)] 
Correct PKINIT EC cert signature metadata

When generating CMS SignedData in PKINIT, check the certificate's
public key type and set the signatureAlgorithm field appropriately.
(This field is currently ignored by OpenSSL when verifying CMS
SignedData.)

ticket: 9111 (new)

16 months agoSimplify PKINIT cert representation
Greg Hudson [Fri, 9 Feb 2024 22:32:40 +0000 (17:32 -0500)] 
Simplify PKINIT cert representation

In the _pkinit_identity_crypto_context structure, the my_certs field
is a stack which only ever contains one cert and is only ever used to
retrieve that one cert.  The cert_index field is always 0.  Replace
these fields with a my_cert field pointing directly to the X509
certificate.

Simplify crypto_cert_select_default() by making it call
crypto_cert_select() with index 0 after verifying the certificate
count.

16 months agoRemove softpkcs11
Greg Hudson [Sat, 2 Mar 2024 00:10:49 +0000 (19:10 -0500)] 
Remove softpkcs11

softpkcs11 is no longer required for the test suite after the previous
commit, so remove it.

16 months agoUse SoftHSMv2 for PKCS11 PKINIT tests
Greg Hudson [Tue, 27 Feb 2024 00:03:38 +0000 (19:03 -0500)] 
Use SoftHSMv2 for PKCS11 PKINIT tests

Instead of softpkcs11, use SoftHSMv2 to mock the PKCS11 token for
PKINIT tests.  Use pkcs11-tool from OpenSC to initialize the token and
import a certificate and key.  SoftHSM does not support PIN-less
tokens (see https://github.com/opendnssec/SoftHSMv2/issues/480) so
remove that test for now.

17 months agoInstall yasm in CI to exercise AES-NI code
Greg Hudson [Mon, 12 Feb 2024 16:38:22 +0000 (11:38 -0500)] 
Install yasm in CI to exercise AES-NI code

17 months agoAvoid strict-prototype compiler errors 1327/head
Steffen Kieß [Tue, 13 Feb 2024 17:39:27 +0000 (18:39 +0100)] 
Avoid strict-prototype compiler errors

Commit 4b9d7f7c107f01a61600fddcd8cde3812d0366a2 added the
-Werror=strict-prototypes parameter to the build process, but left
behind 28 function definitions using "()" instead of "(void)".  Most
of these definitions could not cause compiler errors for various
reasons (such as an accompanying prototype), but a few could cause
errors in gcc depending on the build configuration.

For consistency and safety, add "(void)" to all 28 definitions.

[ghudson@mit.edu: rewrote commit message]

18 months agoFix NOTICE generation and regenerate it 1326/head
Greg Hudson [Wed, 24 Jan 2024 22:33:18 +0000 (17:33 -0500)] 
Fix NOTICE generation and regenerate it

In conf.py, exclude the formats directory (added in commit
68ac7ac1f1a1d2939a2c99fa49cecd734614d16d) when building notice.txt, to
prevent a "document isn't included in any toctree" warning.

18 months agoRemove klist's defname global variable 1324/head
Julien Rische [Mon, 8 Jan 2024 15:52:27 +0000 (16:52 +0100)] 
Remove klist's defname global variable

Addition of a "cleanup" section in kinit's show_ccache() function as
part of commit 6c5471176f5266564fbc8a7e02f03b4b042202f8 introduced a
double-free bug, because defname is a global variable.  After the
first call, successive calls may take place with a dangling pointer in
defname, which will be freed if krb5_cc_get_principal() fails.

Convert "defname" to a local variable initialized at the beginning of
show_ccache().

[ghudson@mit.edu: edited commit message]

18 months agoFix memory leak in macOS 11 ccache client
Anthony Sottile [Sat, 13 Jan 2024 00:10:03 +0000 (19:10 -0500)] 
Fix memory leak in macOS 11 ccache client

In get_primary_name(), use the proper function to free conn.

[ghudson@mit.edu: wrote commit message]

ticket: 9109
tags: pullup
target_version: 1.21-next

19 months agoRefactor PKINIT KDF internal interfaces 1322/head
Greg Hudson [Sat, 2 Dec 2023 00:40:02 +0000 (19:40 -0500)] 
Refactor PKINIT KDF internal interfaces

Simplify the client and server PKINIT code by renaming
pkinit_alg_agility_kdf() to pkinit_kdf() and making it do RFC 4556
octet2string if alg_oid is null.  Move responsibility for tracing
inside the new interface.  Constify some parameters and remove some
unnecessary casts.  Rename "key" to "secret" in several internal
functions to avoid confusion between the input DH secret and the
output key.

20 months agoRemove PKINIT RSA support 1321/head
Greg Hudson [Sun, 26 Nov 2023 22:42:34 +0000 (17:42 -0500)] 
Remove PKINIT RSA support

RSA mode is no longer needed for interoperability.  Reduce the attack
surface of clients and KDCs by removing support for it.

ticket: 9108 (new)

20 months agoIn PKINIT, check for null PKCS7 enveloped fields 1320/head
Greg Hudson [Sat, 25 Nov 2023 16:04:56 +0000 (11:04 -0500)] 
In PKINIT, check for null PKCS7 enveloped fields

The PKCS7 ContentInfo content field and EncryptedContentInfo
encryptedContent field are optional.  Check for null values in
cms_envelopeddata_verify() before calling pkcs7_decrypt().  Reported
by Bahaa Naamneh.

ticket: 9107 (new)
tags: pullup
target_version: 1.21-next
target_version: 1.20-next

21 months agoMake def-check.pl work with Windows git-bash perl 1319/head
unknown [Tue, 24 Oct 2023 01:29:14 +0000 (18:29 -0700)] 
Make def-check.pl work with Windows git-bash perl

The version of Perl included in git-bash does not translate line
endings or filter out the end-of-file marker when reading from files
in text mode.  Adjust def-check.pl to work in this environment.

21 months agoWait indefinitely on KDC TCP connections 1318/head
Greg Hudson [Thu, 26 Oct 2023 20:26:42 +0000 (16:26 -0400)] 
Wait indefinitely on KDC TCP connections

When making a KDC or password change request, wait indefinitely
(limited only by request_timeout if set) once a KDC has accepted a TCP
connection.

ticket: 9105 (new)

21 months agoAdd request_timeout configuration parameter
Greg Hudson [Thu, 26 Oct 2023 18:20:34 +0000 (14:20 -0400)] 
Add request_timeout configuration parameter

Add a parameter to limit the total amount of time taken for a KDC or
password change request.

ticket: 9106 (new)

21 months agoEnd connection on KDC_ERR_SVC_UNAVAILABLE
Greg Hudson [Fri, 27 Oct 2023 04:44:53 +0000 (00:44 -0400)] 
End connection on KDC_ERR_SVC_UNAVAILABLE

In sendto_kdc.c:service_fds(), if a message handler indicates that a
message should be discarded, kill the connection so we don't continue
waiting on it for more data.

ticket: 7899

21 months agoFix unimportant memory leaks 1306/head
Steve Grubb [Thu, 13 Jul 2023 20:22:30 +0000 (16:22 -0400)] 
Fix unimportant memory leaks

Eliminate memory leaks detected through static analysis and manual
review.  These leaks are unlikely to happen repeatedly in long-running
processes.

[jrische@redhat.com: fixed many additional leaks]
[ghudson@mit.edu: fixed additional leaks; edited for style; removed
some unused ksu functions; rewrote commit message]

22 months agoProperly mirror child exit status in ksu 1309/head
Greg Hudson [Fri, 28 Jul 2023 22:07:34 +0000 (18:07 -0400)] 
Properly mirror child exit status in ksu

ksu attempts to exit with the same status as its child process, but
does not do so correctly.  Use WEXITSTATUS() to extract the exit code.
Reported by Todd Lubin.

ticket: 8618

22 months agoAdd ksu test script 1315/head
Greg Hudson [Tue, 29 Aug 2023 20:40:58 +0000 (16:40 -0400)] 
Add ksu test script

Add a test script for ksu, which must be run under sudo and makes
potentially disruptive temporary changes to the host environment.  Do
not run it as part of "make check", but do run it as part of the
Github Actions CI.

22 months agoWork around Doxygen 1.9.7 change 1316/head
Greg Hudson [Wed, 13 Sep 2023 21:57:01 +0000 (17:57 -0400)] 
Work around Doxygen 1.9.7 change

Doxygen 1.9.7 avoids duplicating member definitions in the XML
documents for groups and header files (doxygen/doxygen#9797).  This
change breaks the current Doxygen-REST bridge, which expects to find
memberdef elements in krb5_8hin.xml.  To work around this problem,
remove the @group and @ref declarations in krb5.hin; they were not
translated into REST as it was.

Also remove a deprecated setting in Doxyfile.

ticket: 9104 (new)
tags: pullup
target_version: 1.21-next
target_version: 1.20-next

23 months agoFix krb5_cccol_have_content() bad pointer free
Ilya Gladyshev [Wed, 30 Aug 2023 20:19:59 +0000 (21:19 +0100)] 
Fix krb5_cccol_have_content() bad pointer free

krb5_cccol_have_content() calls krb5_cc_get_principal() within a loop,
and frees the resulting principal on success or failure.  Set princ to
null before each call to ensure we don't free a dangling pointer.

[ghudson@mit.edu: rewrote commit message; moved assignment for greater
clarity]

ticket: 9103
tags: pullup
target_version: 1.21-next
target_version: 1.20-next

23 months agoAdd missing dependencies 1311/head
Greg Hudson [Sun, 30 Jul 2023 18:30:58 +0000 (14:30 -0400)] 
Add missing dependencies

23 months agoGet rid of pkinit_crypto_openssl.h 1310/head
Greg Hudson [Sun, 30 Jul 2023 05:07:38 +0000 (01:07 -0400)] 
Get rid of pkinit_crypto_openssl.h

Fold pkinit_crypto_openssl.h into the one source file where it was
used.  Also clean up the include of <arpa/inet.h>, as htonl() is no
longer used after commit 1c87ce6c44a9de0824580a2d72a8a202237e01f4.

23 months agoEliminate sim_client include of getopt.h 1314/head
Michael Osipov [Tue, 22 Aug 2023 08:05:24 +0000 (10:05 +0200)] 
Eliminate sim_client include of getopt.h

Commit 9139a60c94c24e41109574e84e7cda9c2dc3fb38 added an unconditional
include of getopt.h, which is non-portable (it isn't present on HP-UX)
and unecessary for getopt().  The same commit also disabled the
include of unistd.h (which is necessary for getopt()), as sim_client
no longer indirectly includes autoconf.  Make the unistd.h include
unconditional and remove the getopt.h include.

[ghudson@mit.edu: edited commit message]

ticket: 9102 (new)
tags: pullup
target_version: 1.21-next

23 months agoProperly quote command strings in k5test.py 1308/head
Greg Hudson [Fri, 28 Jul 2023 03:54:16 +0000 (23:54 -0400)] 
Properly quote command strings in k5test.py

Requiring Python 3.4 gives us shlex.quote() (added in Python 3.3).
Use it in _shell_equiv() to quote command arguments.

23 months agoFix double-free in KDC TGS processing 1312/head
Andreas Schneider [Fri, 4 Aug 2023 07:54:06 +0000 (09:54 +0200)] 
Fix double-free in KDC TGS processing

When issuing a ticket for a TGS renew or validate request, copy only
the server field from the outer part of the header ticket to the new
ticket.  Copying the whole structure causes the enc_part pointer to be
aliased to the header ticket until krb5_encrypt_tkt_part() is called,
resulting in a double-free if handle_authdata() fails.

[ghudson@mit.edu: changed the fix to avoid aliasing enc_part rather
than check for aliasing before freeing; rewrote commit message]

CVE-2023-39975:

In MIT krb5 release 1.21, an authenticated attacker can cause a KDC to
free the same pointer twice if it can induce a failure in
authorization data handling.

ticket: 9101 (new)
tags: pullup
target_version: 1.21-next

2 years agoReplace ssl.wrap_socket() for tests 1307/head
Julien Rische [Wed, 19 Jul 2023 11:43:17 +0000 (13:43 +0200)] 
Replace ssl.wrap_socket() for tests

The ssl.wrap_socket() function was deprecated in Python 3.7 and is
removed in Python 3.12.  The ssl.SSLContext.wrap_socket() method
replaces it.

Bump the required Python version for tests to 3.4 for
ssl.create_default_context().

[ghudson@mit.edu: changed minimum Python version]

2 years agoAdd ecdsa-with-sha512/256 to supportedCMSTypes 1305/head
Julien Rische [Wed, 21 Jun 2023 16:27:11 +0000 (18:27 +0200)] 
Add ecdsa-with-sha512/256 to supportedCMSTypes

Elliptic curve certificates are already supported for PKINIT
pre-authentication, but their associated signature types aren't
advertized.  Add ecdsa-with-sha512 and ecdsa-with-sha256 OIDs to the
supportedCMSTypes list sent by the client.

[ghudson@mit.edu: edited commit message]

ticket: 9100 (new)