<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc text-list-sybols="o-*+"?>
<rfc category="std" docName="draft-song-ipsecme-seq-icv-01" ipr="trust200902">
  <front>
    <title abbrev="IPsec SEQ-ICV">
      IPsec sequence number integrity check value
    </title>

    <author fullname="Jifei Song" initials="J." surname="Song">
      <organization>Huawei Technologies</organization>
      <address>
        <email>jifei.song@huawei.com</email>
      </address>
    </author>
    <author fullname="Tina Tsou" initials="T." surname="Tsou">
      <organization>Huawei Technologies</organization>
      <address>
        <postal>
          <street>2330 Central Expressway</street>
          <city>Santa Clara</city>
          <country>USA</country>
        </postal>
        <phone>+1-408-330-4424</phone>
        <email>tina.tsou.zouting@huawei.com</email>
      </address>
    </author>
    <author fullname="Vishwas Manral" initials="V." surname="Manral">
      <organization>Hewlett-Packard Company</organization>
      <address>
        <postal>
          <street>3000 Hanover St.</street>
          <city>Palo Alto</city>
          <country>USA</country>
        </postal>
        <email>vishwas.manral@hp.com</email>
      </address>
    </author>

    <date day="8" month="July" year="2013" />

    <workgroup>IPSECME Working Group</workgroup>

    <keyword>IPsec, sequence number, ICV</keyword>

    <abstract>
      <t>This document specifies an IPsec AH and ESP sequence number validation scheme, which is complementary to the existing ICV mechanism and anti-replay mechanism of AH and ESP in defense against DOS attack. It is an optional feature negotiable through IKE, for this feature to be negotiated, both sender and receiver must implement it. If any party doesn't support it, then this feature should be excluded from negotiation. The rationale for such a scheme is discussed first; then requirements and guidelines for design of the scheme are laid out. There can be various ways to implement the scheme, 
some reference designs are discussed to set the base for effort of identifying best practice and eventually establishing a standard on the subject.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>As defense against replay attack, IPsec, both AH and ESP, uses anti-replay window to keep track of the sequence numbers of received packets, and reject packets with sequence number that is either too old (below anti-replay window) or duplicate (within anti-replay window, but marked as received).
Anti-replay window is not effective against DOS attack by packets with sequence number that are above anti-replay window, in which case the sequence number is neither considered too old, nor duplicate. Attack packets with sequence number above anti-replay window would penetrate anti-replay check and only be rejected after failing ICV check. The issue is that ICV check, which involves hashing operation, is rather expensive in terms of resource and time consumption. In case of ESP, when hardware crypto acceleration engine is used, ICV check and decryption often need to be performed together to optimize bandwidth efficiency, which makes the operation even more expensive. Large number of such packets would cause recevier's service degradation or interruption because significant amount of receiver's resource and time would be consumed by performing expensive ICV check on these packets.</t>

      <t>An inexpensive mechanism to check sequence number would allow rejecting such packets without causing service degradation or interruption. This check can be performed either before or after anti-replay check depending on policy and situation, but must be performed before ICV check. Such check doesn't have to be 100% accurate as long as it doesn't yield false positive result, i.e. mistaking correct sequence number as incorrect sequence number, since the packet with false negative result, i.e. incorrect sequence number passing the check, will be caught by ICV check eventually. But it must be significantly more resource and time efficient than ICV check to be beneficial.</t>

      <t>This check will increase packet length slightly, and incur slight computation overhead per packet, but greatly improve IPsec's capability to withstand DOS attack. This check would not be effective if attacker can prevent original packets from reaching destination, since in such case the attacker doesn't need to change sequence number, instead he or she can change payload, then the packet would pass both anti-replay check and this proposed sequence number check. But in order to shoot down original packets, attacker must compromise intermediate router. The proposed sequence number check is not designed to defend against attacks that involves compromised intermediate router, instead it is designed against attacks where attacker does not control intermediate router, but is able to obtain copy of original packets and launch attack by changing sequence number of the original packets to values that are greater so that anti-replay check would pass and ICV check is required. The latter is simpler attack and easier to carry out therefore is a more serious threat.</t>

      <t>This check is not designed for systems that are capable of line rate ICV check; instead it is designed for systems that are not capable of line rate ICV check. This check makes it possible for systems that are not capable of line rate ICV check to continue with normal function when under attacks, as long as the original packets are still being delivered, or in another words, as long as the network in between is not compromised. Systems that are capable of line rate ICV check should decline SEQ-ICV in negotiation.
      </t>

      <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">RFC 2119</xref>.</t>
    </section>

    <section title="SEQ-ICV">
      <t>SEQ-ICV is a 4 byte value generated by sender for each IPsec packet based on 4 byte packet sequence number, 12 byte ICV value, and 16 byte secret key known and only known to sender and receiver. The value is appended to immediately follow ICV and transmitted together with the packet to receiver, which generates its own value locally the same way as sender, then compares with the transmitted value. If the value is the same, then the sequence number is considered to be good, otherwise the sequence number is considered to be bad.</t>
	<t>Following figure illustrates AH header format with SEQ-ICV,</t>
