]> git.ipfire.org Git - thirdparty/krb5.git/log
thirdparty/krb5.git
2 years agoAvoid using internal APIs in sim_client 1292/head
Greg Hudson [Fri, 24 Feb 2023 19:15:14 +0000 (14:15 -0500)] 
Avoid using internal APIs in sim_client

In sim_client.c, remove the calls to krb5_gen_portaddr() and
krb5_gen_replay_name() as they don't do anything after commit
dcb853ac32779b173f39e19c0f24b0087de85771.  Remove them, and include
krb5.h plus appropriate system headers rather than k5-int.h.

Also use a subkey when negotiating the auth context.  Kerberos
application protocols should generally use subkeys to prevent
cross-connection replay attacks.

2 years agoFix meridian type in getdate.y 1290/head
Julien Rische [Tue, 21 Feb 2023 09:03:35 +0000 (10:03 +0100)] 
Fix meridian type in getdate.y

Commit d3356bc42191c1896ab06835a2fb245e00471420 (ticket 8927)
incorrectly tagged tMERIDIAN as <Number>.  So while the lexer assigns
meridian values to the Meridian union field, the parser erroneously
reads them from the Number field.  On 64-bit IBM zSystems (s390x),
this can result in using the most recently read number as a meridian
value, leading to an abort in ToSeconds().

Fix the tMERIDIAN token type to be <Meridian>.

[ghudson@mit.edu: edited commit message]

ticket: 9087 (new)
tags: pullup
target_version: 1.20-next

2 years agoFix read overruns in SPNEGO parsing
Greg Hudson [Wed, 8 Feb 2023 17:23:28 +0000 (12:23 -0500)] 
Fix read overruns in SPNEGO parsing

Fix three read overruns discovered by the GitHub Security Lab team
(GHSL-2023-016, GHSL-2023-017, and GHSL-2023-018) using OSS-Fuzz.

In get_mech_set(), error out if gss_add_oid_set_member() fails rather
than continue the loop and increment i past the current bound of
returned_mechSet.  In g_verify_neg_token_init(), check for zero-byte
sequences before reading tag bytes, and reduce cur_size by one to
account for the tag byte when calling gssint_get_der_length().

ticket: 9085 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

2 years agoAdd margin to expired tickets in test suite 1287/head
Greg Hudson [Sat, 28 Jan 2023 01:13:12 +0000 (20:13 -0500)] 
Add margin to expired tickets in test suite

Very occasionally a test using expired tickets will fail because the
ticket isn't seen as expired.  Obtain tickets with a longer expiration
margin to avoid these failures.

2 years agoFix t_ndr to return a define value from main()
Greg Hudson [Sat, 28 Jan 2023 01:22:32 +0000 (20:22 -0500)] 
Fix t_ndr to return a define value from main()

2 years agoAdd PAC full checksums 1284/head
Greg Hudson [Thu, 22 Dec 2022 08:05:23 +0000 (03:05 -0500)] 
Add PAC full checksums

A paper by Tom Tervoort noted that computing the PAC privsvr checksum
over only the server checksum is vulnerable to collision attacks
(CVE-2022-37967).  In response, Microsoft has added a second KDC
checksum over the full contents of the PAC.  Generate and verify full
KDC checksums in PACs for service tickets.  Update the t_pac.c ticket
test case to use a ticket issued by a recent version of Active
Directory (provided by Stefan Metzmacher).

ticket: 9084 (new)

2 years agoDon't issue session keys with deprecated enctypes 1283/head
Greg Hudson [Fri, 16 Dec 2022 23:31:07 +0000 (18:31 -0500)] 
Don't issue session keys with deprecated enctypes

A paper by Tom Tervoort noted that rc4-hmac pre-hashes the input for
its checksum and GSS operations before applying HMAC, and is therefore
potentially vulnerable to hash collision attacks if a protocol
contains a restricted signing oracle.

In light of these potential attacks, begin the functional deprecation
of DES3 and RC4 by disallowing their use as session key enctypes by
default.  Add the variables allow_des3 and allow_rc4 in case
negotiability of these enctypes for session keys needs to be turned
back on, with the expectation that in future releases the enctypes
will be more comprehensively deprecated.

ticket: 9081

2 years agoIn KDC, assume all services support aes256-sha1
Greg Hudson [Wed, 14 Dec 2022 18:20:46 +0000 (13:20 -0500)] 
In KDC, assume all services support aes256-sha1

To facilitate negotiating session keys with acceptable security,
assume that services support aes256-cts-hmac-sha1 unless a
session_enctypes string attribute says otherwise.

ticket: 9075

2 years agoRemove man page includes from RST documentation 1286/head
Greg Hudson [Wed, 4 Jan 2023 16:10:53 +0000 (11:10 -0500)] 
Remove man page includes from RST documentation

Rewrite parts of database.rst and appl_servers.rst to avoid including
full option descriptions from the (already linked) man pages.

2 years agoFix PKINIT CMS error checking for older OpenSSL 1281/head
Greg Hudson [Tue, 13 Dec 2022 18:15:28 +0000 (13:15 -0500)] 
Fix PKINIT CMS error checking for older OpenSSL

Commit 70f61d417261ca17efe3d60d180033bea2da60b0 updated the
CMS_verify() error code checks, using two error codes new to OpenSSL
3.0 (RSA_R_DIGEST_NOT_ALLOWED and CMS_R_UNKNOWN_DIGEST_ALGORITHM).
This change broke the build for OpenSSL 1.0 and 1.1.

Instead of looking for codes indicating an algorithm issue and
assuming that everything else is an invalid signature, check for the
code indicating an invalid signature and assume that everything else
is an algorithm issue.

ticket: 9069

2 years agoFix policy DB fallback error handling 1280/head
Greg Hudson [Mon, 12 Dec 2022 19:36:47 +0000 (14:36 -0500)] 
Fix policy DB fallback error handling

In osa_adb_open_and_lock(), if the btree dbopen() call returns EINVAL
or EFTYPE and the fallback hash dbopen() call also returns an error,
release the lock and return an error instead of returning success with
a null database.

