RFC 4178

The Simple and Protected Generic Security Service Application Program Interface (GSS-API) Negotiation Mechanism

๐Ÿ“… published October 2005, from ietf

RFC 4178: The Simple and Protected Generic Security Service Application Program Interface (GSS-API) Negotiation Mechanism ๐ŸŽ€

Okay bestie, so this is RFC 4178 ๐Ÿ’– (part 1 of 4). It's a Standards Track doc from the Network Working Group, dated October 2005. The authors are L. Zhu, P. Leach, and K. Jaganathan from Microsoft Corporation, plus W. Ingersoll from Sun Microsystems. It obsoletes RFC 2478 ๐Ÿฆ‹, and this one is the replacement for that spec. The title block doesn't list anything it updates.


Status of This Memo ๐Ÿ“œ

This document specifies an Internet standards track protocol for the Internet community, and it's asking for discussion and suggestions for improvements ๐ŸŒธ. Check the current edition of the "Internet Official Protocol Standards" (STD 1) for the standardization state and status of this protocol. Distribution of this memo is unlimited โœจ.

Copyright (C) The Internet Society (2005).

Abstract ๐Ÿงš

This document specifies a negotiation mechanism for the Generic Security Service Application Program Interface (GSS-API), which is described in RFC 2743 ๐Ÿ’œ. GSS-API peers can use this mechanism to pick from a shared set of security mechanisms ๐Ÿซถ. If per-message integrity services are available on the established mechanism context, then the negotiation is protected against an attacker that forces the selection of a mechanism the peers didn't want ๐Ÿ’€. That's the main character moment right there.

This mechanism replaces RFC 2478 to fix defects in that spec ๐Ÿ”ฅ. It also explains how to inter-operate with implementations of that spec that are commonly deployed on the Internet ๐ŸŒˆ.

Table of Contents ๐Ÿ“š

1. Introduction ....................................................2
2. Conventions Used in This Document ...............................3
3. Negotiation Protocol ............................................3
   3.1. Negotiation Description ....................................4
   3.2. Negotiation Procedure ......................................5
4. Token Definitions ...............................................7
   4.1. Mechanism Types ............................................7
   4.2. Negotiation Tokens .........................................7
        4.2.1. negTokenInit ........................................8
        4.2.2. negTokenResp ........................................9
5. Processing of mechListMIC ......................................10
6. Extensibility ..................................................13
7. Security Considerations ........................................13
8. Acknowledgments ................................................14
9. References .....................................................14
   9.1. Normative References ......................................14
   9.2. Informative References ....................................15
Appendix A.  SPNEGO ASN.1 Module ..................................16
Appendix B.  GSS-API Negotiation Support API ......................17
   B.1.  GSS_Set_neg_mechs Call ...................................17
   B.2.  GSS_Get_neg_mechs Call ...................................18
Appendix C.  Changes since RFC 2478 ...............................18
Appendix D.  mechListMIC Computation Example ......................20

1. Introduction ๐ŸŒธ

So the GSS-API [RFC2743] is a generic interface that can sit on top of different security mechanisms ๐Ÿง. If communicating peers get GSS-API credentials for the same security mechanism, then a security context can be set up between them (subject to policy) ๐Ÿ’…. The catch is that GSS-API doesn't say how peers can figure out whether they even have a common security mechanism ๐Ÿ˜ญ.

The Simple and Protected GSS-API Negotiation (SPNEGO) mechanism defined here is a pseudo security mechanism ๐Ÿฆ‹. It lets GSS-API peers figure out in-band whether their credentials support a common set of one or more GSS-API security mechanisms โœจ. If they do, it kicks off the normal security context establishment for a selected common mechanism ๐Ÿ”ฅ. This is most useful for applications that depend on GSS-API implementations and share multiple mechanisms between the peers ๐Ÿซถ.

Here's the model SPNEGO uses for negotiation ๐Ÿ’–. The initiator proposes a list of security mechanisms in decreasing preference order, favorite choice first ๐Ÿ‘‘. The acceptor (also known as the target) either accepts the initiator's preferred mechanism (the first one in the list) or picks one of the available mechanisms from the offered list ๐Ÿ“. If neither works out, the acceptor rejects the proposed value(s) ๐Ÿ’€. Then the target tells the initiator what it chose ๐Ÿงš.

Once a common security mechanism is chosen, mechanism-specific options MAY be negotiated as part of that mechanism's context establishment ๐ŸŒˆ. Those negotiations (if any) are internal to the mechanism and opaque to the SPNEGO protocol ๐Ÿ™ˆ. So they're outside the scope of this document ๐Ÿ’….

