<?xml version="1.0" encoding="UTF-8"?>
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc tocindent="no"?>
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc tocindent="no"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [
<!ENTITY rfc2119 PUBLIC "" "http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY rfc2743 PUBLIC "" "http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2743.xml">
<!ENTITY rfc2744 PUBLIC "" "http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.2744.xml">
<!ENTITY rfc4120 PUBLIC "" "http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.4120.xml">
<!ENTITY rfc4121 PUBLIC "" "http://xml2rfc.tools.ietf.org/public/rfc/bibxml/reference.RFC.4121.xml">
<!ENTITY x680 PUBLIC "" "http://xml2rfc.tools.ietf.org/public/rfc/bibxml2/reference.CCITT.X680.2002.xml">
<!ENTITY x690 PUBLIC "" "http://xml2rfc.tools.ietf.org/public/rfc/bibxml2/reference.CCITT.X690.2002.xml">
]>
<rfc docName="draft-williams-kitten-krb5-extra-rt-02" ipr="trust200902" category="std" updates="4121">
  <front>
    <title abbrev="Kerberos Extra AP">Negotiation of Extra Security Context Tokens for Kerberos V5 Generic Security Services Mechanism</title>
    <author initials="N." surname="Williams" fullname="Nicolas Williams">
      <organization abbrev="Cryptonector">Cryptonector, LLC</organization>
      <address>
        <email>nico@cryptonector.com</email>
      </address>
    </author>
    <author initials="R." surname="Dowdeswell" fullname="Roland Charles Dowdeswell">
      <organization abbrev="Dowdeswell Security Architecture">Dowdeswell Security Architecture</organization>
      <address>
        <email>elric@imrryr.org</email>
      </address>
    </author>
    <date month="October" year="2014"/>
    <area>
Security Area
</area>
    <keyword>Internet-Draft</keyword>
    <abstract>
      <t>
This Internet-Draft proposes an extension to the Kerberos V5 security mechanism for the Generic Security Services Application Programming Interface (GSS-API) for using extra security context tokens in order to recover from certain errors. Other benefits include: user-to-user authentication, authenticated errors, replay cache avoidance, and others.</t>
    </abstract>
  </front>
  <middle>
    <section title="Introduction" anchor="d1e249">
      <t>
The Kerberos V5 <xref target="RFC4120"/> AP protocol, and therefore the Kerberos V5 GSS mechanism <xref target="RFC4121"/> security context token exchange, is a one-round trip protocol. Occasionally there are errors that the protocol could recover from by using an additional round trip, but until now there was no way to execute such an additional round trip. For many application protocols the failure of the Kerberos AP protocol is fatal, requiring closing TCP connections and starting over; often there is no automatic recovery. This document proposes a negotiation of additional security context tokens for automatic recovery from certain errors. This is done in a backwards-compatible way, thus retaining the existing mechanism OID for the Kerberos V5 GSS mechanism. Additionally we add support for user-to-user authentication and authenticated errors, and provide a way to avoid the need for replay caching.</t>
      <section title="Conventions used in this document" anchor="d1e270">
        <t>
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 <xref target="RFC2119"/>.</t>
      </section>
    </section>
    <section title="Negotiation" anchor="d1e286">
      <t>
We introduce the following new protocol elements. A partial ASN.1 <xref target="CCITT.X680.2002"/> module (for inclusion in the base Kerberos ASN.1 module) is given in  <xref target="sub_ASN_1_for_New"/>, and references to its contents are made below.</t>
      <t>
        <list style="symbols">
          <t>
a new ap-options flag for use in the clear-text part of AP-REQs to indicate the desire for an extra round trip if need be;</t>
          <t>
a new Authorization-Data element for use in Authenticators for quoting back a challenge nonce from the acceptor;</t>
          <t>
a new PDU: KRB-ERROR2, with additional fields and support for authenticated errors.</t>
        </list>
      </t>
      <t>
No new interface is needed for GSS-API applications to use this feature.</t>
      <t>
To use this feature, the Kerberos GSS mechanism MUST act as follows:</t>
      <t>
        <list style="symbols">
          <t>
To request this feature, initiators SHALL add the new ap-options flag to their AP-REQs.</t>
          <t>
Acceptors that wish to request an additional security context token can only do so when initiators indicate support for it, and MUST do so by returning a KRB-ERROR2. The encrypted part of the KRB-ERROR2 SHALL be encrypted in one of the following keys: the sub-session key from the AP-REQ's Authenticator if it could be decrypted, else the session key from the Ticket, if it could be decrypted, else the null enc-type/key.</t>
          <t>