ticket: 9082 (new)

2 years agoFix kpropd crash with unrecognized option 1285/head
abushwang [Wed, 28 Dec 2022 07:06:02 +0000 (15:06 +0800)] 
Fix kpropd crash with unrecognized option

ticket: 9083 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

2 years agoRemove unused Unicode functions 1279/head
Greg Hudson [Sat, 10 Dec 2022 06:26:36 +0000 (01:26 -0500)] 
Remove unused Unicode functions

2 years agoSimplify krb5_chpw_message() UTF-8 processing
Greg Hudson [Sat, 10 Dec 2022 05:40:44 +0000 (00:40 -0500)] 
Simplify krb5_chpw_message() UTF-8 processing

Only validate the message as a UTF-8 string, rather than normalizing
it.

2 years agoRemove line continuations in et_c.awk 1276/head
gakamath [Mon, 28 Nov 2022 14:26:23 +0000 (19:56 +0530)] 
Remove line continuations in et_c.awk

Line continuations cause issues for the awk in MinGW, so just have
long lines instead.

[ghudson@mit.edu: rewrote commit message; factored out some string
constructions for readability]

2 years agoFix gic_keytab crash on memory exhaustion 1275/head
ChenChen Zhou [Sun, 27 Nov 2022 14:57:14 +0000 (22:57 +0800)] 
Fix gic_keytab crash on memory exhaustion

get_as_key_keytab() does not check the result of krb5_copy_keyblock(),
and dereferences a null pointer if it fails.  Remove the call and
steal the memory from kt_ent instead.

[ghudson@mit.edu: rewrote commit message; fixed comments]

ticket: 9080 (new)

2 years agoFix preauth crash on memory exhaustion 1274/head
ChenChen Zhou [Sun, 27 Nov 2022 14:24:24 +0000 (22:24 +0800)] 
Fix preauth crash on memory exhaustion

In k5_preauth_request_context_init(), check the result of calloc().

[ghudson@mit.edu: rewrote commit message; added free() of reqctx on error]

ticket: 9079 (new)

2 years agoFix profile crash on memory exhaustion 1273/head
ChenChen Zhou [Thu, 24 Nov 2022 13:59:21 +0000 (21:59 +0800)] 
Fix profile crash on memory exhaustion

In profile_get_values(), if init_list() fails to allocate values.list,
end_list() will dereference a null pointer.  Fix end_list() to handle
list->list being null.

[ghudson@mit.edu: rewrote commit message]

ticket: 9078 (new)

2 years agoFix aclocal.m4 syntax error for autoconf 2.72 1272/head
Julien Rische [Thu, 17 Nov 2022 14:01:24 +0000 (15:01 +0100)] 
Fix aclocal.m4 syntax error for autoconf 2.72

An incorrect closure inside KRB5_AC_INET6 is innocuous with autoconf
versions up to 2.71, but will cause an error at configure time with
the forthcoming autoconf 2.72.

[ghudson@mit.edu: added more context to commit message]

ticket: 9077 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

2 years agoAdd Georgian translation 1271/head
NorwayFun [Wed, 9 Nov 2022 07:24:37 +0000 (08:24 +0100)] 
Add Georgian translation

[ghudson@mit.edu: added the translation to po/Makefile.in]

2 years agoUse memmove() in Unicode functions
Greg Hudson [Tue, 18 Oct 2022 20:17:55 +0000 (16:17 -0400)] 
Use memmove() in Unicode functions

Where the upstream OpenLDAP code uses AC_MEMCPY(), use memmove()
instead of memcpy() as the copies frequently involve overlapping
memory regions.  Credit to OSS-Fuzz for discovering one instance of
the issue.

ticket: 9076 (new)

2 years agoFix integer overflows in PAC parsing
Greg Hudson [Tue, 18 Oct 2022 00:25:11 +0000 (20:25 -0400)] 
Fix integer overflows in PAC parsing

In krb5_parse_pac(), check for buffer counts large enough to threaten
integer overflow in the header length and memory length calculations.
Avoid potential integer overflows when checking the length of each
buffer.  Credit to OSS-Fuzz for discovering one of the issues.

CVE-2022-42898:

In MIT krb5 releases 1.8 and later, an authenticated attacker may be
able to cause a KDC or kadmind process to crash by reading beyond the
bounds of allocated memory, creating a denial of service.  A
privileged attacker may similarly be able to cause a Kerberos or GSS
application service to crash.  On 32-bit platforms, an attacker can
also cause insufficient memory to be allocated for the result,
potentially leading to remote code execution in a KDC, kadmind, or GSS
or Kerberos application server process.  An attacker with the
privileges of a cross-realm KDC may be able to extract secrets from a
KDC process's memory by having them copied into the PAC of a new
ticket.

ticket: 9074 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

2 years agoFix null deref in KDC when decoding invalid NDR
Greg Hudson [Wed, 12 Oct 2022 04:46:52 +0000 (00:46 -0400)] 
Fix null deref in KDC when decoding invalid NDR

In ndr_dec_delegation_info(), keep di->transited_services_length valid
by incrementing it as we add entries.  Otherwise
ndr_free_delegation_info() could dereference a null
di->transited_services field.  Also bound nservices using data->length
to prevent inordinately large memory allocations.  Credit to OSS-Fuzz
for discovering the issues.

ticket: 9073 (new)
tags: pullup
target_version: 1.20-next

2 years agoAvoid small read overrun in UTF8 normalization
Greg Hudson [Wed, 12 Oct 2022 04:27:17 +0000 (00:27 -0400)] 
Avoid small read overrun in UTF8 normalization

In krb5int_utf8_normalize(), check the length of the current character
against the buffer length before reading more than one byte.  Credit
to OSS-Fuzz for discovering the overrun.

ticket: 9072 (new)

2 years agoFix typo in TRACE_FAST_ARMOR_CCACHE_KEY message 1270/head
Richard E. Silverman [Fri, 28 Oct 2022 18:36:26 +0000 (14:36 -0400)] 
Fix typo in TRACE_FAST_ARMOR_CCACHE_KEY message