<figure><artwork>

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   | Next Header   |  Payload Len  |          RESERVED             |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                 Security Parameters Index (SPI)               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                    Sequence Number Field                      |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |                                                               |
   +                Integrity Check Value-ICV (variable)           |
   |                                                               |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
   |        Sequence Number Integrity Check Value-SEQ-ICV          |
   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

</artwork></figure>
	<t>Following figure illustrates ESP packet format with SEQ-ICV,</t>
<figure><artwork>

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ----
|               Security Parameters Index (SPI)                 | ^Int.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Cov-
|                      Sequence Number                          | |ered
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ----
|                    Payload Data* (variable)                   | |   ^
~                                                               ~ |   |
|                                                               | |Conf.
+               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |Cov-
|               |     Padding (0-255 bytes)                     | |ered*
+-+-+-+-+-+-+-+-+               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |   |
|                               |  Pad Length   | Next Header   | v   v
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ------
|         Integrity Check Value-ICV   (variable)                |
~                                                               ~
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|        Sequence Number Integrity Check Value-SEQ-ICV          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

</artwork></figure>

<t>SEQ-ICV is generated as the following,</t>
<figure><artwork>

 	SEQ - sequence number, 4 bytes
	ICV - Integrity Check Value, 12 bytes
	K - secret key, 12 bytes
	
	SEQ-ICV = (SEQ + ICV[0-3]) ^ K[0-3] +
		    (SEQ + ICV[4-7]) ^ K[4-7] +
		    (SEQ + ICV[8-11]) ^ K[8-11]

</artwork></figure>

    </section>

    <section title="Outbound processing">
      <t>AH transport/tunnel mode</t>
        <t>
     <list style="numbers">
	<t>generate ICV</t>
        <t>generate SEQ-ICV</t>
	<t>adjust packet length in IP header</t>
      </list>
	</t>
<t>Packet length field can only be adjusted after generating ICV, since ICV must be based on the packet length without SEQ-ICV</t>

      <t>ESP transport/tunnel mode</t>
        <t>
     <list style="numbers">
	<t>encrypt packet payload</t>
        <t>generate ICV</t>
	<t>generate SEQ-ICV</t>
	<t>adjust packet length in IP header</t>      
	</list>
	</t>

      <t></t>
    </section>
    <section title="Inbound processing">
      <t>AH transport/tunnel mode</t>
         <t>
     <list style="numbers">
	<t>reject if failed anti-replay check</t>
        <t>generate SEQ-ICV</t>
	<t>Compare locally generated SEQ-ICV with received SEQ-ICV</t>
	<t>Reject packet if not same, otherwise adjust packet length field of IP header proceed to AH processing</t>
      </list>
	</t>