The KRB-ERROR2 in this case SHALL have a the continue-needed e-flag set when the acceptor is willing to consume another security context token from the initiator; the acceptor SHALL also return GSS_S_CONTINUE_NEEDED to the application in this case.</t>
          <t>
Initiators that request this feature and receive a KRB-ERROR2 SHOULD attempt to recover.</t>
          <t>
Initiators that request this feature and receive a KRB-ERROR2 with the continue-needed e-flag set SHOULD attempt to recover and MAY produce a token to send to the acceptor: either a KRB-ERROR2 if the initiator failed to recover, or a new AP-REQ (with the traditional GSS-API pseudo-ASN.1 mechanism OID header).

<list style="symbols"><t>
In the successful recovery case the initiator MUST quote the nonce from the KRB-ERROR2 using an AD-CHALLENGE-RESPONSE-NONCE (see below) authorization data element.</t></list>
</t>
          <t>
When it consumes a KRB-ERROR2, GSS_Init_sec_context() can return an error (GSS_S_FAILURE), or attempt recovery and output a new AP-REQ security context token.

<list style="symbols"><t>
When GSS_Init_sec_context() outputs a new AP-REQ security context token, it SHALL return GSS_S_CONTINUE_NEEDED if the application requested mutual authentication, else it SHALL return GSS_S_COMPLETE.</t><t>
When GSS_Init_sec_context() returns an error and the acceptor is awaiting a security context token, GSS_Init_sec_context() MAY generate a KRB-ERROR to send to the acceptor.</t></list>
</t>
          <t>
Acceptors MUST reject additional AP-REQs which do not have a challenge response nonce matching the one sent by the acceptor in the previous KRB-ERROR2.</t>
          <t>
Acceptors MUST reject initial security context tokens that contain a challenge response nonce.</t>
        </list>
      </t>
      <section title="Error Recovery" anchor="d1e358">
        <t>
The following Kerberos errors can be recovered from automatically using this protocol:</t>
        <t>
          <list style="symbols">
            <t>
KRB_AP_ERR_TKT_EXPIRED: the initiator should get a new service ticket;</t>
            <t>
KRB_AP_ERR_TKT_NYV: the initiator should get a new service ticket;</t>
            <t>
KRB_AP_ERR_REPEAT: the initiator should build a new AP-REQ;</t>
            <t>
KRB_AP_ERR_SKEW: the initiator should build a new AP-REQ with time corrected for the offset between the initiator's and acceptor's clocks;</t>
            <t>
KRB_AP_ERR_BADKEYVER: the initiator should get a new service ticket;</t>
            <t>
KRB_AP_PATH_NOT_ACCEPTED: the initiator should get a new service ticket using a different transit path;</t>
            <t>
KRB_AP_ERR_INAPP_CKSUM: the initiator should try again with a different checksum type.</t>
          </list>
        </t>
        <t>
Error codes that denote PDU corruption (and/or an active attack) can also be recovered from by attempting a new AP-REQ:</t>
        <t>
          <list style="symbols">
            <t>
KRB_AP_ERR_BAD_INTEGRITY</t>
            <t>
KRB_AP_ERR_BADVERSION</t>
            <t>
KRB_AP_ERR_BADMATCH</t>
            <t>
KRB_AP_ERR_MSG_TYPE</t>
            <t>
KRB_AP_ERR_MODIFIED</t>
          </list>
        </t>
        <t>
Other error codes that may be recovered from:</t>
        <t>
          <list style="symbols">
            <t>
KRB_AP_ERR_BADADDR; the acceptor SHOULD include a list of one or more client network addresses as reported by the operating system, but if the acceptor does not then the continue-needed e-flag MUST NOT be included and the error must be final.</t>
          </list>
        </t>
      </section>
      <section title="Number of Security Context Tokens" anchor="d1e416">
        <t>
The first AP-REQ may well result in an error; the second should not. Therefore acceptors SHOULD return a fatal error when a second error results in one security context establishment attempt, except when the first error is that the initiator should use user-to-user authentication. This limits the maximum number of round trips to two (not user-to-user) or three (user-to-user).</t>
        <t>
Initiators and acceptors MUST impose some limit on the maximum number of security context tokens. For the time being that limit is six.</t>
        <t>
An initiator that rejects an additional round trip MUST respond with a KRB-ERROR2.</t>
        <t>