2 years agoRefactor KDC TGS processing code 1265/head
Greg Hudson [Tue, 9 Aug 2022 16:22:43 +0000 (12:22 -0400)] 
Refactor KDC TGS processing code

Split the TGS processing code into information gathering, constraint
and policy checking, and ticket-issuing steps, using a structure to
hold the gathered information.  Split validate_tgs_request() into
validate_tgs_constraints() and check_tgs_policy() for better auditing.
Fold kdc_process_s4u2proxy_req() into check_tgs_policy(), except for
the get_pac_princ_with_realm() step which is now performed in
gather_tgs_req_info().  Modify some other utility functions to fit the
new design.

2 years agoAdd and use ts_interval() helper 1266/head
Greg Hudson [Mon, 19 Sep 2022 19:18:50 +0000 (15:18 -0400)] 
Add and use ts_interval() helper

ts_delta() returns a signed result, which cannot hold an interval
larger than 2^31-1 seconds.  Intervals like this have been seen when
admins set password expiration dates more than 68 years in the future.

Add a second helper ts_interval() which returns an unsigned result,
and has the arguments reversed so that the start time is first.  Use
it in warn_pw_expiry() to handle the password expiration case, in the
GSS krb5 mech where we return an unsigned context or credential
lifetime to the caller, and in the KEYRING ccache type where we
compute an unsigned keyring timeout.

ticket: 9071 (new)

2 years agoUpdate error checking for OpenSSL CMS_verify 1264/head
Julien Rische [Thu, 28 Jul 2022 13:20:12 +0000 (15:20 +0200)] 
Update error checking for OpenSSL CMS_verify

The code for CMS data verification was initially written for OpenSSL's
PKCS7_verify() function.  It now uses CMS_verify(), but error handling
is still done using PKCS7_verify() error identifiers.  Update the
recognized error codes so that the KDC generates
KDC_ERR_DIGEST_IN_SIGNED_DATA_NOT_ACCEPTED errors when appropriate.
Use ERR_peek_last_error() to observe the error generated closest to
the API surface.

[ghudson@mit.edu: edited commit message]

ticket: 9069 (new)
tags: pullup
target_version: 1.20-next

2 years agoAvoid protocol error constants in KDC code 1263/head
Greg Hudson [Thu, 21 Jul 2022 17:32:50 +0000 (13:32 -0400)] 
Avoid protocol error constants in KDC code

For simplicity, return com_err codes from validate_as_request() and
validate_tgs_request() instead of protocol error constants.

3 years agoFix k5test.py exit handler
Greg Hudson [Thu, 21 Jul 2022 19:33:11 +0000 (15:33 -0400)] 
Fix k5test.py exit handler

Commit 0b4580b09afe9791d81961c41f61e4f06edad58f mistakenly calls the
nonexistent _stop_daemon() in the onexit handler.  Replace the call
with code to terminate the daemon and check its exit status.

3 years agoRemove kdc_context, tgs_server macros in KDC 1262/head
Greg Hudson [Mon, 18 Jul 2022 21:36:15 +0000 (17:36 -0400)] 
Remove kdc_context, tgs_server macros in KDC

Eliminate the last two kdc_active_realm macros from realm_data.h (left
behind after commits 0a2f14f752c32a24200363cc6b6ae64a92f81379 and
e987546b4ff1689bb711cc46118ad9fc0a5613f6).  Where code is affected,
use the names "context" and "realm".  Pass contexts instead of realm
data structures to several functions which only need a context.

3 years agoRemove include_certchain parameter in PKINIT 1261/head
Greg Hudson [Tue, 12 Jul 2022 23:15:29 +0000 (19:15 -0400)] 
Remove include_certchain parameter in PKINIT

Every caller of cms_signeddata_create() and cms_envelopeddata_create()
passes 1 for include_certchain.  Remove the parameter and
unconditionally add the certificate chain.

3 years agoReduce SUBDIROBJLISTS repetition in makefiles 1260/head
Greg Hudson [Tue, 12 Jul 2022 19:17:48 +0000 (15:17 -0400)] 
Reduce SUBDIROBJLISTS repetition in makefiles

Where applicable, define STOBJLISTS in terms of SUBDIROBJLISTS.

3 years agoRemove pre-CMS PKINIT compatibility code 1259/head
Greg Hudson [Mon, 11 Jul 2022 14:49:38 +0000 (10:49 -0400)] 
Remove pre-CMS PKINIT compatibility code

CMS support is present in OpenSSL 1.0, which is the earliest supported
version.

3 years agoSet reasonable supportedCMSTypes in PKINIT 1254/head
Julien Rische [Wed, 1 Jun 2022 16:02:04 +0000 (18:02 +0200)] 
Set reasonable supportedCMSTypes in PKINIT

The PKINIT client uses AuthPack.supportedCMSTypes to let the KDC know
the algorithms it supports for verification of the CMS data signature.
(The MIT krb5 KDC currently ignores this list, but other
implementations use it.)

Replace 3DES with sha512WithRSAEncryption and sha256WithRSAEncryption.

[ghudson@mit.edu: simplified code and used appropriate helpers; edited
commit message]

ticket: 9066 (new)

3 years agoSimplify plugin loading code 1258/head
Greg Hudson [Thu, 23 Jun 2022 20:41:40 +0000 (16:41 -0400)] 
Simplify plugin loading code

Remove the USE_CFBUNDLE code, which was only used by KfM.  Handle
platform conditionals according to current practice.  Use
k5_dir_filenames() instead of opendir() and remove the Windows
implementation of opendir().

3 years agoFix PKCS11 module path search
sashan [Fri, 17 Jun 2022 22:05:32 +0000 (00:05 +0200)] 
Fix PKCS11 module path search

Commit c5c11839e02c7993eb78f2c94c75c10cf93f2195 switched the loading
of the PKCS#11 module from dlopen() to krb5int_open_plugin().  Because
krb5int_open_plugin() includes a stat() test, this change has the
unintended consequence of requiring the module name to be an absolute
or relative path to the library, not a filename within the dynamic
linker search path.

Within krb5int_open_plugin(), only stat() the filename on the
platforms which will use the file type.