If per-message integrity services [RFC2743] are available on the established mechanism security context, then the negotiation is protected so the mechanism list hasn't been modified ๐Ÿ”’. When an attacker could have materially influenced the negotiation, peers swap message integrity code (MIC) tokens to confirm the mechanism list wasn't changed ๐Ÿ‘€. If no action of an attacker could have materially modified the outcome of the negotiation, then the exchange of MIC tokens is optional (see Section 5) ๐Ÿฆ‹. Letting MIC tokens be optional in this case gives you interoperability with existing implementations and still protects the negotiation โœจ. The tradeoff is more complexity ๐Ÿ˜ญ.

SPNEGO builds on the concepts from the GSS-API specification [RFC2743] ๐ŸŽ€. The negotiation data gets wrapped up in context-level tokens ๐Ÿง. So callers of the GSS-API don't need to know the negotiation tokens exist, they only need to know about the new pseudo-security mechanism ๐Ÿ’–. If the negotiation phase fails, a major status code gets returned: GSS_S_BAD_MECH ๐Ÿ’€.

2. Conventions Used in This Document ๐Ÿ“–

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119] ๐Ÿ’….

3. Negotiation Protocol ๐ŸŒˆ

When the established mechanism context provides integrity protection, the mechanism negotiation can be protected โœจ. When acquiring negotiated security mechanism tokens, SPNEGO always requests per-message integrity services ๐Ÿ”’.

When the established mechanism context supports per-message integrity services, SPNEGO guarantees that the selected mechanism is mutually preferred ๐Ÿ‘‘.

Here's how the negotiation process of this protocol works ๐Ÿงš.

3.1. Negotiation Description ๐Ÿซถ

The first negotiation token from the initiator has an ordered list of mechanisms in decreasing preference order (favorite mechanism first) ๐Ÿ“. It can also include the initial mechanism token for the initiator's preferred mechanism (the first one in the list), but that's optional ๐Ÿฆ‹. (Note that the list MUST NOT contain this SPNEGO mechanism itself, or any mechanism the client doesn't have appropriate credentials for ๐Ÿ™ˆ.)

Then the target processes the token from the initiator ๐ŸŽ€. This leads to one of four possible states (as defined in Section 4.2.2) being returned in the reply message: accept-completed, accept-incomplete, reject, or request-mic ๐Ÿ’–. A reject state ends the negotiation ๐Ÿ’€. An accept-completed state means the initiator-selected mechanism was acceptable to the target, and the security mechanism token in the first negotiation message was enough to finish authentication ๐ŸŽ‰. An accept-incomplete state means more message exchange is needed, but the MIC token exchange (as described in Section 5) is OPTIONAL ๐ŸŒธ. A request-mic state (which can only show up in the first reply message from the target) means the MIC token exchange is REQUIRED if per-message integrity services are available โญ.

Unless the application specifies the preference order, the way the target picks a mechanism is an implementation-specific, local matter ๐Ÿงš. Without an application-specified preference order or other policy, the target SHALL choose the first mechanism in the initiator's proposed list that it has valid credentials for ๐Ÿ‘‘.

If the negotiation works, the security mechanism in the first reply message is the value that's suitable for the target, picked from the list the initiator offered โœจ.

If the negotiation fails, the reject state is returned, and generating a context-level negotiation token is OPTIONAL ๐Ÿ’€.

Once a mechanism is selected, context establishment tokens specific to that mechanism get carried inside the negotiation tokens ๐Ÿฆ‹.

Last but not least, MIC tokens may be exchanged to make sure the target can trust the authenticity of the mechanism list it received ๐Ÿ”’.

To avoid conflicts with MIC token use by SPNEGO, partially-established contexts MUST NOT be used for per-message calls ๐Ÿšซ. To guarantee that, prot_ready_state [RFC2743] MUST be set to false on return from GSS_Init_sec_context() and GSS_Accept_sec_context(), even if the underlying mechanism returned true ๐Ÿ’….

Here's a key bit ๐Ÿ”ฅ. To avoid an extra round trip, the first context establishment token of the initiator's preferred mechanism SHOULD be embedded in the initial negotiation message (as defined in Section 4.2) โœจ. This document calls that the optimistic mechanism token ๐ŸŒˆ. Using the optimistic mechanism token also lets the initiator recover from non-fatal errors it hits while producing the first mechanism token, before a mechanism has been selected ๐Ÿซถ. If the acceptor probably won't pick the initiator's preferred mechanism because generating its token is really expensive, implementations MAY leave out the optimistic mechanism token ๐Ÿง.


3.2. Negotiation Procedure โœจ

okay so the basic version of this procedure assumes per-message integrity services are available on the established mechanism context ๐Ÿ”. here's the flow in five steps, bestie:

a) The GSS-API initiator calls GSS_Init_sec_context() like normal, but asks for SPNEGO to be used. SPNEGO can either be explicitly requested or accepted as the default mechanism ๐Ÿ’…

