Commit Graph

173 Commits

Author SHA1 Message Date
Luke Howard
dc682769c4 gss: use mechglue instead of gssntlm encoders
Replace calls to {en,de}code...() with mechglue equivalents.
2023-01-16 19:11:03 +11:00
Nicolas Williams
27e5c40a79 gss: Fix leaks 2023-01-04 00:43:43 -06:00
Joseph Sutton
b19633f9b9 Use constant-time memcmp when comparing sensitive buffers
This helps to avoid timing attacks.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
2022-04-30 13:35:52 -04:00
Jeffrey Altman
d35c9b2d67 lib/gssapi/ntlm: _gss_ntlm_inquire_cred dead code removal
do not check 'cred_handle' for GSS-C_NO_CREDENTIAL twice.

Change-Id: I3629aa49b2d20d3444c6ede46715d65b6072484f
2022-01-23 23:11:46 -05:00
Roland C. Dowdeswell
8dcd05ed4d _gss_ntlm_init_sec_context() mem leaks 2022-01-22 21:54:20 -05:00
Roland C. Dowdeswell
e87fca8091 _gss_ntlm_delete_sec_context() mem leaks 2022-01-22 21:54:20 -05:00
Roland C. Dowdeswell
8526b4c627 fix memory leak near NTLM type2 response 2022-01-22 21:54:20 -05:00
Jeffrey Altman
ff18c32ae4 lib/gssapi/ntlm: from_file do not leak 'f' on error
Change-Id: Ica774bc3c156c384a2cf7084259d31f445d24a7d
2022-01-16 23:10:33 -05:00
Nicolas Williams
96b7ea671d gss: Fix warnings 2022-01-14 17:39:05 -06:00
Nicolas Williams
05e8c0ede6 Check HMAC_Init_ex() return value 2022-01-14 12:48:32 -06:00
Andrew Bartlett
7686028718 Use UTF-8 in KTH copyright notice
Samba is starting to protect against bi-di attacks and the starting point
is to require that input files be fully UTF-8.  In 2021 this is a reasonable
starting point anyway.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2021-11-29 12:50:26 +11:00
Robert Crowston
5d462795ce Add stub for gss_acquire_cred_impersonate_name(). 2021-10-19 20:45:40 +11:00
Luke Howard
d672e49231 gss: don't leak NTLM cred on failure
Do not leak partially complete credential handle in _gss_ntlm_get_user_cred()
2021-08-02 17:09:55 +10:00
Nicolas Williams
a54761d68a Properly implement neg_mechs & GM_USE_MG_CRED
SPNEGO was already using union creds.  Now make the mechglue know about
it, delete all of the cred-related SPNEGO stubs that are now not called
(lib/gssapi/spnego/cred_stubs.c), and implement gss_get/set_neg_mechs()
by storing the OID set in the union cred.

This commit was essentially authored as much if not more by Luke Howard
<lukeh at padl.com> as much as by the listed author.
2020-04-21 00:21:32 -05:00
Nicolas Williams
92c288994a Better support for "non-standard" GSS mechs
If an initial security context token doesn't have a standard header per
RFC2743 then try all mechanisms until one succeeds or all fail.

We still try to guess NTLMSSP, raw Kerberos, and SPNEGO, from tasting
the initial security context token.
2020-04-17 14:37:39 -05:00
Nicolas Williams
7bf4d76e75 krb5: Improve cccol sub naming; add gss_store_cred_into2()
- Formalize the TYPE:collection_name:subsidiary_name naming scheme for
   ccaches in ccache collections
    - KEYRING: ccaches are weird because they have one more optional field: the
      "anchor", so rather than just assume a naming convention everywhere, we
      add new functions as well
 - Add krb5_cc_{resolve,default}_sub() that allows one to specify a
   "subsidiary" ccache name in a collection separately from the
   collection name
 - Add krb5_cc_{resolve,default}_for() which take a principal name,
   unparse it, and use it as the subsidiary ccache name (with colons
   replaced)
 - Make kinit use the new interfaces
 - Add missing DIR ccache iteration functionality
 - Revamps test_cc
 - Add krb5_cc_get_collection() and krb5_cc_get_subsidiary()
 - Bump the ccops SPI version number
 - Add gss_store_cred_into2()
 - Make MEMORY:anonymous not linked into the global MEMORY ccache
   collection, and uses this for delegated cred handles

TBD:

 - Split this up into a krb5 change and gss mech_krb5 change?
 - Add krb5_cc_init_and_store() utility, per Greg's suggestion?
2020-03-02 17:48:04 -06:00
Luke Howard
4fb6a6adc9 gss: port NegoEx implementation from MIT
An implementation of draft-zhu-negoex-04 for MIT Kerberos was developed in
2011. This has been recently integrated, with many fixes from Greg Hudson. This
commit ports it to Heimdal. The implementation has been interoperability tested
with MIT Kerberos and Windows, using the GSS EAP mechanism developed as part of
the Moonshot project.

