Commit Graph

64 Commits

Author SHA1 Message Date
Michael Tokarev
c80c04b235 spelling fixes (underun prefered relase encyption confunder)
[abartlet@samba.org: From Samba debian package at
 https://salsa.debian.org/samba-team/samba/-/blob/master/debian/patches/heimdal-spelling.patch?ref_type=heads]

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
2024-06-16 23:28:43 -04:00
Jeffrey Altman
8254c01ae7 lib/gssapi/spnego: accept_sec_context free 'supported_mechs'
If no preferred mechanism was found 'supported_mechs' was leaked.

Change-Id: I2982f94d7e9569461f562987609ff7bff57b3f88
2022-01-16 22:57:15 -05:00
Nicolas Williams
2f31063e97 spnego: Minor style cleanup 2021-11-11 22:41:13 -06:00
Nicolas Williams
7a19658c1f spnego: Fix NULL deref
Reported to Heimdal by Michał Kępień <michal@isc.org>.

From the report:

Acknowledgement
---------------

This flaw was found while working on addressing ZDI-CAN-12302: ISC BIND
TKEY Query Heap-based Buffer Overflow Remote Code Execution
Vulnerability, which was reported to ISC by Trend Micro's Zero Day
Initiative.
2021-11-11 22:41:13 -06:00
Luke Howard
73224fef5a gss: zero spnego mechanism token error buffer
Ensure mechanism error token buffer, which is allocated on the stack, is zero'd
out before freeing containing ASN.1 structure
2021-08-02 15:55:10 +10:00
Luke Howard
8d19f3f47f gss: pass mechanism error tokens through SPNEGO
Fix for issue #486 based on a patch by Nico Williams.

A GSS-API acceptor can return an error token to be sent to the initiator. Our
SPNEGO implementation discarded these when sending a SPNEGO reject response.
This patch fixes the SPNEGO acceptor to convey those in the SPNEGO response.

The SPNEGO initiator is also updated to not bail out early on receiving a
SPNEGO reject response from the acceptor, but instead pass the response token
(if any) to gss_init_sec_context(). A reject response with no response token
will continue to return an error.
2020-04-24 15:07: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
Luke Howard
3b7aae7fce gss: order SPNEGO proposed mechs by req_flags
Sort the list of mechanisms proposed by the initiator so that mechanisms are
preferred by their advertised support for GSS flags. For example, if
GSS_C_MUTUAL_FLAG is requested, a mechanism that offers GSS_C_MA_AUTH_TARG will
be preferred over one that doesn't. The flag/mechanism attribute combinations
are also assigned a weight (mutual trumps anonymous, for example).
2020-04-12 13:25:09 -05:00
Luke Howard
161f846d76 gss: harmonize negState with RFC 4178
RFC 4178 4.2.2 uses the field name negState rather than negResult in
NegTokenResp, to denote the negotiation state. Harmonize with this, also
replacing the underscores in accept-completed and accepet-incomplete to match
the RFC.
2020-02-04 17:28:35 +11:00
Luke Howard
3e69aacbe2 gss: harmonize SPNEGO with [MS-SPNG]
In [MS-SPNG], the Microsoft extension is defined as NegTokenInit2 rather than
NegTokenInitWin. Harmonize with the specification.
2020-02-04 17:28:35 +11:00
Luke Howard
044c1c6b63 gss: don't generate mechListMIC in SPNEGO if it is safe to omit it 2020-02-04 17:28:35 +11: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
83d2951c0d gssapi: SPNEGO does not reset NTLM RC4 state (#509) 2019-01-06 20:50:24 -06:00
Luke Howard
dfaaf9c93f gssapi: honor acceptor credential in SPNEGO (#506)
SPNEGO uses the callback function acceptor_approved() in order to determine
which mechanisms to advertise to the initiator in the case that the initiator
sent an empty initial context token. Prior to this commit, that function was
not passed in the acceptor credential (if present), so always uses a default
credential. For correctness, we should only advertise the availability of
mechanisms for which we have a credential.
2019-01-04 15:49:44 +11:00
Luke Howard
a7d42cdf6b gssapi: honor initiator credential in SPNEGO (#506)
SPNEGO uses the callback function initiator_approved() in order to determine
mechanism availability. Prior to this commit, is not passed in the initiator
credential, so it always uses a default credential. This breaks SPNEGO if a
non-default credential (such as one acquired with
gss_acquire_cred_with_password()) is used. This commit addresses this.
2019-01-03 23:25:30 +11:00
Nicolas Williams
7dfad1ab0b Use secure_getenv() instead of issuid() 2017-04-17 18:02:30 -04:00
Nicolas Williams
774f166e31 First attempt s/\<const gss_.*_t/gss_const_.*_t/g 2013-06-02 15:30:58 -05:00
Love Hornquist Astrand
0879b9831a remove trailing whitespace 2011-05-21 11:57:31 -07:00
Love Hornquist Astrand
b01fe66069 Use right variable with comparing lengths. Patch orignally from Jaideep Padhye 2011-05-17 21:17:59 -07:00
Jeffrey Altman
6850d6a65f avoid uninit variable and unreachable code warnings
most of these warnings are not problems because of ample
use of abort() calls.  However, the large number of warnings
makes it difficult to identify real problems.  Initialize
the variables to shut up the compilers.

Change-Id: I8477c11b17c7b6a7d9074c721fdd2d7303b186a8
2011-05-17 12:02:16 -04:00
Love Hornquist Astrand
f5f9014c90 Warning fixes from Christos Zoulas
- shadowed variables
- signed/unsigned confusion
- const lossage
- incomplete structure initializations
- unused code
2011-04-29 20:25:05 -07:00
Asanka Herath
5dcc605f6b Fix calling conventions for Windows 2010-08-20 13:14:10 -04:00
Love Hornquist Astrand
2b1645aa08 catch error from as.*printf 2010-05-30 13:44:41 -07:00
Love Hornquist Astrand
de0102fa0c drop RCSID 2009-11-14 11:14:56 -08:00
Love Hornquist Astrand
022e7d4319 Return unwrapped delegated credentials if the actual mech is not the called mech
Assumes that pseudo mechs are are of how mechglue credentails look like and
return credentials like that.

Pointed out on krbdev by Nicolas Williams
2009-08-26 22:32:50 -07:00
Love Hörnquist Åstrand
8eb14db155 remove unused variable
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25323 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-07-15 22:16:21 +00:00
Love Hörnquist Åstrand
90ac3afd08 hostname is not_defined_in_RFC4178@please_ignore
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@25291 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-06-28 21:12:38 +00:00
Love Hörnquist Åstrand
269a7a057b flatten include headers
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24382 ec53bebd-3082-4978-b11e-865c3cabbd6b
2009-01-25 00:35:00 +00:00
Love Hörnquist Åstrand
b35c56fff6 check for value of get_mic, not that is a pointer. cid#141
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24109 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-11 05:01:10 +00:00
Love Hörnquist Åstrand
0e01d8fa11 check for value of get_mic, not that is a pointer. cid#141
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24108 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-12-11 05:01:00 +00:00
Love Hörnquist Åstrand
6937d41a02 remove trailing whitespace
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23815 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 09:21:03 +00:00
Love Hörnquist Åstrand
e172367898 switch to utf8 encoding of all files
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23814 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-09-13 08:53:55 +00:00
Love Hörnquist Åstrand
f462f342a0 don't bother setting verify_mic if its not used after this.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23499 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-08-11 09:59:49 +00:00
Love Hörnquist Åstrand
fc518d9fca Changes from doug barton to make spnego indepedant of the heimdal version of the plugin system.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@23158 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-05-02 09:45:28 +00:00
Love Hörnquist Åstrand
784ffbfa6a Make delegated credentials delegated directly, Oleg Sharoiko pointed out that it always didnt work with the old code. Also add som missing cred and context pass-thou functions in the SPNEGO layer
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22688 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-03-16 11:33:58 +00:00
Love Hörnquist Åstrand
3673482a9b make the SPNEGO mech store the error itself instead, works for everything except other stackable mechs
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22600 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-02-21 12:46:24 +00:00
Love Hörnquist Åstrand
b53c90da08 Make error reporting somewhat more correct for SPNEGO.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22569 ec53bebd-3082-4978-b11e-865c3cabbd6b
2008-02-03 18:20:24 +00:00
Love Hörnquist Åstrand
05e5153afc Make compile again.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21461 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-07-10 14:01:13 +00:00
Love Hörnquist Åstrand
f3842471ec remove checks that are done by the previous function.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21459 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-07-10 13:23:14 +00:00
Love Hörnquist Åstrand
64b2fd7e72 Wrap name in a spnego_name instead of just a copy of the underlaying object.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21243 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-20 15:16:22 +00:00
Love Hörnquist Åstrand
c68e3696e2 Handle underlaying mech not returning mn.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21239 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-20 11:23:13 +00:00
Love Hörnquist Åstrand
a5f538fae9 Make sure src_name is always set to GSS_C_NO_NAME when returning.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21235 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-20 11:10:33 +00:00
Love Hörnquist Åstrand
79f9985a9c Only wrap the delegated cred if we are going to return it to the consumer.
From Rafal Malinowski.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21186 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-20 03:29:02 +00:00
Love Hörnquist Åstrand
b3d275ac40 Fixed memory leak pointed out by Rafal Malinowski, also while here
moved to use NegotiationToken for decoding.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21185 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-20 03:23:49 +00:00
Love Hörnquist Åstrand
ab8094ae4c Init get_mic to 0.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@21127 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-18 20:23:14 +00:00
Love Hörnquist Åstrand
f3b2b8b19c Make sure the gethostname() returned string is NUL terminated.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20929 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-06-05 21:19:22 +00:00
Love Hörnquist Åstrand
5e36b724c0 Use the return value before is overwritten by later calls.
From Rafal Malinowski


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@20755 ec53bebd-3082-4978-b11e-865c3cabbd6b
2007-05-31 23:01:27 +00:00
Love Hörnquist Åstrand
3c9d3266f4 try using gss_accept_sec_context() on the opportunistic token instead
of guessing the acceptor name and do gss_acquire_cred, this make
SPNEGO work like before.


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19435 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-19 12:10:35 +00:00
Love Hörnquist Åstrand
20e973fda2 Resurect negHints for the acceptor sends first packet.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19421 ec53bebd-3082-4978-b11e-865c3cabbd6b
2006-12-18 18:50:15 +00:00