Note that in the user-to-user cases (see  <xref target="sub_User_to_User_Authentication"/>) it's possible to have up to three round trips under normal conditions if, for example, the acceptor wishes to avoid the use of replay caches (see  <xref target="sub_Replay_Cache_Avoidance"/>), or if the initiator's clock is too skewed, for example.</t>
      </section>
      <section title="PROT_READY" anchor="d1e440">
        <t>
It is REQUIRED that each AP-REQ in a security context token exchange replace the sub-session key to be used for PROT_READY per-message tokens. This can conceivably cause failure-to-verify/unwrap errors for some applications (e.g., using datagram transports), but none that they shouldn't have been prepared to handle.</t>
        <section title="Negotiation Issues for User-to-User Authentication" anchor="d1e534">
          <t>
Initiator applications that can negotiate security mechanisms and which have available an existing user-to-user mechanism <xref target="I-D.swift-win2k-krb-user2user"/> as well as the Kerberos V5 GSS mechanism with the user-to-user extension defined here will have a problem: they may end up negotiating the use of the Kerberos V5 GSS mechanism and fail to establish a security context because the acceptor does not support the features defined in this document, but the application might have succeeded if it had selected the user-to-user mechanism.</t>
          <t>
            <cref>
Question: how should we address this? We could say “give priority to the user-to-user mechanism”, but in some cases that might require changes to the acceptor side.</cref>
          </t>
        </section>
      </section>
    </section>
    <section title="ASN.1 for New Protocol Elements" anchor="sub_ASN_1_for_New">
      <t>
A partial ASN.1 module appears below. This ASN.1 is to be used as if it were part of the base Kerberos ASN.1 module (see RFC4120), therefore the encoding rules to be used are the Distinguished Encoding Rules (DER) <xref target="CCITT.X690.2002"/>, and the environment is one of explicit tagging.</t>
      <t>
</t>
      <t>
        <figure anchor="magicparlabel-198" title="ASN.1 module (with explicit tagging)">
          <artwork> APOptions       ::= KerberosFlags
         -- reserved(0),
         -- use-session-key(1),
         -- mutual-required(2) 
         -- continue-needed-ok(TBD)
 
 ad-continue-nonce     Int32 ::= &lt;TBD&gt;
        -- ad-value is challenge nonce from KRB-ERROR2
 
 KrbErrorEncPartFlags ::= KerberosFlags
         -- reserved(0)  [XXX cargo cult!]
         -- use-initiator-subkey(1)
         -- use-ticket-session-key(2)
         -- use-null-enctype(3)
 
 KRB-ERROR2          ::= [APPLICATION &lt;TBD&gt;] SEQUENCE {
         pvno            [0] INTEGER (5),
         msg-type        [1] INTEGER (&lt;TBD&gt;),
         enc-part-key    [2] KrbErrorEncPartFlags,
         enc-part        [3] EncryptedData -- EncKRBErrorPart
 }
 
 ErrorFlags ::= KerberosFlags
         -- reserved(0)  [XXX sounds like cargo cult!]
         -- continue-needed(1)
 
 EncKRBErrorPart    ::= [APPLICATION &lt;TBD&gt;] SEQUENCE {
         challenge-nonce [0] OCTET STRING (16),
         stime           [1] KerberosTime,
         susec           [2] Microseconds,
         error-code      [3] Int32,
         e-flags         [4] ErrorFlags,
         e-text          [5] KerberosString OPTIONAL,
         e-data          [6] OCTET STRING OPTIONAL,
         e-typed-data    [7] TYPED-DATA OPTIONAL,
         tgt             [8] Ticket OPTIONAL, -- for user2user
         ...
 }</artwork>
        </figure>
      </t>
    </section>
    <section title="Replay Cache Avoidance" anchor="sub_Replay_Cache_Avoidance">
      <t>
By using an additional AP-REQ and a challenge/response nonce, this protocol is immune to replays of AP-REQ PDUs and does not need a replay cache. Acceptor implementations MUST not insert Authenticators from extra round trips into a replay cache when there are no other old implementations on the same host (and with access to the same acceptor credentials) that ignore critical authorization data or which don't know to reject initial AP-REQs that contain a challenge response nonce.</t>
      <t>
In the replay cache avoidance case where there's no actual error (e.g., time skew) the acceptor's KRB-ERROR2 will have KDC_ERR_NONE as the error code, with the continue-needed e-flag.</t>
    </section>
    <section title="User-to-User Authentication" anchor="sub_User_to_User_Authentication">
      <t>