b) The initiator GSS-API implementation builds a negotiation token listing one or more security mechanisms that are available based on the credentials used for this context establishment, and optionally on the initial mechanism token for the first mechanism in the list ๐Ÿงš

c) The GSS-API initiator application sends the token to the target application. The target passes it along by invoking GSS_Accept_sec_context(), and the acceptor will do one of the following (it's giving decision tree ๐ŸŒณ):

  • I) If none of the proposed mechanisms are acceptable, the negotiation SHALL be terminated. GSS_Accept_sec_context indicates GSS_S_BAD_MECH. The acceptor MAY output a negotiation token containing a reject state.
  • II) If either the initiator's preferred mechanism is not accepted by the target, or this mechanism is accepted but is not the acceptor's most preferred mechanism (so the MIC token exchange described in Section 5 is required), GSS_Accept_sec_context() indicates GSS_S_CONTINUE_NEEDED. The acceptor MUST output a negotiation token containing a request-mic state ๐Ÿ™ˆ
  • III) Otherwise, if at least one additional negotiation token from the initiator is needed to establish this context, GSS_Accept_sec_context() indicates GSS_S_CONTINUE_NEEDED and outputs a negotiation token containing an accept-incomplete state.
  • IV) Otherwise, no additional negotiation token from the initiator is needed to establish this context, so GSS_Accept_sec_context() indicates GSS_S_COMPLETE and outputs a negotiation token containing an accept_complete state ๐Ÿ‘‘

If the initiator's preferred mechanism is accepted, and an optimistic mechanism token was included, this mechanism token MUST be passed to the selected mechanism by invoking GSS_Accept_sec_context(). If a response mechanism token is returned, it MUST be included in the response negotiation token. Otherwise, the target will not generate a response mechanism token in the first reply.

d) The GSS-API target application returns the negotiation token to the initiator application. The initiator passes it by invoking GSS_Init_sec_context(). The security context initialization then continues according to the standard GSS-API conventions for the selected mechanism, where the tokens of the selected mechanism are encapsulated in negotiation messages (see Section 4) until GSS_S_COMPLETE is returned for both the initiator and the target by the selected security mechanism ๐Ÿฆ‹

e) MIC tokens are then either skipped or exchanged according to Section 5.

Note that the *_req_flag input parameters for context establishment are relative to the selected mechanism, as are the *_state output parameters. That is, these parameters are not applicable to the negotiation process per se.

On receipt of a negotiation token on the target side, a GSS-API implementation that does not support negotiation would indicate GSS_S_BAD_MECH, as though a particular basic security mechanism had been requested and was not supported.

When a GSS-API credential is acquired for the SPNEGO mechanism, the implementation SHOULD produce a credential element for the SPNEGO mechanism. That element internally contains GSS-API credential elements for all mechanisms the principal has credentials for, except any mechanisms that are not to be negotiated per implementation-, site-, or application-specific policy. See Appendix B for interfaces for expressing application policy ๐ŸŒธ


4. Token Definitions ๐ŸŽ€

The type definitions in this section assume an ASN.1 module definition of the following form:

   SPNEGOASNOneSpec {
      iso(1) identified-organization(3) dod(6) internet(1)
      security(5) mechanism(5) snego (2) modules(4) spec2(2)
   } DEFINITIONS EXPLICIT TAGS ::= BEGIN

   -- rest of definitions here

   END

This specifies that the tagging context for the module will be explicit and non-automatic.

The encoding of the SPNEGO protocol messages shall obey the Distinguished Encoding Rules (DER) of ASN.1, as described in [X690].

4.1. Mechanism Types ๐Ÿฆ„

In this negotiation model, each OID represents one GSS-API mechanism or one variant (see Section 6) of it, according to [RFC2743].

   MechType ::= OBJECT IDENTIFIER
       -- OID represents each security mechanism as suggested by
       -- [RFC2743]

   MechTypeList ::= SEQUENCE OF MechType

4.2. Negotiation Tokens ๐Ÿ’Œ

The syntax of the initial negotiation tokens follows the initialContextToken syntax defined in Section 3.1 of [RFC2743]. The SPNEGO pseudo mechanism is identified by the Object Identifier iso.org.dod.internet.security.mechanism.snego (1.3.6.1.5.5.2). Subsequent tokens MUST NOT be encapsulated in this GSS-API generic token framing.

This section specifies the syntax of the inner token for the initial message and the syntax of subsequent context establishment tokens.

   NegotiationToken ::= CHOICE {
       negTokenInit    [0] NegTokenInit,
       negTokenResp    [1] NegTokenResp
   }