[ghudson@mit.edu: adjusted conditionals to call stat() on Windows;
rewrote commit message]

ticket: 9067 (new)
tags: pullup
target_version: 1.20-next

3 years agoFix build with -DDEBUG option 1257/head
sashan [Fri, 17 Jun 2022 22:17:10 +0000 (00:17 +0200)] 
Fix build with -DDEBUG option

DEBUG is not used in sserver.c, and defining it may conflict with
build options.

[ghudson@mit.edu: removed define instead of conditionalizing; edited
commit message]

3 years agoImprove k5test daemon checking 1255/head
Greg Hudson [Fri, 3 Jun 2022 18:28:26 +0000 (14:28 -0400)] 
Improve k5test daemon checking

Instead of checking daemon exit statuses prior to termination, check
them after we send SIGTERM.  This way we will notice when asan causes
an unsuccessful exit due to memory leaks, or when a daemon crashes in
its exit handling.

3 years agoFree verto context later in KDC cleanup
Greg Hudson [Fri, 3 Jun 2022 18:38:45 +0000 (14:38 -0400)] 
Free verto context later in KDC cleanup

The KDC supplies the verto context to kdcpreauth modules via the loop
method (added in commit 83b4ecd20e50ad330cd761977d5dadefe30a785b).
This context should remain valid until kdcpreauth modules are
unloaded, as modules might refer to it during cleanup.  In particular,
the OTP module references the verto context when freeing the RADIUS
client object (commit e89abc2d4ea1fea1ec28d470f297514b828e4842), which
can cause a memory error during KDC shutdown without this change.

ticket: 9064 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

3 years agoFix memory leak in OTP kdcpreauth module
Greg Hudson [Fri, 3 Jun 2022 18:30:42 +0000 (14:30 -0400)] 
Fix memory leak in OTP kdcpreauth module

In otp_edata(), free the generated nonce.

ticket: 9063 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

3 years agoFix uncommon PKINIT memory leak 1253/head
sashan [Sun, 29 May 2022 08:32:57 +0000 (10:32 +0200)] 
Fix uncommon PKINIT memory leak

PKINIT per-request module data objects are normally created by
pkinit_server_verify_padata() and freed by
pkinit_server_return_padata().  In some unusual circumstances, the KDC
may not call the return_padata method after verification succeeds.
Add a free_modreq method and free the object there instead.

[ghudson@mit.edu: rewrote commit message]

ticket: 9065 (new)
tags: pullup
target_version: 1.20-next
target_version: 1.19-next

3 years agoFix net-server.c when AI_NUMERICSERV is undefined 1252/head
Sergey Fedorov [Thu, 26 May 2022 17:06:38 +0000 (01:06 +0800)] 
Fix net-server.c when AI_NUMERICSERV is undefined

Some macOS versions do not define AI_NUMERICSERV.  Other source files
check whether it is defined before using it; do so here as well.

[ghudson@mit.edu: rewrote commit message; slightly changed approach]

ticket: 9062 (new)
tags: pullup
target_version: 1.20-next

3 years agoFix leaks in KDB test module 1251/head
sashan [Thu, 26 May 2022 06:47:33 +0000 (08:47 +0200)] 
Fix leaks in KDB test module

3 years agoFix memory leak in SPAKE kdcpreauth module
sashan [Thu, 26 May 2022 06:51:10 +0000 (08:51 +0200)] 
Fix memory leak in SPAKE kdcpreauth module

Commit ff57dc682a27bd205d715f3c0bed84890f2453c4 introduced a memory
leak into verify_response().  reply_key is no longer passed to the
callback and therefore needs to be freed by this function.

[ghudson@mit.edu: rewrote commit message]

ticket: 9061 (new)
tags: pullup
target_version: 1.20-next

3 years agoRead GSS configuration files with mtime 0 1249/head
Simo Sorce [Thu, 19 May 2022 16:27:40 +0000 (12:27 -0400)] 
Read GSS configuration files with mtime 0

There is at least one case (with flatpaks) where configuration files
in the special read-only /etc all have an mtime of 0.  Using an
initial last modified time of 0 in g_initialize.c causes these files
to never be read.

Change the initial high value to the be the "invalid" value
(time_t)-1.  Since the C and POSIX standards do not require time_t to
be signed, special-case the checks in load_if_changed() and
updateMechList() to treat all mod times as newer than -1.

[ghudson@mit.edu: edited commit message; slightly modified approach]

ticket: 9060 (new)
target_version: 1.20
tags: pullup

3 years agoSupport macOS 11 native credential cache 1221/head
Ken Hornstein [Wed, 4 Aug 2021 03:18:27 +0000 (23:18 -0400)] 
Support macOS 11 native credential cache

Add an API credential cache implementation using the CCAPI stubs in
the macOS Kerberos framework, tailored to access the native
collections used by macOS 10.6 and later (KCM before macOS 11, XCACHE
afterwards).  Make API: the default ccache name for macOS 10.6 and
later.

[ghudson@mit.edu: used shared CCAPI credential conversion functions;
changed ptcursor behavior to match current Unix collection semantics;
adjusted naming and code style]

ticket: 9052 (new)

3 years agoRefactor and move CCAPI utility functions
Greg Hudson [Thu, 24 Feb 2022 06:24:23 +0000 (01:24 -0500)] 
Refactor and move CCAPI utility functions

Move the CCAPI credential transiation functions up a layer and
refactor them to current practices.

3 years agoRemove unused CCAPI libkrb5 code
Greg Hudson [Wed, 2 Feb 2022 21:01:48 +0000 (16:01 -0500)] 
Remove unused CCAPI libkrb5 code

Remove the pre-CCAPIv3 code in the ccache type, and remove the unused
stdccCredsMatch() function from stdcc_util.c.

3 years agoRemove krb5_aprof_init() and krb5_aprof_finish() 1248/head
Greg Hudson [Mon, 9 May 2022 14:55:41 +0000 (10:55 -0400)] 
Remove krb5_aprof_init() and krb5_aprof_finish()

These functions are not part of the API, as they are prototyped in the
internal header adm_proto.h.  Stop using them in kdc/main.c (instead
using the context profile) and stop defining them.