The SPNEGO code was also updated to import the state machine from Apple which
improves mechListMIC processing and avoids discarding initial context tokens
generated during mechanism probing, that can be used for optimistic tokens.

Finally, to aid in testing, the GSS-API mechanism glue configuration file can
be changed using the environment variable GSS_MECH_CONFIG. This environment
variable name, along with the format of the configuration file, is compatible
with MIT (although it would be difficult for a single mechanism binary to
support both implementations).
2020-02-04 17:28:35 +11:00
Luke Howard
ae5c60286a gss: remove SPNEGO name wrappers
Wrapping GSS names at the SPNEGO level serves no purpose; remove it and return
mechglue names directly. This required a small change to the NTLM mechanism to
allow NULL names to be passed to its release name function.
2020-02-04 17:28:35 +11:00
Luke Howard
920cfc5584 gss: use _gss_ntlm_set_keys() in gss_init_sec_context()
DRY: use the _gss_ntlm_set_keys() helper function to initialize the key state
for both initiator and acceptor.
2020-02-04 17:28:35 +11:00
Luke Howard
c510e6d474 gss: don't provide domain to nsi_probe() in NTLM
_gss_ntlm_accept_sec_context() does not provide the acceptor domain to
nsi_probe(); for consistency, _gss_ntlm_acquire_cred_from() should do that
same. Providing the acceptor domain was breaking tests.