4.2.1. negTokenInit ๐ŸŒท

   NegTokenInit ::= SEQUENCE {
       mechTypes       [0] MechTypeList,
       reqFlags        [1] ContextFlags  OPTIONAL,
         -- inherited from RFC 2478 for backward compatibility,
         -- RECOMMENDED to be left out
       mechToken       [2] OCTET STRING  OPTIONAL,
       mechListMIC     [3] OCTET STRING  OPTIONAL,
       ...
   }
   ContextFlags ::= BIT STRING {
       delegFlag       (0),
       mutualFlag      (1),
       replayFlag      (2),
       sequenceFlag    (3),
       anonFlag        (4),
       confFlag        (5),
       integFlag       (6)
   } (SIZE (32))

This is the syntax for the inner token of the initial negotiation message.

mechTypes: This field contains one or more security mechanisms available for the initiator, in decreasing preference order (favorite choice first).

reqFlags: This field, if present, contains the service options that are requested to establish the context (the req_flags parameter of GSS_Init_sec_context()). This field is inherited from RFC 2478 and is not integrity protected. For implementations of this specification, the initiator SHOULD omit this reqFlags field and the acceptor MUST ignore this reqFlags field.

The size constraint on the ContextFlags ASN.1 type only applies to the abstract type. The ASN.1 DER requires that all trailing zero bits be truncated from the encoding of a bit string type whose abstract definition includes named bits. Implementations should not expect to receive exactly 32 bits in an encoding of ContextFlags.

mechToken: This field, if present, contains the optimistic mechanism token.

mechlistMIC: This field, if present, contains an MIC token for the mechanism list in the initial negotiation message. This MIC token is computed according to Section 5.

4.2.2. negTokenResp ๐Ÿฆ‹

   NegTokenResp ::= SEQUENCE {
       negState       [0] ENUMERATED {
           accept-completed    (0),
           accept-incomplete   (1),
           reject              (2),
           request-mic         (3)
       }                                 OPTIONAL,
         -- REQUIRED in the first reply from the target
       supportedMech   [1] MechType      OPTIONAL,
         -- present only in the first reply from the target
       responseToken   [2] OCTET STRING  OPTIONAL,
       mechListMIC     [3] OCTET STRING  OPTIONAL,
       ...
   }

This is the syntax for all subsequent negotiation messages.

negState: This field, if present, contains the state of the negotiation. This can be:

  • accept-completed: No further negotiation message from the peer is expected, and the security context is established for the sender.
  • accept-incomplete: At least one additional negotiation message from the peer is needed to establish the security context.
  • reject: The sender terminates the negotiation.
  • request-mic: The sender indicates that the exchange of MIC tokens, as described in Section 5, will be REQUIRED if per-message integrity services are available on the mechanism context to be established. This value SHALL only be present in the first reply from the target.

This field is REQUIRED in the first reply from the target, and is OPTIONAL thereafter. When negState is absent, the actual state should be inferred from the state of the negotiated mechanism context.

supportedMech: This field SHALL only be present in the first reply from the target. It MUST be one of the mechanism(s) offered by the initiator.

ResponseToken: This field, if present, contains tokens specific to the mechanism selected.

mechlistMIC: This field, if present, contains an MIC token for the mechanism list in the initial negotiation message. This MIC token is computed according to Section 5.

5. Processing of mechListMIC ๐ŸŽ€

okay so first things first: if the mechanism that got picked doesn't support integrity protection, then there's no mechlistMIC token at all. nothing to check, no drama ๐Ÿ’…

Otherwise, if the accepted mechanism is the most preferred mechanism of BOTH the initiator and the acceptor, then the MIC token exchange (we'll get to it in this section) is OPTIONAL ๐ŸŒธ A mechanism counts as the acceptor's most preferred one if there's no other mechanism the acceptor would have preferred over the accepted one had that other mechanism been in the mechanism list.

In all other cases, MIC tokens MUST be exchanged after the mechanism context is fully established ๐Ÿ”ฅ

a) The mechlistMIC token (or just the MIC token) gets computed over the mechanism list in the initial negotiation message by calling GSS_GetMIC() like this: the input context_handle is the established mechanism context, the input qop_req is 0, and the input message is the DER encoding of the value of type MechTypeList, which lives in the "mechTypes" field of the NegTokenInit. The input message is NOT the DER encoding of the type [0] MechTypeList. not the same thing at all, bestie ๐Ÿ™ˆ