3 years agoUse context profile for libkadm5 configuration
Greg Hudson [Mon, 9 May 2022 14:41:47 +0000 (10:41 -0400)] 
Use context profile for libkadm5 configuration

In kadm5_get_config_params(), uxe the context profile instead of
creating a new one with krb5_aprof_init().

In kproplog, obtain the context with kadm5_init_krb5_context() so that
KDC configuration is used.

ticket: 9059 (new)

3 years agoOmit LDFLAGS from krb5-config --libs output 1247/head
Greg Hudson [Tue, 3 May 2022 05:56:05 +0000 (01:56 -0400)] 
Omit LDFLAGS from krb5-config --libs output

Linker options supplied at configure time (such as -Wl,--as-needed)
can be harmful when applied to downstream users of the libraries, and
in most cases should not be necessary.

ticket: 9057 (new)

3 years agoAdd configure variable for default PKCS#11 module 1246/head
Julien Rische [Fri, 22 Apr 2022 12:12:37 +0000 (14:12 +0200)] 
Add configure variable for default PKCS#11 module

[ghudson@mit.edu: added documentation of configure variable and doc
substitution; shortened commit message]

ticket: 9058 (new)

3 years agoUpdate Windows CI and installer config
Greg Hudson [Tue, 22 Feb 2022 19:10:13 +0000 (14:10 -0500)] 
Update Windows CI and installer config

Add a VCVer case for the new Visual Studio version.  Use
ilammy/msvc-dev-cmd to set up the build environments.

3 years agomake regen
Greg Hudson [Tue, 26 Apr 2022 21:10:07 +0000 (17:10 -0400)] 
make regen

3 years agoFix iprop with fallback 1244/head
Greg Hudson [Mon, 28 Mar 2022 23:06:29 +0000 (19:06 -0400)] 
Fix iprop with fallback

kpropd produces a client principal name with
krb5_sname_to_principal(), then converts it to a string to pass as the
client principal to kadm5_init_with_skey().  This conversion loses the
name type, so no canonicalization is performed by libkadm5.

Commit dcb79089276624d7ddf44e08d35bd6d7d7e557d2 addresses this problem
for kadmin -k by looking for the referral realm, but kpropd sets the
realm in the krb5_sname_to_principal() result.  Add an additional
check for a two-component principal with kiprop as the first
component.

ticket: 9056 (new)
tags: pullup
target_version: 1.20

3 years agoInclude time.h in kdb.h 1245/head
Greg Hudson [Tue, 29 Mar 2022 20:27:55 +0000 (16:27 -0400)] 
Include time.h in kdb.h

kdb.h uses time_t, and therefore must include <time.h> to ensure its
definition.  Noticed when building t_sort_key_data.c on macOS.

3 years agoUpdates for krb5-1.21-prerelease
Greg Hudson [Thu, 24 Mar 2022 16:12:40 +0000 (12:12 -0400)] 
Updates for krb5-1.21-prerelease

3 years agoUpdate config.guess, config.sub
Greg Hudson [Tue, 22 Mar 2022 06:07:08 +0000 (02:07 -0400)] 
Update config.guess, config.sub

3 years agoUpdate features list for 1.20
Greg Hudson [Tue, 22 Mar 2022 05:39:08 +0000 (01:39 -0400)] 
Update features list for 1.20

3 years agomake regen
Greg Hudson [Fri, 18 Mar 2022 22:28:47 +0000 (18:28 -0400)] 
make regen

3 years agoTry harder to avoid password change replay errors 1242/head
Greg Hudson [Fri, 4 Mar 2022 05:45:00 +0000 (00:45 -0500)] 
Try harder to avoid password change replay errors

Commit d7b3018d338fc9c989c3fa17505870f23c3759a8 (ticket 7905) changed
change_set_password() to prefer TCP.  However, because UDP_LAST falls
back to UDP after one second, we can still get a replay error due to a
dropped packet, before the TCP layer has a chance to retry.

Instead, try k5_sendto() with NO_UDP, and only fall back to UDP after
TCP fails completely without reaching a server.  In sendto_kdc.c,
implement an ONLY_UDP transport strategy to allow the UDP fallback.

ticket: 9037

3 years agoUse SHA-256 instead of SHA-1 for PKINIT CMS digest 1243/head
Julien Rische [Fri, 11 Mar 2022 11:04:14 +0000 (12:04 +0100)] 
Use SHA-256 instead of SHA-1 for PKINIT CMS digest

[ghudson@mit.edu: edited comments]

ticket: 9055 (new)

3 years agoMake kprop work for dump files larger than 4GB 1239/head
Julien Rische [Wed, 19 Jan 2022 18:46:08 +0000 (19:46 +0100)] 
Make kprop work for dump files larger than 4GB

If the dump file size does not fit in 32 bits, encode four zero bytes
(forcing an error for unmodified kpropd) followed by the size in the
next 64 bits.

Add a functional test case, but only run it when an environment
variable is set, as processing a 4GB dump file is too
resource-intensive for make check.

[ghudson@mit.edu: edited comments and commit message; eliminated use
of defined constant in some cases; added test case]

ticket: 9053 (new)

3 years agoReplace macros with typedefs in gssrpc types.h 1240/head
Tianjiao Yin [Mon, 7 Feb 2022 08:48:05 +0000 (00:48 -0800)] 
Replace macros with typedefs in gssrpc types.h

Defining bool_t and enum_t with the preprocessor conflicts with
namespaced declarations in fbthrift's headers.  Use typedefs to avoid
this conflict and for consistency with other Sun RPC implementations.

[ghudson@mit.edu: clarified commit message]

ticket: 9054 (new)

3 years agoClarify certauth interface documentation 1238/head
Greg Hudson [Tue, 25 Jan 2022 23:09:21 +0000 (18:09 -0500)] 
Clarify certauth interface documentation

Try to make it clearer that princ is the requested client principal,
not a principal extracted from the certificate, and that the module
must decode the certificate and inspect its attributes.  Document
KRB5_CERTAUTH_HWAUTH_PASS in certauth_plugin.h.