<t>Packet length field must be adjusted before AH processing</t>     
<t>ESP transport/tunnel mode</t>
        <t>
     <list style="numbers">
	<t>reject if failed anti-replay check</t>
        <t>generate SEQ-ICV</t>
	<t>Compare locally generated SEQ-ICV with received SEQ-ICV</t>
	<t>Reject packet if not same, otherwise proceed to ESP processing</t>
      </list>
	</t>
 <t>In calculating ESP payload length, SEQ-ICV must be excluded.</t>          

<t>Enable SEQ-ICV dynamically</t>
<t>If too many packets passed anti-replay but failed ICV check, then notify sender to enable SEQ-ICV, and receiver begins SEQ-ICV check but would not reject packets that failed SEQ-ICV check, 
once receiver no longer observes packets passing ICV check but failing SEQ-ICV check, then receiver considers SEQ-ICV has been enabled, and begins to reject packet that failed SEQ-ICV check.</t>
<t>Disable SEQ-ICV dynamically</t>
<t>If no packets passed anti-replay but failed SEQ-ICV, then notify sender to disable SEQ-ICV, and receiver stops rejecting packets that failed SEQ-ICV check,
once receiver no longer observes packets passing both SEQ-ICV and ICV check, but only packets passing ICV check, then receiver considers SEQ-ICV has been disabled, and stops checking SEQ-ICV </t>
<t>Following is summary of conditions that could occur throughout the whole process of dynamically enabling and disabling SEQ-ICV with assumption that original packets are delivered,</t>
<figure><artwork>
--------------------------------------------------------------
| id |condition | packet |anti-replay|SEQ-ICV| icv  | action |
|----|----------|--------|-----------|-------|------|--------|
|    | normal,  |original| pass      | skip  | pass | accept |
| 1  | SEQ-ICV  |        |           |       |      |        |
|    | disabled |        |           |       |      |        |
|----|----------|--------|-----------|-------|------|--------|
|    | under    |original| pass      | skip  | pass | accept |
|    | attack,  |        |           |       |      |        |
|    | SEQ-ICV  |        |           |       |      |        |
|    | disabled |        |           |       |      |        |
| 2  |----------|--------|-----------|-------|------|--------|
|    |under     | with   | pass	     | skip  | fail | reject |
|    |attack,   | fake   |           |       |      |        |
|    |SEQ-ICV   | seq    |           |       |      |        |
|    |disabled  |        |           |       |      |        |
|----|----------|--------|-----------|-------|------|--------|
|    | under    |original| pass	     |  fail | pass | accept |
|    | attack,  |        |           |	     |      |        |
|    | enabling |        |           |       |      |        |
|    | SEQ-ICV  |        |           |       |      |        |
| 3  |----------|--------|-----------|-------|------|--------|
|    | under    | with   | pass      |  fail | fail | reject |
|    | attack,  | fake   |           |	     |      |        |
|    | enabling | seq    |           |       |      |        |
|    | SEQ-ICV  |        |           |       |      |        |
|----|----------|--------|-----------|-------|------|--------|
|    | under    |original| pass      |  pass | pass | accept |
|    | attack,  |        |           |	     |	    |        |
|    | enabling |        |           |       |      |        |
|    | SEQ-ICV  |        |           |       |      |        |
|    | ready    |        |           |       |      |        |
| 4  |----------|--------|-----------|-------|------|--------|
|    | under    | with   | pass      | fail  | fail | reject |
|    | attack,  | fake   |           |       |      |        |
|    | enabling | seq    |           |       |      |        |
|    | SEQ-ICV  |        |           |       |      |        |
|    | ready    |        |           |       |      |        |
|----|----------|--------|-----------|-------|------|--------|
|    | under    |original| pass      |  pass | pass | accept |
|    | attack,  |        |           |       |      |        |
|    | SEQ-ICV  |        |           |       |      |        |
|    | enabled  |        |           |       |      |        |
| 5  |----------|--------|-----------|-------|------|--------|
|    | under    | with   | pass      |  fail | skip | reject |
|    | attack,  | fake   |           |       |      |        |
|    | SEQ-ICV  | seq    |           |       |      |        |
|    | enabled  |        |           |       |      |        |
|----|----------|--------|-----------|-------|------|--------|
|    | normal,  |original| pass      |  pass | pass | accept |
| 6  | SEQ-ICV  |        |           |       |      |        |
|    | enabled  |        |           |       |      |        |
|----|----------|--------|-----------|-------|------|--------|
|    | normal,  |original| pass      |  fail | pass | accept |
| 7  | disabling|        |           |       |      |        |
|    | SEQ-ICV  |        |           |       |      |        |
--------------------------------------------------------------
</artwork></figure>
<t> </t>
<t> </t>
<t>1 - normal, SEQ-ICV disabled</t>
<t>2 - under attack, SEQ-ICV disabled</t>
<t>3 - under attack, enabling SEQ-ICV</t>
<t>4 - under attack, enabling SEQ-ICV ready</t>
<t>5 - under attack, SEQ-ICV enabled</t>
<t>6 - normal, SEQ-ICV enabled</t>
<t>7 - normal, disabling SEQ-ICV</t>
<t>SEQ-ICV enabling process is 1 through 5</t>
<t>SEQ-ICV disabling process is 6 -> 7 -> 1</t>
    </section>
    <section title="IKE negotiation">
      <t>SEQ-ICV will be a type of transform used in AH/ESP.</t>
	<t>Following is list of transform IDs that will be defined for transform type of SEQ-ICV</t>