b) okay this one's a whole thing. If the selected mechanism exchanges an even number of mechanism tokens (meaning the acceptor sends the last mechanism token), then the acceptor does the following when it generates the negotiation message that has the last mechanism token:

  • if the MIC token exchange is optional, GSS_Accept_sec_context() either indicates GSS_S_COMPLETE and does not include a mechlistMIC token, or indicates GSS_S_CONTINUE_NEEDED and includes a mechlistMIC token and an accept-incomplete state
  • if the MIC token exchange is required, GSS_Accept_sec_context() indicates GSS_S_CONTINUE_NEEDED and includes a mechlistMIC token

Acceptors that want to play nice with legacy Windows SPNEGO implementations (see Appendix C) should not generate a mechlistMIC token when the MIC token exchange is not required ๐Ÿซถ Then the initiator processes the last mechanism token and does one of the following:

  • I) If a mechlistMIC token was included and is correctly verified, GSS_Init_sec_context() indicates GSS_S_COMPLETE. The output negotiation message contains a mechlistMIC token and an accept_complete state. The acceptor MUST then verify this mechlistMIC token.
  • II) If a mechlistMIC token was included but is incorrect, the negotiation SHALL be terminated. GSS_Init_sec_context() indicates GSS_S_DEFECTIVE_TOKEN.
  • III) If no mechlistMIC token was included and the MIC token exchange is not required, GSS_Init_sec_context() indicates GSS_S_COMPLETE with no output token.
  • IV) If no mechlistMIC token was included but the MIC token exchange is required, the negotiation SHALL be terminated. GSS_Accept_sec_context() indicates GSS_S_DEFECTIVE_TOKEN.

c) Now the odd-number case, where the chosen mechanism exchanges an odd number of mechanism tokens (meaning the initiator sends the last one). The initiator does the following when it generates the negotiation message containing the last mechanism token: if the negState was request-mic in the first reply from the target, a mechlistMIC token MUST be included; otherwise, the mechlistMIC token is OPTIONAL. (heads up: the MIC token exchange is required if a mechanism other than the initiator's first choice gets chosen ๐Ÿ‘€) In the case that the optimistic mechanism token is the only mechanism token for the initiator's preferred mechanism, the mechlistMIC token is OPTIONAL. Whether or not the mechlistMIC token is included, GSS_Init_sec_context() indicates GSS_S_CONTINUE_NEEDED. Initiators that want to be compatible with legacy Windows SPNEGO implementations (see Appendix C) should not generate a mechlistMIC token when the MIC token exchange is not required. Then the acceptor processes the last mechanism token and does one of the following:

  • I) If a mechlistMIC token was included and is correctly verified, GSS_Accept_sec_context() indicates GSS_S_COMPLETE. The output negotiation message contains a mechlistMIC token and an accept_complete state. The initiator MUST then verify this mechlistMIC token.
  • II) If a mechlistMIC token was included but is incorrect, the negotiation SHALL be terminated. GSS_Accept_sec_context() indicates GSS_S_DEFECTIVE_TOKEN.
  • III) If no mechlistMIC token was included and the mechlistMIC token exchange is not required, GSS_Accept_sec_context() indicates GSS_S_COMPLETE. The output negotiation message contains an accept_complete state.
  • IV) In the case that the optimistic mechanism token is also the last mechanism token (when the initiator's preferred mechanism is accepted by the target) and the target sends a request-mic state but the initiator did not send a mechlistMIC token, the target then MUST include a mechlistMIC token in that first reply. GSS_Accept_sec_context() indicates GSS_S_CONTINUE_NEEDED. The initiator MUST verify the received mechlistMIC token and generate a mechlistMIC token to send back to the target. The target SHALL, in turn, verify the returned mechlistMIC token and complete the negotiation.
  • V) If no mechlistMIC token was included and the acceptor sent a request-mic state in the first reply message (the exchange of MIC tokens is required), the negotiation SHALL be terminated. GSS_Accept_sec_context() indicates GSS_S_DEFECTIVE_TOKEN.

6. Extensibility ๐Ÿงš

Two mechanisms are provided for extensibility, and yes, I'm obsessed ๐Ÿ˜ญ First, the ASN.1 structures in this specification MAY be expanded by IETF standards action. Implementations receiving unknown fields MUST ignore these fields.

Secondly, OIDs corresponding to a desired mechanism attribute (aka mechanism variants) MAY be included in the set of preferred mechanisms by an initiator. The acceptor can choose to honor this request by preferring mechanisms that have the included attributes. Future work within the Kitten working group is expected to standardize common attributes that SPNEGO mechanisms may wish to support. At this time, it's enough to say that initiators MAY include OIDs that do not correspond to mechanisms. Such OIDs MAY influence the acceptor's choice of mechanism. As discussed in Section 5, if there are mechanisms that, if present in the initiator's list of mechanisms, might be preferred by the acceptor instead of the initiator's preferred mechanism, the acceptor MUST demand the MIC token exchange. As the consequence, acceptors MUST demand the MIC token exchange if they support negotiation of attributes not available in the initiator's preferred mechanism, regardless of whether the initiator actually requested these attributes. it's giving protocol-level accountability ๐Ÿ’€