ticket: 9051 (new)

3 years agoIn k5test, look for lldb if gdb is not found 1241/head
Greg Hudson [Thu, 10 Feb 2022 20:02:14 +0000 (15:02 -0500)] 
In k5test, look for lldb if gdb is not found

XCode for macOS provides lldb but not gdb.  For convenience, make
k5test default to lldb if gdb is not found in the path.

3 years agoUpdate copyright years to 2022
Greg Hudson [Wed, 23 Feb 2022 06:27:01 +0000 (01:27 -0500)] 
Update copyright years to 2022

3 years agoRun Windows CI on windows-2019 image for now
Greg Hudson [Wed, 23 Feb 2022 05:31:13 +0000 (00:31 -0500)] 
Run Windows CI on windows-2019 image for now

The Github Actions windows-latest runner label now uses Windows Server
2022, which requires different setup steps for the Visual Studio
environment and does not contain CRT merge modules for VS 2022 (though
it does for VS 2017).  For now, run the Windows build on windows-2019.

3 years agoRemove unneeded SPAKE free_modreq method
Greg Hudson [Fri, 28 Jan 2022 15:44:21 +0000 (10:44 -0500)] 
Remove unneeded SPAKE free_modreq method

Commit ff57dc682a27bd205d715f3c0bed84890f2453c4 removed the use of
per-request module data in SPAKE, but neglected to remove the
corresponding free_modreq method.

ticket: 9049

3 years agoAvoid passing null for asprintf strings 1235/head
Greg Hudson [Fri, 21 Jan 2022 15:58:46 +0000 (10:58 -0500)] 
Avoid passing null for asprintf strings

It is undefined behavior to pass null to a printf function for a %.*s
substitution, even if the accompanying length is zero.  OpenBSD
generates syslog warnings from libc when it sees a null pointer in a
string substitution (reported by Nathanael Rensen).
krb5_sname_to_principal() passes a null pointer in the usual case
where there is no port trailer.  Address this case and others where we
use asprintf() with %.*s substitutions and might pass null, either by
avoiding the use of asprintf() or by ensuring that the pointer isn't
null.

ticket: 9047 (new)

3 years agoPass client flag to KDB for client preauth match 1236/head
Greg Hudson [Tue, 18 Jan 2022 22:06:46 +0000 (17:06 -0500)] 
Pass client flag to KDB for client preauth match

In the kdcpreauth match_client() callback, if it is necessary to look
up the given principal in the KDB, pass KRB5_KDB_FLAG_CLIENT to
krb5_db_get_principal().  Samba requires this flag to properly handle
enterprise client principals.

ticket: 9048 (new)

3 years agoImplement replaced_reply_key input to issue_pac()
Greg Hudson [Thu, 13 Jan 2022 19:33:14 +0000 (14:33 -0500)] 
Implement replaced_reply_key input to issue_pac()

If a kdcpreauth module fully replaces the reply key during an AS
request, pass the reply key as the replaced_reply_key input to
issue_pac().  In Windows environments this is used to provide an NTLM
hash to the LSA when the client cannot be presumed to have a password
to derive it from.

To test this, add a fake PAC_CREDENTIALS_INFO buffer to the PAC in the
test KDB module, and alter adata.c to display the set of PAC buffer
types when a PAC is present.

ticket: 9050 (new)

3 years agoAdd replace_reply_key kdcpreauth callback
Greg Hudson [Thu, 13 Jan 2022 17:58:32 +0000 (12:58 -0500)] 
Add replace_reply_key kdcpreauth callback

Provide an explicit way for kdcpreauth modules to replace the reply
key, and internally track when the reply key is fully replaced (as
opposed to strengthened by replacing it with a derivative of the
client long-term key).  Use this facility in the FAST OTP, PKINIT, and
SPAKE kdcpreauth modules.

ticket: 9049 (new)

3 years agoAdd k5test.py facilities for PKINIT
Greg Hudson [Mon, 24 Jan 2022 16:20:12 +0000 (11:20 -0500)] 
Add k5test.py facilities for PKINIT

Add the global variables pkinit_enabled and pkinit_certs.  Add the
realm flag pkinit=True.  Add the realm method pkinit().  Use these
facilities in t_pkinit.py, t_certauth.py, and t_authdata.py.

3 years agoRemove unimplemented GSSRPC symbols 1222/head
Greg Hudson [Sun, 2 Jan 2022 04:32:58 +0000 (23:32 -0500)] 
Remove unimplemented GSSRPC symbols

3 years agoFactor out PAC checksum verification 1237/head
Greg Hudson [Fri, 14 Jan 2022 07:05:58 +0000 (02:05 -0500)] 
Factor out PAC checksum verification

Reduce code repetition in PAC checksum handling by adding a helper
function.  Remove the unnecessary prefix on several function names.

3 years agoReplace AD-SIGNEDPATH with minimal PACs 1225/head
Greg Hudson [Sat, 8 Jan 2022 03:41:30 +0000 (22:41 -0500)] 
Replace AD-SIGNEDPATH with minimal PACs

Remove all of the AD-SIGNEDPATH code.  Instead, issue a signed minimal
PAC in all tickets and require a valid PAC to be present in all
tickets presented for S4U operations.  Remove the get_authdata_info()
and sign_authdata() DAL methods, and add an issue_pac() method to
allow the KDB to add or copy buffers to the PAC.  Add a disable_pac
realm flag.

Microsoft revised the S4U2Proxy rules for forwardable tickets.  All
S4U2Proxy operations require forwardable evidence tickets, but
S4U2Self should issue a forwardable ticket if the requesting service
has no ok-to-auth-as-delegate bit but also no constrained delegation
privileges for traditional S4U2Proxy.  Implement these rules,
extending the check_allowed_to_delegate() DAL method so that the KDC
can ask if a principal has any delegation privileges.

Combine the KRB5_KDB_FLAG_ISSUE_PAC and
KRB5_FLAG_CLIENT_REFERRALS_ONLY flags into KRB5_KDB_FLAG_CLIENT.

