<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd" [

<!ENTITY RFC1997 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.1997.xml">
<!ENTITY RFC2119 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.2119.xml">
<!ENTITY RFC4271 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4271.xml">
<!ENTITY RFC4724 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4724.xml">
<!ENTITY RFC4360 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4360.xml">
<!ENTITY RFC4456 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4456.xml">
<!ENTITY RFC4760 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.4760.xml">
<!ENTITY RFC6514 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6514.xml">
<!ENTITY RFC6793 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6793.xml">
<!ENTITY RFC5701 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5701.xml">
<!ENTITY RFC7117 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.7117.xml">
<!ENTITY RFC5543 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5543.xml">
<!ENTITY RFC5549 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.5549.xml">
<!ENTITY RFC6368 SYSTEM "http://xml.resource.org/public/rfc/bibxml/reference.RFC.6368.xml">
<!ENTITY I-D.ietf-l2vpn-evpn SYSTEM 
     "http://xml.resource.org/public/rfc/bibxml3/reference.I-D.ietf-l2vpn-evpn.xml">
]>
<?xml-stylesheet type='text/xsl' href='rfc2629.xslt' ?>
<?rfc strict="yes" ?>
<?rfc toc="yes"?>
<?rfc tocdepth="4"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<rfc category="std" docName="draft-ietf-idr-error-handling-17" ipr="pre5378Trust200902"
 updates="1997, 4271, 4360, 4456, 4760, 5543, 5701, 6368">


  <front>
    <title abbrev="Revised Error Handling for BGP">Revised Error Handling 
    	for BGP UPDATE Messages</title>

    <author fullname="Enke Chen" initials="E." role="editor"
            surname="Chen">
      <organization>Cisco Systems, Inc.</organization>
      <address>
        <email>enkechen@cisco.com</email>
      </address>
    </author>

    <author fullname="John G. Scudder" initials="J.G." role="editor"
            surname="Scudder">
      <organization>Juniper Networks</organization>
      <address>
        <email>jgs@juniper.net</email>
      </address>
    </author>

    <author fullname="Pradosh Mohapatra" initials="P."
            surname="Mohapatra">
      <organization>Sproute Networks</organization>
      <address>
        <email>mpradosh@yahoo.com</email>
      </address>
    </author>

    <author fullname="Keyur Patel" initials="K."
            surname="Patel">
      <organization>Cisco Systems, Inc.</organization>
      <address>
        <email>keyupate@cisco.com</email>
      </address>
    </author>

    <date year="2014" />

    <area>General</area>
    <workgroup>Internet Engineering Task Force</workgroup>
    <keyword>BGP</keyword>

    <abstract>
      <t>
   According to the base BGP specification, a BGP speaker that receives
   an UPDATE message containing a malformed attribute is required to
   reset the session over which the offending attribute was received.
   This behavior is undesirable, because a session reset would impact not only
   routes with the offending attribute, but also other, valid routes
   exchanged over the session.  This document partially revises the
   error handling for UPDATE messages and provides guidelines for the
   authors of documents defining new attributes.  Finally, it revises
   the error handling procedures for a number of existing attributes.
      </t>
      <t>
   This document updates error handling for RFCs 1997, 4271, 4360, 4456,
   4760, 5543, 5701 and 6368.
      </t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>
   According to the base BGP specification <xref target="RFC4271"/>, a BGP speaker that
   receives an UPDATE message containing a malformed attribute is
   required to reset the session over which the offending attribute was
   received.  This behavior is undesirable, because a session reset
   impacts not only routes with the offending attribute, but also other,
   valid routes exchanged over the session.  In the case of optional
   transitive attributes, the behavior is especially troublesome and may
   present a potential security vulnerability. This is because attributes 
   may have been propagated without being checked by intermediate routers 
   that don't recognize the attributes. In effect, the attributes may have been 
   tunneled; and when they reach a router that recognizes and checks the 
   attributes, the session that is reset may not be associated with the router 
   that is at fault. To make matters worse,
   in such cases although the problematic attributes may have originated with
   a single update transmitted by a single BGP speaker, by the time they 
   encounter a router that checks them they may have been replicated many 
   times, and thus may cause the reset of many peering sessions. Thus the
   damage inflicted may be multiplied manyfold.
      </t>
      <t>
   The goal for revising the error handling for UPDATE messages is to
   minimize the impact on routing by a malformed UPDATE message, while
   maintaining protocol correctness to the extent possible.  This can be
   achieved largely by maintaining the established session and keeping
   the valid routes exchanged, but removing the routes carried in the
   malformed UPDATE from the routing system.
      </t>
      <t>
   This document partially revises the error handling for UPDATE
   messages, and provides guidelines for the authors of documents
   defining new attributes.  Finally, it revises the error handling
   procedures for a number of existing attributes.  Specifically, the
   error handling procedures of <xref target="RFC1997"/>, 
   <xref target="RFC4271"/>, <xref target="RFC4360"/>,
   <xref target="RFC4456"/>, <xref target="RFC4760"/>,
   <xref target="RFC5543"/>, <xref target="RFC5701"/>,
   and <xref target="RFC6368"/> are revised.
      </t>

      <section title="Requirements Language">
        <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>
    
   <section anchor="approaches" title="Error-Handling Approaches">
     <t>
   In this document we refer to four different approaches to
   handle errors found in BGP path attributes. They are as follows
   (listed in order, from the one with the "strongest" action to the
   one with the "weakest" action):
     </t>
     <t><list style="symbols">
	<t>
	Session reset: This is the approach used throughout the
	<xref target="RFC4271">base BGP specification</xref>, where
	a NOTIFICATION is sent and the session terminated. 
	</t>
	<t>
	AFI/SAFI disable: <xref target="RFC4760"/> specifies a procedure for
	disabling a particular AFI/SAFI. 
	</t>
	<t>
	Treat-as-withdraw: In this approach, the UPDATE message containing
   the path attribute in question MUST be treated as though all contained routes had
   been withdrawn just as if they had been listed in the WITHDRAWN
   ROUTES field (or in the MP_UNREACH_NLRI attribute if appropriate) of
   the UPDATE message, thus causing them to be removed from the Adj-RIB-In 
   according to the procedures of <xref target="RFC4271"/>. 
   	</t>
   	<t>
   	Attribute discard: In this approach the
   malformed attribute MUST be discarded and the UPDATE message
   continues to be processed. This approach MUST NOT be used except in the case of an
   attribute that has no effect on route selection or installation.
   	</t>
     </list></t>
    </section>

    <section anchor="revision" title="Revision to BGP UPDATE Message Error Handling">
          
      <t>
   This specification amends <xref target="RFC4271"/> Section 6.3 in a number of
   ways. See also <xref target="existing_attributes"/> for treatment of 
   specific path attributes.
      </t>
      
	<t>
		<list style="letters">
			<t>
   The first paragraph is revised as follows:
				<list style="empty">
					<t>
   Old Text:
      						<list>
      							<t>
      All errors detected while processing the UPDATE message MUST be
      indicated by sending the NOTIFICATION message with the Error Code
      UPDATE Message Error. The error subcode elaborates on the specific
      nature of the error.
							</t>
						</list>
					</t>
      					<t>
   New Text:
						<list>
							<t>
      An error detected while processing the UPDATE message for which a
      session reset is specified MUST be indicated by sending the
      NOTIFICATION message with the Error Code UPDATE Message Error.
      The error subcode elaborates on the specific nature of the error.
							</t>
						</list>
					</t>
				</list>
			</t>

      			<t>
   Error handling for the following case remains unchanged:
				<list style="hanging" hangIndent="6">
					<t>
      If the Withdrawn Routes Length or Total Attribute Length
      is too large (i.e., if Withdrawn Routes Length + Total Attribute
      Length + 23 exceeds the message Length), then the Error Subcode
      MUST be set to Malformed Attribute List.
					</t>
				</list>
			</t>

			<t>
   Attribute Flag error handling is revised as follows:
      				<list style="empty">
      					<t>
   Old Text:
						<list>
							<t>
      If any recognized attribute has Attribute Flags that conflict with
      the Attribute Type Code, then the Error Subcode MUST be set to
      Attribute Flags Error.  The Data field MUST contain the erroneous
      attribute (type, length, and value).
      							</t>
      						</list>
      					</t>
      					<t>
   New Text:
   						<list>
   							<t>
   	  If the value of either the Optional or Transitive bits in
   	  the Attribute Flags is in conflict with their specified 
   	  values, then the attribute MUST be
      treated as malformed and the treat-as-withdraw approach 
      used, unless the specification for the attribute
      mandates different handling for incorrect Attribute Flags.  
      							</t>
      						</list>
					</t>
				</list>
			</t>
      
		      	<t>
   If any of the well-known mandatory attributes are not present in an
   UPDATE message, then "treat-as-withdraw" MUST be used. (Note that
   <xref target="RFC4760"/> reclassifies NEXT_HOP as what is effectively
   discretionary.)
         		</t>
      			<t>
   "Treat-as-withdraw" MUST be used for the cases that specify a
   session reset and involve any of the attributes ORIGIN, AS_PATH,
   NEXT_HOP, MULTI_EXIT_DISC, or LOCAL_PREF.
      			</t>
      			<t>
   "Attribute discard" MUST be used for any of the cases that specify a
   session reset and involve ATOMIC_AGGREGATE or AGGREGATOR.
      			</t>
      			<t>
   If the MP_REACH_NLRI attribute or the MP_UNREACH_NLRI <xref
   target="RFC4760"/> attribute appears more than once in the UPDATE
   message, then a NOTIFICATION message MUST be sent with the Error
   Subcode "Malformed Attribute List".  If any other attribute
   (whether recognized or unrecognized)
   appears more than once in an UPDATE message, then all the
   occurrences of the attribute other than the first one SHALL be
   discarded and the UPDATE message continue to be processed.
      			</t>
      			<t>
   When multiple attribute errors exist in an UPDATE message, if the
   same approach (either "session reset", "treat-as-withdraw" or
   "attribute discard") is specified for the handling of these malformed
   attributes, then the specified approach MUST be used. Otherwise the
   approach with the strongest action MUST be used.
      			</t>
      			<t>
   The Withdrawn Routes field MUST be checked for syntactic correctness
   in the same manner as the NLRI field. This is discussed further 
   below, and in <xref target="nlri_syntax"/>.
   			</t>
		      	<t anchor="must_parse_nlri">
   Finally, we observe that in order to use the approach of
   "treat-as-withdraw", the entire NLRI field and/or the MP_REACH_NLRI
   and MP_UNREACH_NLRI attributes need to be successfully parsed -- what
   this entails is discussed in more detail in <xref
   target="parsing_nlri"/>.  If this is not possible, the procedures of
   <xref target="RFC4271"/> and/or <xref target="RFC4760"/> 
   continue to apply, meaning that the "session
   reset" approach (or the "AFI/SAFI disable" approach) MUST be followed. 
		   	</t>
		</list>
	</t>
    </section>
    
      <section title="Attribute Length Fields">
        <t>
   There are two error cases in which the Total Attribute Length value
   can be in conflict with the enclosed path attributes, which
   themselves carry length values. In the "overrun" case, as the
   enclosed path attributes are parsed, the length of the last
   encountered path attribute would cause the Total Attribute Length to
   be exceeded. In the "underrun" case, as the enclosed path attributes
   are parsed, after the last successfully-parsed attribute, fewer than
   three octets remain, or fewer than four octets, if the Attribute Flags
   field has the Extended Length bit set -- that is, there remains
   unconsumed data in the path attributes but yet insufficient data to
   encode a single minimum-sized path attribute. In either of these
   cases, an error condition exists and the treat-as-withdraw approach
   MUST be used (unless some other, more severe error is encountered
   dictating a stronger approach), and the Total Attribute Length MUST
   be relied upon to enable the beginning of the NLRI field to be
   located.
        </t>
    	<t>
 For all path attributes other than those specified as having an
 attribute length that may be zero, it SHALL be considered a syntax 
 error for the attribute to have a length of zero. (Of the path
 attributes considered in this specification, only AS_PATH and 
 ATOMIC_AGGREGATE may validly have an attribute length of zero.)
    	</t>
      </section>

    <section anchor="parsing_nlri" 
             title="Parsing of Network Layer Reachability Information (NLRI) Fields">
     <section anchor="encoding" title="Encoding NLRI">
      <t>
   To facilitate the determination of the NLRI field in an UPDATE
   with a malformed attribute:
      </t>
      <t><list style="symbols"><t>
   The MP_REACH_NLRI or MP_UNREACH_NLRI attribute (if present) SHALL be
   encoded as the very first path attribute in an UPDATE.
      </t>
      <t>
   An UPDATE message MUST NOT contain more than one of the following:
   non-empty Withdrawn Routes field, non-empty Network Layer
   Reachability Information field, MP_REACH_NLRI attribute, and
   MP_UNREACH_NLRI attribute. 
      </t></list></t>
      <t>
   Since older BGP speakers may not implement these restrictions, an
   implementation MUST still be prepared to receive these fields in any
   position or combination.
      </t>
      <t>
   If the encoding of <xref target="RFC4271"/> is used, the NLRI field for the IPv4
   unicast address family is carried immediately following all the
   attributes in an UPDATE.  When such an UPDATE is received, we observe
   that the NLRI field can be determined using the "Message Length",
   "Withdrawn Route Length" and "Total Attribute Length" (when they are
   consistent) carried in the message instead of relying on the length
   of individual attributes in the message.
      </t>
     </section>
     <section title="Missing NLRI">
      <t>
   <xref target="RFC4724"/> specifies an End-of-RIB message ("EoR") that
   can be encoded as an UPDATE message that contains only a
   MP_UNREACH_NLRI attribute that encodes no NLRI (it can also be a
   completely empty UPDATE message in the case of the "legacy" encoding). 
   In all other
   well-specified cases, an UPDATE either carries only withdrawn routes
   (either in the Withdrawn Routes field, or the MP_UNREACH_NLRI
   attribute), or it advertises reachable routes (either in the Network
   Layer Reachability Information field, or the MP_REACH_NLRI
   attribute). 
     </t>
     <t>
   Thus, if an UPDATE message is encountered that does contain path
   attributes other than MP_UNREACH_NLRI and doesn't encode any
   reachable NLRI, we cannot be confident that the NLRI have been
   successfully parsed as Section 3 (j) requires. For this reason, 
    <!--
    Ideally I wouldn't have hard-coded the reference above, but my
    XML-fu was insufficient to the task of making xml2rfc spit out 
    a reasonable, readable reference. My attempts for posterity are
    below:
    <xref target="revision">(j)</xref> 
    <xref target="must_parse_nlri"/> -->
   if any path attribute errors are encountered in such an UPDATE message, 
   and if any encountered error specifies an error-handling approach 
   other than "attribute discard", then the "session reset" approach 
   MUST be used.
     </t>
      </section>
      <section anchor="nlri_syntax"
               title="Syntactic Correctness of NLRI Fields">
        <t>
   The NLRI field or Withdrawn Routes field SHALL be considered
   "syntactically incorrect" if either of the following are true:
        <list style="symbols">
        <t>
      The length of any of the included NLRI is greater than 32,
        </t>
        <t>
      When parsing NLRI contained in the field, the length of the
      last NLRI found exceeds the amount of unconsumed data
      remaining in the field.
        </t></list></t>
        <t>
   Similarly, the MP_REACH_NLRI or MP_UNREACH_NLRI attribute of an update SHALL be
   considered to be incorrect if any of the following are true:
        <list style="symbols">
        <t>
      The length of any of the included NLRI is inconsistent with the
      given AFI/SAFI (for example, if an IPv4 NLRI has a length
      greater than 32 or an IPv6 NLRI has a length greater than 128),
        </t>
        <t>
      When parsing NLRI contained in the attribute, the length of the
      last NLRI found exceeds the amount of unconsumed data
      remaining in the attribute.
        </t>
        <t>
      The attribute flags of the attribute are inconsistent with those
      specified in <xref target="RFC4760"/>.
        </t>
        <t>
      The length of the MP_UNREACH_NLRI attribute is less than 3, or the
      length of the MP_REACH_NLRI attribute is less than 5.
        </t></list></t>
      </section>

      <section anchor="typed_nlri"
               title="Typed NLRI">
	  <t>
    Certain address families, for example <xref
    target="RFC6514">MCAST-VPN</xref>, <xref
    target="RFC7117">MCAST-VPLS</xref> and <xref
    target="I-D.ietf-l2vpn-evpn">EVPN</xref> have NLRI that are typed.
    Since supported type values within the address family are not
    expressed in the <xref target="RFC4760">MP-BGP capability</xref>, it
    is possible for a BGP speaker to advertise support for the given
    address family and sub-address family while still not supporting a
    particular type of NLRI within that AFI/SAFI.
    	</t>
    	<t>
    A BGP speaker advertising support for such a typed address
    family MUST handle routes with unrecognized NLRI types within that
    address family by discarding them, unless the relevant specification
    for that address family specifies otherwise.
    	</t>
      </section>

    </section>
    
    <section title="Operational Considerations">
      <t>
   Although the "treat-as-withdraw" error-handling behavior defined in
   Section 2 makes every effort to preserve BGP's correctness, we note
   that if an UPDATE received on an IBGP session is subjected to this
   treatment, inconsistent routing within the affected Autonomous System
   may result.  The consequences of inconsistent routing can include
   long-lived forwarding loops and black holes.  While lamentable, this
   issue is expected to be rare in practice, and, more importantly, is
   seen as less problematic than the session-reset behavior it replaces.
      </t>
      <t>
   When a malformed attribute is indeed detected over an IBGP session,
   we RECOMMEND that routes with the malformed attribute be identified
   and traced back to the ingress router in the network where the routes
   were sourced or received externally, and then a filter be applied on
   the ingress router to prevent the routes from being sourced or
   received.  This will help maintain routing consistency in the
   network.
      </t>
      <t>
   Even if inconsistent routing does not arise, the "treat-as-withdraw"
   behavior can cause either complete unreachability or sub-optimal
   routing for the destinations whose routes are carried in the affected
   UPDATE message.
      </t>
      <t>
   Note that "treat-as-withdraw" is different from discarding an UPDATE
   message.  The latter violates the basic BGP principle of incremental
   update, and could cause invalid routes to be kept. 
      </t>
      <t>
   Because of these potential issues, a BGP speaker MUST provide
   debugging facilities to permit issues caused by a malformed attribute
   to be diagnosed.  At a minimum, such facilities MUST include logging
   an error listing the NLRI involved, and containing the entire
   malformed UPDATE message when such an attribute is detected.  The
   malformed UPDATE message SHOULD be analyzed, and the root cause
   SHOULD be investigated.    
      </t>
      <t>
   <xref target="guidance"/> mentions that attribute discard should not
   be used in cases where "the attribute in question has or may have an
   effect on route selection." Although all cases that specify attribute
   discard in this document do not affect route selection by default, in
   principle routing policies could be written that affect selection
   based on such an attribute. Operators should take care when writing
   such policies to consider the possible consequences of an attribute
   discard. (In general, as long as such policies are only applied to
   external BGP sessions, correctness issues are not expected to arise.)
      </t>
    </section>

    <section anchor="existing_attributes" 
             title="Error Handling Procedures for Existing Attributes">
        <t>
    In the following subsections, we elaborate on the conditions for
    error-checking various path attributes, and specify what approach(es)
    should be used to handle malformations. It is possible that implementations
    may apply other error checks not contemplated here. If so, the error 
    handling approach given here should generally be applied.
    	</t>
    	<t>
    This section addresses all path attributes that are defined at the
    time of this writing, that were not defined with error-handling
    consistent with <xref target="guidance"/>, and that are not marked
    as "deprecated" in <xref target="IANA-BGP-ATTRS"/>. Attributes 17
    (AS4_PATH), 18 (AS4_AGGREGATOR), 22 (PMSI_TUNNEL), 23 (Tunnel
    Encapsulation Attribute), 26 (AIGP), 27 (PE Distinguisher Labels)
    and 29 (BGP-LS Attribute) do have error-handling consistent with
    <xref target="guidance"/> and thus are not further discussed herein.
    Attributes 11 (DPA), 12 (ADVERTISER), 13 (RCID_PATH / CLUSTER_ID),
    19 (SAFI Specific Attribute), 20 (Connector Attribute), 21
    (AS_PATHLIMIT) and 28 (BGP Entropy Label Capability Attribute) are
    deprecated and thus are not further discussed herein.
    	</t>
    	
      <section title="ORIGIN">
      <t>
   The attribute is considered malformed if its length is not 1, or it
   has an undefined value <xref target="RFC4271"/>.
      </t>
      <t>
   An UPDATE message with a malformed ORIGIN attribute SHALL be handled
   using the approach of "treat-as-withdraw".
      </t>
      </section>
      
      <section title="AS_PATH">
      <t>
   An AS_PATH is considered malformed if an unrecognized segment
   type is encountered, or if it contains a malformed segment. A
   segment is considered malformed if any of the following obtains:
     </t>
     <t><list style="symbols">
       <t>
  There is an overrun, where the path segment length field of the last 
  segment encountered would cause the Attribute Length to be exceeded.
       </t>
       <t>
  There is an underrun, where after the last successfully-parsed segment,
  there is only a single octet remaining (that is, there is not enough 
  unconsumed data to provide even an empty segment header).
       </t>
       <t>
  It has a path segment length field of zero.
       </t>
     </list></t>
      <t>
   An UPDATE message with a malformed AS_PATH attribute SHALL be handled
   using the approach of "treat-as-withdraw".
      </t>
      <t>
   <xref target="RFC4271"/> also says that an implementation
   optionally "MAY check whether the leftmost ... AS in the AS_PATH
   attribute is equal to the autonomous system number of the peer
   that sent the message". A BGP implementation SHOULD also handle 
   routes that violate this check using "treat-as-withdraw", but 
   MAY follow the session reset behavior if configured to do so.
      </t>
      </section>
      
      <section anchor="next_hop" title="NEXT_HOP">
      <t>
   The attribute is considered malformed if its length is not 4
   <xref target="RFC4271"/>. A length of 16 is also permissible
   if <xref target="RFC5549"/> is in use and all conditions 
   given in that specification have been satisfied. 
      </t>
      <t>
   An UPDATE message with a malformed NEXT_HOP attribute SHALL be
   handled using the approach of "treat-as-withdraw".
      </t>
      </section>

      <section title="MULTI_EXIT_DISC">
      <t>
   The attribute is considered malformed if its length is not 4
   <xref target="RFC4271"/>.
      </t>
      <t>
   An UPDATE message with a malformed MULTI_EXIT_DISC attribute SHALL be
   handled using the approach of "treat-as-withdraw".
      </t>
      </section>
      
      <section title="LOCAL_PREF">
      <t>
   The error handling of <xref target="RFC4271"/> is revised as follows.
      <list style="symbols">
      <t>
     If the LOCAL_PREF attribute is received from an external 
      neighbor, it SHALL be discarded using the approach of "attribute
      discard", or
      </t>
      <t>
     if received from an internal neighbor, it SHALL be considered
      malformed if its length is not equal to 4.  If malformed, the
      UPDATE SHALL be handled using the approach of "treat-as-withdraw".
      </t>
      </list>
      </t>
      </section>
      
      <section title="ATOMIC_AGGREGATE">
      <t>
   The attribute SHALL be considered malformed if its length is not 0
   <xref target="RFC4271"/>.
      </t>
      <t>
   An UPDATE message with a malformed ATOMIC_AGGREGATE attribute SHALL
   be handled using the approach of "attribute discard".
      </t>
      </section>
      
      <section title="AGGREGATOR">
      <t>
   The error conditions specified in <xref target="RFC4271"/> for the attribute are
   revised as follows:
      </t>
      <t>
   The AGGREGATOR attribute SHALL be considered malformed if any of the
   following applies:
      <list style="symbols"><t>
      Its length is not 6 (when the "4-octet AS number capability" is
      not advertised to, or not received from the peer <xref target="RFC6793"/>).
      </t>
      <t>
      Its length is not 8 (when the "4-octet AS number capability" is
      both advertised to, and received from the peer).
      </t></list></t>
      <t>
   An UPDATE message with a malformed AGGREGATOR attribute SHALL be
   handled using the approach of "attribute discard".
      </t>
      </section>
      
      <section title="Community">
      <t>
   The error handling of <xref target="RFC1997"/> is revised as follows:
      </t>
      <t>
   The Community attribute SHALL be considered malformed if its length
   is not a nonzero multiple of 4.
      </t>
      <t>
   An UPDATE message with a malformed Community attribute SHALL be
   handled using the approach of "treat-as-withdraw".
      </t>
      </section>
      
      <section title="ORIGINATOR_ID">
      <t>
    The error handling of <xref target="RFC4456"/> is revised as follows.
      <list style="symbols"><t>
    If the ORIGINATOR_ID attribute is received from an external neighbor,
    it SHALL be discarded using the approach of "attribute discard", or
      </t>
      <t>
    if received from an internal neighbor, it SHALL be considered
    malformed if its length is not equal to 4. If
    malformed, the UPDATE SHALL be handled using the approach of
    "treat-as-withdraw".
      </t></list></t>
    </section>
    
    <section title="CLUSTER_LIST">
      <t>
    The error handling of <xref target="RFC4456"/> is revised as follows.
      <list style="symbols"><t>
    If the CLUSTER_LIST attribute is received from an external neighbor,
    it SHALL be discarded using the approach of "attribute discard", or
      </t>
      <t>
    if received from an internal neighbor, it SHALL be considered
    malformed if its length is not a nonzero multiple of 4.
    If malformed, the UPDATE SHALL be handled using the approach of
    "treat-as-withdraw".
      </t></list></t>
    </section>
    
    <section title="MP_REACH_NLRI">
      <t>
    If the Length of Next Hop Network Address field of the MP_REACH
    attribute is inconsistent with that which was expected, the
    attribute is considered malformed. Since the next hop precedes the
    NLRI field in the attribute, in this case it will not be possible to
    reliably locate the NLRI, and thus the "session reset" or "AFI/SAFI
    disable" approach MUST be used.
      </t>
	  <t>
	"That which was expected", while somewhat vague, is intended to
	encompass the next hop specified for the Address Family Identifier
	and Subsequent Address Family Identifier fields and potentially
	modified by any extensions in use. For example, if <xref
	target="RFC5549"/> is in use then the next hop would have to have a
	length of 4 or 16.
	  </t>
      <t>
    <xref target="revision"/> and <xref target="parsing_nlri"/> provide
    further discussion of the handling of this attribute.
      </t>
    </section>
    
    <section title="MP_UNREACH_NLRI">
      <t>
    <xref target="revision"/> and <xref target="parsing_nlri"/> discuss
    the handling of this attribute.
      </t>
    </section>
    
    <section title="Traffic Engineering path attribute">
		<t>
    We note that <xref target="RFC5543"/> does not detail what
    constitutes "malformation" for the Traffic Engineering path
    attribute. A future update to that specification may provide more
    guidance. In the interim, an implementation that determines (for
    whatever reason) that an UPDATE message contains a malformed Traffic
    Engineering path attribute MUST handle it using the approach of
    "treat-as-withdraw".
    	</t>
    </section>
    
      <section title="Extended Community">
      <t>
   The error handling of <xref target="RFC4360"/> is revised as follows:
      </t>
      <t>
   The Extended Community attribute SHALL be considered malformed if its
   length is not a nonzero multiple of 8.
      </t>
      <t>
   An UPDATE message with a malformed Extended Community attribute SHALL
   be handled using the approach of "treat-as-withdraw".
      </t>
      <t>
   Note that a BGP speaker MUST NOT treat an unrecognized Extended
   Community Type or Sub-Type as an error.
      </t>
      </section>
      
      <section title="IPv6 Address Specific BGP Extended Community Attribute">
      <t>
   The error handling of <xref target="RFC5701"/> is revised as follows:
      </t>
      <t>
   The IPv6 Address Specific Extended Community attribute SHALL be
   considered malformed if its length is not a nonzero multiple
   of 20.
      </t>
      <t>
   An UPDATE message with a malformed IPv6 Address Specific Extended
   Community attribute SHALL be handled using the approach of "treat-as-
   withdraw".
      </t>
      <t>
   Note that a BGP speaker MUST NOT treat an unrecognized IPv6 Address
   Specific Extended Community Type or Sub-Type as an error.
      </t>
      </section>
    
    <section title="ATTR_SET">
      <t>
    The final paragraph of Section 5 of <xref target="RFC6368"/> is
    revised as follows:
        <list style="empty">
          <t>
    Old Text:
            <list>
              <t>
   An UPDATE message with a malformed ATTR_SET attribute SHALL be
   handled as follows.  If its Partial flag is set and its
   Neighbor-Complete flag is clear, the UPDATE is treated as a route
   withdraw as discussed in [OPT-TRANS-BGP].  Otherwise (i.e., Partial
   flag is clear or Neighbor-Complete is set), the procedures of the
   BGP-4 base specification [RFC4271] MUST be followed with respect to
   an Optional Attribute Error.
              </t>
            </list>
          </t>
          <t>
    New Text:
            <list>
              <t>
   An UPDATE message with a malformed ATTR_SET attribute SHALL be
   handled using the approach of "treat as withdraw".
              </t>
            </list>
          </t>
        </list>
      </t>
      <t>
    Furthermore, the normative reference to [OPT-TRANS-BGP] in
    <xref target="RFC6368"/> is removed.
      </t>
    </section>
    
    </section>

    <section anchor="guidance" title="Guidance for Authors of BGP Specifications">
    <t>
   A document that specifies a new BGP attribute MUST provide specifics
   regarding what constitutes an error for that attribute and how that
   error is to be handled. Allowable error-handling approaches are 
   detailed in <xref target="approaches"/>. The
   treat-as-withdraw approach is generally preferred. The document
   SHOULD also provide consideration of what debugging facilities may
   be required to permit issues caused by a malformed attribute  to be 
   diagnosed.
    </t>
      <t>
   For any malformed attribute that is handled by the "attribute
   discard" instead of the "treat-as-withdraw" approach, it is critical
   to consider the potential impact of doing so.  In particular, if the
   attribute in question has or may have an effect on route selection or
   installation, the presumption is that discarding it is unsafe, unless
   careful analysis proves otherwise.  The analysis should take into
   account the tradeoff between preserving connectivity and potential
   side effects.
      </t>
      <t>
    Authors can refer to <xref target="existing_attributes"/> for
    examples.
      </t>
    </section>

    <section anchor="IANA" title="IANA Considerations">
      <t>This document makes no request of IANA.</t>
    </section>
        
    <section title="Security Considerations">
      <t>
   This specification addresses the vulnerability of a BGP speaker to a
   potential attack whereby a distant attacker can generate a malformed
   optional transitive attribute that is not recognized by intervening
   routers (which thus propagate the attribute unchecked) but that
   causes session resets when it reaches routers that do recognize the
   given attribute type.
      </t>
      <t>
   In other respects, this specification does not change BGP's security
   characteristics.
      </t>
    </section>

    <section title="Acknowledgements">
      <t>
   The authors wish to thank Juan Alcaide, Deniz Bahadir, Ron Bonica,
   Mach Chen, Andy Davidson, Bruno Decraene, Rex Fernando, Jeff Haas,
   Chris Hall, Joel Halpern, Dong Jie, Akira Kato, Miya Kohno, Warren Kumari,
   Tony Li,
   Alton Lo, Shin Miyakawa, Tamas Mondal, Jonathan Oddy, Tony
   Przygienda, Robert Raszuk, Yakov Rekhter, Eric Rosen, Shyam Sethuram,
   Rob Shakir, Naiming Shen, Adam Simpson, Ananth Suryanarayana, Kaliraj
   Vairavakkalai, Lili Wang and Ondrej Zajicek for their observations
   and discussion of this topic, and review of this document.
       </t>
     </section>
  </middle>

  <back>
    <references title="Normative References">
      &RFC1997;
      &RFC2119;
      &RFC4271;
      &RFC4724;
      &RFC4360;
      &RFC4456;
      &RFC4760;
      &RFC6793;
      &RFC5701;
      &RFC5543;
      &RFC6368;
      &RFC5549;
      
		<reference anchor="IANA-BGP-ATTRS" 
		           target="http://www.iana.org/assignments/bgp-parameters/bgp-parameters.xhtml#bgp-parameters-2">
		  <front>
			<title>BGP Path Attributes</title>
			<author/>
			<date/>
		  </front>
		</reference>

    </references>
    
    <references title="Informative References">
      &RFC6514;
      &RFC7117;
      &I-D.ietf-l2vpn-evpn;
    </references>

  </back>
</rfc>