There are two user2user authentication cases:</t>
      <t>
        <list style="numbers">
          <t>
the KDC only allows a service principal to use user2user authentication,</t>
          <t>
the service principal does not know its long-term keys or otherwise wants to use user2user authentication even though the KDC vended a service ticket.</t>
        </list>
      </t>
      <t>
In the first case the initiator knows this because the KDC returns KDC_ERR_MUST_USE_USER2USER. The initiator cannot make a valid AP-REQ in this case, yet it must send an AP-REQ or fail to make even an initial security context token. For this case we propose that the initiator make an AP-REQ with a Ticket with zero-length enc-part (and null enctype) and a zero-length authenticator (and null enctype). The acceptor will fail to process the AP-REQ, of course, and SHOULD respond with a continue-needed KRB-ERROR2 (using the null enc-type for the enc-part) that includes a TGT for the acceptor.</t>
      <t>
In the second case the initiator does manage to get a real service ticket for the acceptor but the acceptor nonetheless wishes to use user2user authentication.</t>
      <t>
In both cases the acceptor responds with a KRB-ERROR2 with the KRB_AP_ERR_USER_TO_USER_REQUIRED error code and including a TGT for itself.</t>
      <t>
In both cases the initiator then does a TGS request with a second ticket to get a new, user2user Ticket. Then the initiator makes a new AP-REQ using the new Ticket, and proceeds.</t>
    </section>
    <section title="Other Requirements, Recommendations, and Non-Requirements" anchor="d1e552">
      <t>
All error PDUs in an AP exchange where the AP-REQ has the continue-needed-ok ap-options flag MUST be KRB-ERROR2 PDUs.</t>
      <t>
Whenever an acceptor is able to decrypt the Ticket from an AP-REQ and yet wishes or has to output a KRB-ERROR2, then the enc-part of the KRB-ERROR2 MUST be encrypted in either the initiator's sub-session key (from the Authenticator) or the Ticket's session key (if the acceptor could not decrypt the Authenticator).</t>
    </section>
    <section title="Security Considerations" anchor="d1e564">
      <t>
This document deals with security.</t>
      <t>
There are a number of unauthenticated protocol elements: the continue-needed-ok flag that the initiator uses to indicate its willingness to have more than one round trip, and some errors. This is unavoidable.</t>
      <t>
The new KRB-ERROR2 PDU is cryptographically distinguished from the original mechanism's acceptor success security context token (AP-REQ).</t>
      <t>
Not every KRB-ERROR2 can be integrity protected.</t>
      <t>
Because in the base Kerberos V5 GSS-API security mechanism all errors are unauthenticated, and because even with this specification some elements are unauthenticated, it is possible for an attacker to cause one peer to think that the security context token exchange has failed while the other thinks it will continue. This can cause an acceptor to waste resources while waiting for additional security context tokens from the initiator. This is not really a new problem, however: acceptor applications should already have suitable timeouts on security context establishment.</t>
    </section>
    <section title="IANA Considerations" anchor="d1e586">
      <t>
        <cref>
Various allocations are required...</cref>
      </t>
    </section>
  </middle>
  <back>
    <references title="Normative References">&rfc2119;
&rfc2743;
&rfc2744;
&rfc4120;
&rfc4121;
&x680;
&x690;
</references>
    <references title="Informative References">
      <reference anchor="I-D.swift-win2k-krb-user2user">
        <front>
          <title>User to User Kerberos Authentication using GSS-API</title>
          <author initials="M." surname="Swift" fullname="Michael Swift">
            <organization/>
          </author>
          <author initials="J." surname="Brezak" fullname="John Brezak">
            <organization/>
          </author>
          <author initials="P." surname="Moore" fullname="Patrick Moore">
            <organization/>
          </author>
          <date month="February" day="21" year="2011"/>
          <abstract>
            <t>The security model of the web platform has evolved over time to meet the needs of new applications and to correct earlier mistakes. Although web security has evolved largely organically, the security model has converged towards a handful of key concepts. This document presents those concepts and provides advice to designers of new pieces of the web platform.</t>
          </abstract>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-swift-win2k-krb-user2user-03"/>
        <format type="TXT" target="http://www.ietf.org/internet-drafts/draft-swift-win2k-krb-user2user-03.txt"/>
      </reference>
    </references>
  </back>
</rfc>