Rename the KRB5_KDB_FLAG_CANONICALIZE flag to
KRB5_KDB_FLAG_REFERRAL_OK, and only pass it to get_principal() for
lookup operations that can use a realm referral.

For consistency with Active Directory, honor the no-auth-data-required
server principal flag for S4U2Proxy but not for S4U2Self.  Previously
we did the reverse.

ticket: 9044 (new)

3 years agoAdd minimal KDC MS-RPCE (NDR) encoder/decoder
Greg Hudson [Sat, 8 Jan 2022 00:58:42 +0000 (19:58 -0500)] 
Add minimal KDC MS-RPCE (NDR) encoder/decoder

Add NDR marshalling functions for S4U_DELEGATION_INFO PAC buffers.

[ghudson@mit.edu: added safety checks; made minor style changes;
edited commit message]

3 years agoAdd PAC ticket signature APIs
Isaac Boukris [Fri, 7 Jan 2022 18:46:24 +0000 (13:46 -0500)] 
Add PAC ticket signature APIs

Microsoft added a third PAC signature over the ticket to prevent
servers from setting the forwardable flag on evidence tickets.  Add
new APIs to generate and verify ticket signatures, as well as defines
for this and other new PAC buffer types.  Deprecate the old signing
functions as they cannot generate ticket signatures.  Modify several
error returns to better match the protocol errors generated by Active
Directory.

[ghudson@mit.edu: adjusted contracts for KDC requirements; simplified
and commented code changes; wrote commit message.  rharwood@redhat.com
also did some work on this commit.]

ticket: 9043 (new)

3 years agoCorrect CKSUMTYPE_SHA1 value and comment
Greg Hudson [Fri, 7 Jan 2022 06:48:40 +0000 (01:48 -0500)] 
Correct CKSUMTYPE_SHA1 value and comment

ticket: 9040

3 years agoDon't fail krb5_cc_select() for no default realm 1234/head
Isaac Boukris [Sun, 26 Dec 2021 01:28:41 +0000 (03:28 +0200)] 
Don't fail krb5_cc_select() for no default realm

If the target server principal is a host-based service without
multiple dotted components and no default realm is configured,
krb5_cc_select() can fail, and therefore gss_init_sec_context().
Continue without filling in the realm in this case.

[ghudson@mit.edu: edited commit message and comment; slightly adjusted
flow control]

ticket: 9042 (new)

3 years agoAdd PA-REDHAT-IDP-OAUTH2 padata type 1231/head
Pavel Březina [Thu, 2 Dec 2021 13:24:35 +0000 (14:24 +0100)] 
Add PA-REDHAT-IDP-OAUTH2 padata type

Recognize the Red Hat IdP preauth mechanism in trace messages, and add
a declaration for it in krb5.h.

[ghudson@mit.edu: edited comment and commit message]

ticket: 9041 (new)

3 years agoRemove unnecessary flag in macOS build 1233/head
Nikhil Benesch [Wed, 22 Dec 2021 23:58:17 +0000 (18:58 -0500)] 
Remove unnecessary flag in macOS build

The configuration logic for adding the `-search_paths_first` linker
flag on Darwin does not correctly handle cross compilation.  It should
check the value of $krb5_cv_host rather than `uname -s` to detect when
the compilation target is Darwin, rather than the build machine.

It turns out `-search_paths_first` has been the default behavior of ld
on macOS since XCode 4.  So just remove that bit of logic entirely.
(The flag was added in commit acd27af0e845f8b93de2e226cc2ec9ac8af52077
in 2004; XCode 4 was released in 2010.)

[ghudson@mit.edu: edited commit message]

3 years agoUse 14 instead of 9 for unkeyed SHA-1 checksum 1232/head
Greg Hudson [Sat, 11 Dec 2021 06:25:34 +0000 (01:25 -0500)] 
Use 14 instead of 9 for unkeyed SHA-1 checksum

Although MIT krb5 had been using the value 9 for unkeyed SHA-1 since
its 1.0 release in 1996, RFC 3961 instead assigned this value to
rsa-md5-des3 (likely never used), and assigned the values 10 and 14 to
SHA-1.  Heimdal and Microsoft use the value 14.  Unkeyed SHA-1 almost
never appears on the wire, but has been seen in PKINIT asChecksum
fields in replies from Windows KDCs (despite the field being specified
as a keyed checksum).

Define a new symbol CKSUMTYPE_SHA1 with the value 14, and use it where
we currently use CKSUMTYPE_NIST_SHA.  Continue to allow the value 9
for ABI compatibility.  Remove the pkinit_clnt.c workaround as the
value 14 will now work without adjustment.

ticket: 9040 (new)

3 years agoFix PAC handling of authtimes after y2038
Greg Hudson [Thu, 2 Dec 2021 00:35:32 +0000 (19:35 -0500)] 
Fix PAC handling of authtimes after y2038

Remove the unnecessary handling of negative inputs in
k5_time_to_seconds_since_1970() and k5_seconds_since_1970_to_time(),
and cast the krb5_timestamp input to uint32_t to properly handle
values after y2038.

ticket: 9039 (new)

3 years agoFix OpenSSL conditionals for two files
Isaac Boukris [Sun, 5 Dec 2021 21:08:41 +0000 (16:08 -0500)] 
Fix OpenSSL conditionals for two files

Commit 7e8c41afc54db2ca75de5a1e2e440b034be8887b mistakenly left
two files.  Fix them.

[ghudson@mit.edu: keep crypto_int.h include unconditional; wrote
commit message]

3 years agoIssue an error from KDC on S4U2Self failures
Andreas Schneider [Wed, 20 Oct 2021 05:12:19 +0000 (07:12 +0200)] 
Issue an error from KDC on S4U2Self failures

Commit 3b163eed1cf1f55dd4a7bc6d6fffc34f55695b00 mistakenly separated
the call to kdc_process_s4u2self_req() from its error check, causing
the KDC to ignore S4U2Self padata with bad checksums.  Restore the
error check so that the KDC replies with an error as intended.

[ghudson@mit.edu: removed old error check later on in the code;
rewrote commit message]

ticket: 9038 (new)