7. Security Considerations ๐Ÿ”ฅ

โš ๏ธ this section is serious, so read it carefully, bestie.

In order to produce the MIC token for the mechanism list, the mechanism must provide integrity protection. When the selected mechanism does not support integrity protection, the negotiation is vulnerable: an active attacker can force it to use a security mechanism that is not mutually preferred but is acceptable to the target.

This protocol provides the following guarantees when per-message integrity services are available on the established mechanism context, and the mechanism list was altered by an adversary such that a mechanism that is not mutually preferred could be selected:

a) If the last mechanism token is sent by the initiator, both peers shall fail;

b) If the last mechanism token is sent by the acceptor, the acceptor shall not complete and the initiator, at worst, shall complete with its preferred mechanism being selected.

The negotiation may not be terminated if an alteration was made but had no material impact.

The protection of the negotiation depends on the strength of the integrity protection. In particular, the strength of SPNEGO is no stronger than the integrity protection of the weakest mechanism acceptable to GSS-API peers. so the chain is only as strong as its weakest link, fr fr ๐Ÿ’”

Note that where there exist multiple mechanisms with similar context tokens, but different semantics, such that some or all of the mechanisms' context tokens can be easily altered so that one mechanism's context tokens may pass for another of the similar mechanism's context tokens, then there may exist a downgrade or similar attacks. For example, if a given family of mechanisms uses the same context token syntax for two or more variants and depends on the OID in the initial token's pseudo-ASN.1/DER wrapper, but does not provide integrity protection for that OID, then there may exist an attack against those mechanisms. SPNEGO does not generally defeat such attacks. ngl this is the scary part ๐Ÿ˜ฑ

In all cases, the communicating peers are exposed to the denial of service threat.


8. Acknowledgments ๐ŸŒˆ

The authors wish to thank Sam Hartman, Nicolas Williams, Ken Raeburn, Martin Rex, Jeff Altman, Tom Yu, Cristian Ilac, Simon Spero, and Bill Sommerfeld for their comments and suggestions during the development of this document. the real ones ๐Ÿซถ

Luke Howard provided a prototype of this protocol in Heimdal and resolved several issues in the initial version of this document. iconic behavior โœจ

Eric Baize and Denis Pinkas wrote the original SPNEGO specification [RFC2478] of which some of the text has been retained in this document. the OG legends ๐Ÿ‘‘


9. References ๐Ÿ“š

9.1. Normative References