Note that the Heimdal NTLM implementation is old and has few consumers (Apple
and Samba use their own implementations). Arguably we should merge the Apple
implementation or remove it.
2020-02-04 17:28:35 +11:00
Luke Howard
bf14eb29df gss: NTLM nsi_probe returns a krb5, not gss error
The nsi_probe() error code was treated as a GSS error code, rather than a krb5
error. Return a GSS error code, setting the krb5 error in minor_status.
2020-02-04 17:28:35 +11:00
Luke Howard
83d2951c0d gssapi: SPNEGO does not reset NTLM RC4 state (#509) 2019-01-06 20:50:24 -06:00
Luke Howard
735039dbdc gssapi: implement gss_set_neg_mechs() (#495)
Implementation of gss_set_neg_mechs() and gss_get_neg_mechs() as defined in RFC
4178. New gss_release_cred_by_mech() API for dropping a credential from a
mechanism glue credential.
2019-01-04 15:50:11 +11:00
Luke Howard
e0bb9c10ca gssapi: credential store extensions (#451)
Implement the GSS-API credential store API extensions defined by MIT here:

https://k5wiki.kerberos.org/wiki/Projects/Credential_Store_extensions

Note: we kill off gss_acquire_cred_ext() here. This was never a public API,
although mechanisms could have implemented it and I briefly used it in my
BrowserID prototype mechanism. gss_acquire_cred_ext_from() occupies the place
in the dispatch table where gss_acquire_cred_ext() used to, but this structure
was never visible outside Heimdal (i.e. it is only used by internal
mechanisms);

(Mechanisms that need to accept arbitrary key/value dictionaries from
applications should now implement gss_acquire_cred_from().)
2019-01-03 14:38:39 -06:00
Luke Howard
57df2ff1cc gssapi: ntlm mech should use _gss_ntlm_copy_cred() to dup cred 2019-01-02 20:23:18 -06:00
Jeffrey Altman
da6190ec03 lib/gssapi/ntlm: _gss_ntlm_allocate_ctx handle calloc failure
If a memory allocation failure occurs, return an error instead of
triggering a segmentation fault.

Change-Id: I38f5e88ca2f1ba7411b05a35b925168015261eb4
2019-01-01 15:05:31 -05:00
Nicolas Williams
e6d1c10808 Rewrite gss_add_cred() (fix #413)
It turns out gss_add_cred() really needed a complete rewrite.  It's much
better to first have a gss_duplicate_cred() (which has been needed for
other reasons anyways), and use that when the input_cred_handle is not
GSS_C_NO_CREDENTIAL and output_cred_handle is not NULL, then mutate that
duplicate credential handle (or the input_cred_handle if
output_cred_handle is NULL).
2018-12-28 19:26:25 -06:00
Luke Howard
9763482d9f gssapi: fix pointer type mismatch in NTLM mech 2018-12-23 07:42:16 +00:00
Jeffrey Altman
d570541e3d Update accept_sec_context.c 2018-09-17 18:12:25 -04:00
Markus Moeller
635ac1aa85 Free context in case of error 2018-09-17 18:12:25 -04:00
Aleksei Martynov
a666bf165e Fix memory leak in _gss_ntlm_release_cred.
ntlm_cred is always allocated with calloc, so we need to free the cred
object too, similarly to what _gsskrb5_release_cred does.
2017-05-22 12:05:00 -05:00
Jeffrey Altman
93518bfab4 use memset_s
lib roken includes support for memset_s() but it was not applied
to the Heimdal source tree.

Change-Id: I8362ec97a9be50205bb2d398e65b629b88ce1acd
2017-04-29 01:05:59 -04:00
Nicolas Williams
7dfad1ab0b Use secure_getenv() instead of issuid() 2017-04-17 18:02:30 -04:00
Nicolas Williams
c9e5da9d2b NTLM memleak
Originally by Christos Zoulas.
2017-03-13 18:39:41 -04:00
Nicolas Williams
1c81ddf4e2 Round #2 of scan-build warnings cleanup 2016-11-16 17:03:14 -06:00
Nicolas Williams
490337f4f9 Make OpenSSL an hcrypto backend proper
This adds a new backend for libhcrypto: the OpenSSL backend.

Now libhcrypto has these backends:

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

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

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

Because libhcrypto's EC support is incomplete, we can only use OpenSSL
for EC.  Currently that means separating all EC-using code so that it
does not use hcrypto, thus the libhx509/hxtool and PKINIT EC code has
been moved out of the files it used to be in.
2016-04-15 00:16:17 -05:00
Nicolas Williams
d3f9bea491 Fix lib/gssapi/ntlm/crypto.c includes 2016-04-15 00:16:14 -05:00
Jeffrey Altman
1e85577f93 YFS Coverity 11631
Change-Id: I0848303e123ec07ac8c552c736510e7be2dd5598
2015-04-21 21:59:42 -04:00
Nicolas Williams
08724496ff Use default NTLM domain cc config
The NTLM GSS mechanism now supports default credential handles (and
acquiring handles for default credentials with desired_name ==
GSS_C_NO_NAME).
2015-04-17 10:55:17 -05:00
Love Hörnquist Åstrand
01dbfac96f fix warnings 2014-02-14 19:45:46 -08:00
Nicolas Williams
fdcb8f3862 Fix callers of heim_ntlm_encode_type3; make build 2013-11-20 01:20:01 -06:00
Jeffrey Altman
8fe301c692 Include krb5-private.h in gssapi/ntlm/crypto.c
Instead of locally defining prototypes for private functions
_krb5_crc_update and _krb5_crc_init_table simply include
krb5-private.h.

Change-Id: Ia7931f8df2e68eb038d112797edfd456ffcdd23a
2013-06-22 21:17:18 -04:00
Love Hornquist Astrand
4227e45a58 Merge branch 'nico/gss_constify' 2013-06-03 21:51:10 -07:00
Love Hornquist Astrand
060474df16 quel 64bit warnings, fixup implicit encoding for template, fix spelling 2013-06-03 21:46:20 -07:00
Nicolas Williams
774f166e31 First attempt s/\<const gss_.*_t/gss_const_.*_t/g 2013-06-02 15:30:58 -05:00
Roland C. Dowdeswell
cc47c8fa7b Turn on -Wextra -Wno-sign-compare -Wno-unused-paramter and fix issues.
We turn on a few extra warnings and fix the fallout that occurs
when building with --enable-developer.  Note that we get different
warnings on different machines and so this will be a work in
progress.  So far, we have built on NetBSD/amd64 5.99.64 (which
uses gcc 4.5.3) and Ubuntu 10.04.3 LTS (which uses gcc 4.4.3).

Notably, we fixed

	1.  a lot of missing structure initialisers,

	2.  unchecked return values for functions that glibc
	    marks as __attribute__((warn-unused-result)),

	3.  made minor modifications to slc and asn1_compile
	    which can generate code which generates warnings,
	    and

	4.  a few stragglers here and there.

We turned off the extended warnings for many programs in appl/ as
they are nearing the end of their useful lifetime, e.g.  rsh, rcp,
popper, ftp and telnet.

Interestingly, glibc's strncmp() macro needed to be worked around
whereas the function calls did not.

We have not yet tried this on 32 bit platforms, so there will be
a few more warnings when we do.
2012-02-20 19:45:41 +00:00
Love Hornquist Astrand
3564726537 support NT_USER_NAME for real 2011-05-22 13:02:08 -07:00
Love Hornquist Astrand
9dc505a721 cred is no longer a name, handle that 2011-05-22 13:01:32 -07:00
Love Hornquist Astrand
26085dfbc0 allocate enough memory 2011-05-21 13:25:24 -07:00
Love Hornquist Astrand
58ffee93b7 allow GSS_C_NT_USER_NAME too 2011-05-21 13:07:22 -07:00