3 years agoUse OpenSSL CMAC implementation with OpenSSL 3 1212/head
Greg Hudson [Tue, 19 Oct 2021 14:42:34 +0000 (10:42 -0400)] 
Use OpenSSL CMAC implementation with OpenSSL 3

Make krb5int_cmac_checksum() a crypto module interface.  Move the
existing CMAC implementation from krb to builtin.  Add an OpenSSL 3
implementation using EVP_MAC.  Only implement Camellia CBC-MAC if
using the builtin CMAC implementation (it uses functions deprecated in
OpenSSL 3).  Switch to using krb5int_camellia_encrypt() for
camellia-test.c since krb5int_camellia_cbc_mac() won't always be
available.

3 years agoUpdate PKINIT for OpenSSL 3
Robbie Harwood [Thu, 15 Jul 2021 22:12:27 +0000 (18:12 -0400)] 
Update PKINIT for OpenSSL 3

[ghudson@mit.edu: made the new SHA-1 and key decryption code work with
all suported OpenSSL versions with just one implementation; added
Diffie-Hellman changes]

3 years agoUse the supported version of openssl 3's CTS mode
Robbie Harwood [Tue, 17 Aug 2021 21:11:19 +0000 (17:11 -0400)] 
Use the supported version of openssl 3's CTS mode

Fixes deprecation warnings about AES_cbc_encrypt and friends.

3 years agoPrefer openssl's EVP_MAC interface for HMAC
Robbie Harwood [Tue, 13 Jul 2021 19:07:39 +0000 (15:07 -0400)] 
Prefer openssl's EVP_MAC interface for HMAC

OpenSSL 3 has deprecated the HMAC interface.

3 years agoUse OpenSSL 3 versions of remaining KDFs
Robbie Harwood [Fri, 20 Sep 2019 21:20:59 +0000 (17:20 -0400)] 
Use OpenSSL 3 versions of remaining KDFs

In OpenSSL's terminology, id-pkinit-kdf is an instance of SSKDF,
AES-SHA2 and Camellia use KBKDF, and the KDF for DES3 and AES-SHA1 has
been named KRB5KDF.  Support for these KDFs was added in OpenSSL 3; we
already supported the existing PBKDF2.

[ghudson@mit.edu: reorganize into builtin and openssl versions of the
file; detect hash and encryption provider identity using pointer
equality like we do in the OpenSSL PBKDF implementation; add helpers
for this translation; simplify and better refactor the PKINIT code;
fix some latent pkinit_kdf_test.c bugs]

3 years agoSupport larger RADIUS attributes in libkrad 1229/head
Sumit Bose [Mon, 8 Nov 2021 16:48:50 +0000 (17:48 +0100)] 
Support larger RADIUS attributes in libkrad

In kr_attrset_decode(), explicitly treat the length byte as unsigned.
Otherwise attributes longer than 125 characters will be rejected with
EBADMSG.

Add a 253-character-long NAS-Identifier attribute to the tests to make
sure that attributes with the maximal number of characters are working
as expected.

[ghudson@mit.edu: used uint8_t cast per current practices; edited
commit message]

ticket: 9036 (new)

3 years agoMore python3 fixes for t_daemon.py 1230/head
Sumit Bose [Mon, 8 Nov 2021 16:47:17 +0000 (17:47 +0100)] 
More python3 fixes for t_daemon.py

[ghudson@mit.edu: use a list comprehension instead of map()]

3 years agoAvoid use after free during libkrad cleanup
Greg Hudson [Tue, 9 Nov 2021 18:00:43 +0000 (13:00 -0500)] 
Avoid use after free during libkrad cleanup

libkrad client requests contain a list of references to remotes, with
no back-references or reference counts.  To prevent accesses to
dangling references during cleanup, cancel all requests on all remotes
before freeing any remotes.

Remove the code for aging out unused servers.  This code was fairly
safe as all requests referencing a remote should have completed or
timed out during an hour of disuse, but in the current design we have
no way to guarantee or check that.  The set of addresses we send
RADIUS requests to will generally be small, so aging out servers is
unnecessary.

ticket: 9035 (new)

3 years agoRemove pkinit_kdf_constants.c
Greg Hudson [Fri, 5 Nov 2021 23:22:32 +0000 (19:22 -0400)] 
Remove pkinit_kdf_constants.c

Commit 9a0575f84e988a23709429f7d4e626db833ab562 renamed this file to
pkinit_constants.c but neglected to remove it.  Remove it now, and
also regenerate dependencies.

3 years agoUse EVP key agreement in PKINIT 1228/head
Greg Hudson [Thu, 28 Oct 2021 04:00:20 +0000 (00:00 -0400)] 
Use EVP key agreement in PKINIT

In pkinit_crypto_openssl.c, use EVP_PKEY objects and interfaces to
perform DH operations to the extent possible in OpenSSL 1.0 and 1.1.
Define helper functions for DH operations to make it easier to
conditionalize on OpenSSL version.

3 years agoUse OpenSSL SubjectPublicKeyInfo parsing in PKINIT 1227/head
Greg Hudson [Mon, 25 Oct 2021 05:51:59 +0000 (01:51 -0400)] 
Use OpenSSL SubjectPublicKeyInfo parsing in PKINIT

Shift responsibility for encoding and decoding SubjectPublicKeyInfo
from libkrb5 to the PKINIT ASN.1 module.  OpenSSL 1.0 does not support
DHX (RFC 3279 section 3), so for that version use custom ASN.1
marshalling of the parameters and compose that into
SubjectPublicKeyInfo marshalling using X509_PUBKEY.

3 years agoUse pre-encoded DH parameter constants in PKINIT 1226/head
Greg Hudson [Sat, 23 Oct 2021 20:40:23 +0000 (16:40 -0400)] 
Use pre-encoded DH parameter constants in PKINIT

Rename pkinit_kdf_constants.c to pkinit_constants.c and add encodings
of the three well-known Oakley groups.  Use them to greatly simplify
pkinit_create_td_dh_parameters() and eliminate make_oakley_dh().
Change the interface for decoding parameters to take a krb5_data
pointer for caller convenience.