[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
          Requirement Levels", BCP 14, RFC 2119, March 1997.

[RFC2743] Linn, J., "Generic Security Service Application Program
          Interface Version 2, Update 1", RFC 2743, January 2000.

[X690]    ASN.1 encoding rules: Specification of Basic Encoding Rules
          (BER), Canonical Encoding Rules (CER) and Distinguished
          Encoding Rules (DER), ITU-T Recommendation X.690 (1997) |
          ISO/IEC International Standard 8825-1:1998.

9.2. Informative References

[RFC2478] Baize, E. and D. Pinkas, "The Simple and Protected GSS-API
          Negotiation Mechanism", RFC 2478, December 1998.

Appendix A. SPNEGO ASN.1 Module โœจ

okay so this one's the actual ASN.1 module for SPNEGO, the grammar every message in the spec gets built from ๐Ÿงš it's written in a formal syntax so machines can read it, so don't stress if it looks like alphabet soup ๐Ÿ’€

SPNEGOASNOneSpec {
   iso(1) identified-organization(3) dod(6) internet(1)
   security(5) mechanism(5) snego (2) modules(4) spec2(2)
} DEFINITIONS EXPLICIT TAGS ::= BEGIN

MechType ::= OBJECT IDENTIFIER
    -- OID represents each security mechanism as suggested by
    -- [RFC2743]

MechTypeList ::= SEQUENCE OF MechType

NegotiationToken ::= CHOICE {
    negTokenInit    [0] NegTokenInit,
    negTokenResp    [1] NegTokenResp
}

NegTokenInit ::= SEQUENCE {
    mechTypes       [0] MechTypeList,
    reqFlags        [1] ContextFlags  OPTIONAL,
      -- inherited from RFC 2478 for backward compatibility,
      -- RECOMMENDED to be left out
    mechToken       [2] OCTET STRING  OPTIONAL,
    mechListMIC     [3] OCTET STRING  OPTIONAL,
    ...
}
NegTokenResp ::= SEQUENCE {
    negState       [0] ENUMERATED {
        accept-completed    (0),
        accept-incomplete   (1),
        reject              (2),
        request-mic         (3)
    }                                 OPTIONAL,
      -- REQUIRED in the first reply from the target
    supportedMech   [1] MechType      OPTIONAL,
      -- present only in the first reply from the target
    responseToken   [2] OCTET STRING  OPTIONAL,
    mechListMIC     [3] OCTET STRING  OPTIONAL,
    ...
}

ContextFlags ::= BIT STRING {
    delegFlag       (0),
    mutualFlag      (1),
    replayFlag      (2),
    sequenceFlag    (3),
    anonFlag        (4),
    confFlag        (5),
    integFlag       (6)
} (SIZE (32))

END

Appendix B. GSS-API Negotiation Support API ๐ŸŽ€

so the GSS-API caller (the initiator, the target, or both) needs a way to pick from the mechanisms on offer ๐Ÿ’… that's why there's a smaller set of mechanisms just for negotiation, plus two extra APIs:

  • GSS_Get_neg_mechs() tells the caller which security mechanisms are available on the local system for negotiation, limited to ones with appropriate credentials.
  • GSS_Set_neg_mechs() tells the local system which security mechanisms the caller should use for negotiation, for the given credentials.

B.1. GSS_Set_neg_mechs Call

this is the setter ๐Ÿ“

Inputs:

  • cred_handle CREDENTIAL HANDLE, -- NULL specifies default -- credentials
  • mech_set SET OF OBJECT IDENTIFIER

Outputs:

  • major_status INTEGER,
  • minor_status INTEGER

Return major_status codes:

  • GSS_S_COMPLETE indicates that the set of security mechanisms available for negotiation has been set to mech_set.
  • GSS_S_FAILURE indicates that the requested operation could not be performed for reasons unspecified at the GSS-API level.

this lets callers pick which mechanisms can be negotiated with the credential named by cred_handle ๐Ÿฆ‹ it's mostly for specialized callers who want to cut the list down from everything the caller could theoretically use (based on what credentials they have). also, if you put more than one mechanism in mech_set, the order you list them in is the preference order, so first = favourite ๐Ÿ‘‘

B.2. GSS_Get_neg_mechs Call

this is the getter, the other half of the pair ๐Ÿงš

Input:

  • cred_handle CREDENTIAL HANDLE -- NULL specifies default -- credentials

Outputs:

  • major_status INTEGER,
  • minor_status INTEGER,
  • mech_set SET OF OBJECT IDENTIFIER

Return major_status codes:

  • GSS_S_COMPLETE indicates that the set of security mechanisms available for negotiation has been returned in mech_set.
  • GSS_S_FAILURE indicates that the requested operation could not be performed for reasons unspecified at the GSS-API level.

this one lets callers find out which mechanisms are available for negotiation with the credential named by cred_handle โœจ same deal, it's for specialized callers who want to trim the list down from the supported mechanisms that their credentials can actually use.

Note: GSS_Indicate_mechs() gives you the full list of mechanism types on the local system. This call takes no input parameter, so what it returns isn't necessarily available for every credential. ngl that's a bit of a trap if you're not paying attention ๐Ÿ™ˆ

Appendix C. Changes since RFC 2478 ๐Ÿ’œ

okay this part is the tea โ˜• SPNEGO implementations in Microsoft Windows 2000, Windows XP and Windows Server 2003 behave in a few ways that the spec doesn't like: no mechlistMIC gets produced, and one is ignored if it's sent anyway. if the initiator sends the last mechanism token, the acceptor sends back a negotiation token with an accept_complete state and no mechlistMIC token. also, the wrong OID (1.2.840.48018.1.2.2) can be used to identify the GSS-API Kerberos Version 5 mechanism ๐Ÿ’€

these changes are here so things stay compatible with those legacy implementations:

  • NegTokenTarg became negTokenResp, and it's the message format for every negotiation token after the first one.
  • NegTokenInit is the message for the initial negotiation message, and only that message.
  • mechTypes in negTokenInit is not optional.
  • If the selected mechanism is also the most preferred mechanism for both peers, it's safe to leave out the MIC tokens.

if at least one of the two peers implements the updated pseudo mechanism in this document, the negotiation is protected ๐Ÿ”’

these changes fix problems from RFC 2478:

  • reqFlags isn't protected, so it shouldn't affect the negotiation.
  • DER encoding is required.
  • The input to GSS_GetMIC() is clarified.
  • Per-message integrity services are requested for the negotiated mechanism.
  • Two MIC tokens are exchanged, one in each direction.

okay now the spicy bit ๐ŸŒถ๏ธ an implementation that follows this spec will not inter-operate with a strict RFC 2748 implementation. even if the new one always sends a mechlistMIC token, it still fails to inter-operate. if it's a server, it fails because it asks for a mechlistMIC token using an option older implementations don't support. clients will probably fail too.

there was another option: the authors could have documented a correct behaviour that's fully backward compatible with RFC 2478, plus an appendix on how to interoperate with the existing incorrect RFC 2478 implementations. ๐Ÿค”

in practice, the SPNEGO implementers in the IETF really valued interoperability with the Microsoft implementations. they couldn't keep reasonable security guarantees, stay interoperable with the Microsoft implementations, and stay interoperable with correct RFC 2478 implementations all at the same time ๐Ÿ˜ญ

the working group didn't know of any RFC 2478 implementations deployed on the Internet. even if some exist, they probably won't interoperate, because of a critical flaw in how RFC 2478 describes encoding the mechanism list.

with the approach in this spec, security is ensured between new implementations all the time, and interoperability with the implementations deployed in the IETF community is kept. the working group thinks that's worth breaking compatibility with a correct RFC 2478 implementation ๐Ÿซถ

Appendix D. mechListMIC Computation Example ๐ŸŒˆ

this example shows how the mechListMIC field gets computed ๐Ÿงฎ

the start of the DER encoding of NegTokenInit is built like this (the "nn" are length encodings, which can be more than one octet long):

30 -- identifier octet for constructed SEQUENCE (NegTokenInit)
nn -- length

   -- contents octets of the SEQUENCE begin with
   -- DER encoding of "[0] MechTypeList":
   A0 -- identifier octet for constructed [0]
   nn -- length

       -- contents of the constructed [0] are DER encoding
       -- of MechTypeList (which is a SEQUENCE):
       30 -- identifier octet for constructed SEQUENCE
       nn -- length

          -- contents octets of the SEQUENCE begin with
          -- DER encoding of OBJECT IDENTIFIER:
          06 -- identifier octet for primitive OBJECT IDENTIFIER
          09 -- length
          2A 86 48 86 F7 12 01 02 02 -- Kerberos V5
                                     -- {1 2 840 113554 1 2 2}

if a mechlistMIC needs to be generated (following the rules in Section 5), it's computed by feeding the DER encoding of the MechTypeList from the initiator's NegTokenInit token into GSS_GetMIC(). in this case, the MIC gets computed over these octets:

DER encoding of MechTypeList:
30 nn 06 09 2A 86 48 86 F7 12 01 02 02 ...

note that the identifier octet and length octets for the constructed [0] (A0 nn) are not part of the MIC computation ๐Ÿ‘€

Authors' Addresses ๐Ÿง‘โ€๐Ÿ’ป

the people who wrote it, with their contact info:

Larry Zhu
Microsoft Corporation
One Microsoft Way
Redmond, WA  98052
US

EMail: lzhu@microsoft.com


Paul Leach
Microsoft Corporation
One Microsoft Way
Redmond, WA  98052
US

EMail: paulle@microsoft.com


Karthik Jaganathan
Microsoft Corporation
One Microsoft Way
Redmond, WA  98052
US

EMail: karthikj@microsoft.com


Wyllys Ingersoll
Sun Microsystems
1775 Wiehle Avenue, 2nd Floor
Reston, VA  20190
US

EMail: wyllys.ingersoll@sun.com

Copyright (C) The Internet Society (2005).

this document is subject to the rights, licenses and restrictions contained in BCP 78, and except as set forth there, the authors keep all their rights.

this document and the information in it are provided on an "AS IS" basis. THE CONTRIBUTOR, THE ORGANIZATION HE/SHE REPRESENTS OR IS SPONSORED BY (IF ANY), THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT USING THE INFORMATION HEREIN WILL NOT INFRINGE ANY RIGHTS, AND ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.

Intellectual Property ๐Ÿ’ผ

the IETF takes no position on the validity or scope of any Intellectual Property Rights or other rights that might be claimed to pertain to implementing or using the technology in this document, or on whether any licence under those rights might or might not be available. it also doesn't claim to have made any independent effort to identify such rights. info on the procedures for rights in RFC documents is in BCP 78 and BCP 79.

copies of IPR disclosures made to the IETF Secretariat, any assurances of licences to be made available, or the results of an attempt to get a general licence or permission to use those proprietary rights by implementers or users of this specification can be obtained from the IETF on-line IPR repository at http://www.ietf.org/ipr.

the IETF invites any interested party to bring to its attention any copyrights, patents or patent applications, or other proprietary rights that may cover technology needed to implement this standard. please send that info to the IETF at ietf-ipr@ietf.org.

Acknowledgement ๐ŸŒธ

funding for the RFC Editor function is currently provided by the Internet Society. and that's the whole doc, bestie ๐Ÿ’–๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from