<figure><artwork>

Name                                              Number
----------------------------------------------------------
No SEQ-ICV                                          0
Static SEQ-ICV                                      1
Dynamic SEQ-ICV                                     2

</artwork></figure>
<t>Note that an initiator who supports SEQ-ICV will usually construct two proposal, one with SEQ-ICV transform, another without SEQ-ICV transform. It allows implementation that doesn't support SEQ-ICV to choose proposal without SEQ-ICV. In the proposal containing SEQ-ICV transform, an initiator will usually include at least two SEQ-ICV transforms, one with value "0", one with value "1" or "2". A proposal containing a single SEQ-ICV transform with value "1" or "2" means that SEQ-ICV must be used.</t>
<t>A Notify payload with Notify Message Type of SEQ-ICV_ENABLE in an Informational Exchange will be used to notify sender of SEQ-ICV enabling when receiver is under attack by packets with modified sequence number. </t>
    </section>

    <section anchor="IANA" title="IANA Considerations">
      <t>This document makes no request of IANA.</t>

      <t>Note to RFC Editor: this section may be removed on
      publication as an RFC.</t>
    </section>

    <section anchor="Security" title="Security Considerations">
      <t>
      </t>
      <t>
      </t>
      <t>
      </t>
      
      <t>
      <list style="symbols">
        <t></t>
        <t></t>
      </list>
      </t>

      <t>
      </t>
    </section>

    <section title="Acknowledgments">
      <t>Robert Moskowitz reminded us of importance of grammatical integrity.</t>
      <t>Tero Kivinen pointed out issue with original sample SEQ-ICV-4 generation algorithm and provided insightful feedback on issues like compatibility with existing standard and usage scenario of SEQ-ICV.</t>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119"?>
      <?rfc include="reference.RFC.4301"?>
      <?rfc include="reference.RFC.4302"?>
      <?rfc include="reference.RFC.4303"?>
    </references>

    <references title="Informative References">
      <?rfc include="reference.RFC.5996"?>
    </references>

    <section anchor="encap" title="Encapsulation Mode">
      <t>
      </t>

      <t></t>
    </section>

    <section title="Justification">
      <t>
      <list style="symbols">
        <t>
        </t>
        <t></t>
      </list>
     </t>

     <t></t>
    </section>
   </back>
</rfc>
