﻿<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc tocompact="yes"?>
<?rfc tocdepth="3"?>
<?rfc tocindent="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes"?>
<?rfc comments="yes"?>
<?rfc inline="yes"?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<rfc category="bcp" docName="draft-ietf-grow-as-path-prepending-13" updates="" ipr="trust200902">

  <front>
    <title abbrev="AS Path Prepending">AS Path Prepending</title>

    <author fullname="Mike McBride" initials="M" surname="McBride">
      <organization>Futurewei</organization>

      <address>
        <email>michael.mcbride@futurewei.com</email>
      </address>
    </author>
    
       <author fullname="Doug Madory" initials="D" surname="Madory">
      <organization>Kentik</organization>

      <address>
        <email>dmadory@kentik.com</email>
      </address>
    </author>
    
        <author fullname="Jeff Tantsura" initials="J" surname="Tantsura">
      <organization>Nvidia</organization>

      <address>
        <email>jefftant.ietf@gmail.com</email>
      </address>
    </author>
    
 <author fullname='Robert Raszuk' initials='R' surname='Raszuk'>
    <organization>NTT Network Innovations</organization>
    <address>
        <postal>
            <street>940 Stewart Dr</street>
            <city>Sunnyvale</city>
            <region>CA</region>
            <code>94085</code>
            <country>USA</country>
        </postal>
        <email>robert@raszuk.net</email>
    </address>
</author>

     
              <author fullname="Hongwei Li" initials="H." surname="Li">
        <organization>HPE</organization>
        <address>
            <email>flycoolman@gmail.com</email>
        </address>
     </author>
     
     <author fullname="Jakob Heitz" initials="J. " surname="Heitz">
<organization>Cisco</organization>
<address>
<postal>
<street>170 West Tasman Drive</street>
<city>San Jose</city>
<region>CA</region>
<code>95134</code>
<country>USA</country>
</postal>
<email>jheitz@cisco.com</email>
</address>
</author>     

    <author fullname="Gyan Mishra" initials="G. " surname="Mishra">
      <organization>Verizon Inc.</organization>
      <address>
        <email>gyan.s.mishra@verizon.com</email>
      </address>
    </author>


    <date day="20" month="June" year="2024"/>

    <abstract>
      <t>AS Path Prepending provides a tool to manipulate the BGP AS_PATH attribute
      through prepending multiple entries of an ASN. AS Path Prepending is used to deprioritize a
      route or alternate path. By prepending the local ASN multiple times, ASs can make 
      advertised AS paths appear artificially longer. Excessive AS Path Prepending has caused 
      routing issues in the Internet. This document provides guidance for the use of AS Path 
      Prepending, including alternative solutions, in order to avoid negatively affecting the Internet.</t>
    </abstract>
  </front>

  <middle>
    <section title="Introduction">
      <t>The Border Gateway Protocol (BGP) <xref target="RFC4271"/> specifies the AS_PATH 
      attribute, which enumerates ASs a route update has traversed. If the UPDATE message is propagated over an external link, 
      then the local AS number is prepended to the AS_PATH attribute, and the NEXT_HOP 
      attribute is updated with an IP address of the router that should be used as a next hop to the 
      network.  If the UPDATE message is propagated over an internal link, then the AS_PATH 
      attribute and the NEXT_HOP attribute are passed unmodified. </t>
      
      <t>A common practice among operators is to prepend multiple entries of an
      AS (known as AS Path Prepending) in order to deprioritize a route or a path. So far, this has 
      not caused many problems. However, the practice is increasing, with both IPv4 and IPv6, and 
      there are now inherent risks to the global Internet, especially with excessive AS Path Prepending. 
      Prepending is frequently employed in an excessive manner such that it renders routes vulnerable to disruption or 
      misdirection. <xref target="RFC8195"/> discusses using BGP Large Communities for traffic engineering through selective AS_PATH prepending.  
      This document provides additional and specific guidance to 
      operators on how to be good Internet citizens with less risky use of AS Path Prepending.</t>

      <section anchor="requirements-language" 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 title="Use Cases">  
      <t>There are various reasons that AS Path Prepending is in use today, including:</t>
          <t><list style="symbols">
            <t>Preferring one ISP over another ISP on the same ASBR or across different ASBRs.</t>
            <t>Preferring one ASBR over another ASBR in the same site or between sister sites.</t>
            <t>Utilize one path exclusively and another path solely as a backup.</t>
            <t>Signal to indicate that one path may have a different amount of capacity than another where the lower capacity link still takes traffic.</t>
            <t>Conditionally prefer one ASBR over another at the same site or between sites for lowest latency path based on geographic location.</t>
            <t>An ISP doesn't accept traffic engineering using BGP communities. Prepending is the only option.</t>
          </list></t>
          <t>The following illustration, from Geoff Huston's <xref target="Path Prepending in BGP"/>, shows how AS Prepending is typically used:</t>
          
        <t><figure align="left">
          <artwork><![CDATA[      
       
               +---+    +---+
           +---| D |----| F |
           |   +---+    +---+
+---+   +---+             |
| A |---| B |             |
+---+   +---+        2x<- |
           |   +---+    +---+
           +---| C |----| E |
               +---+    +---+

       
      ]]></artwork>
        </figure></t>
          
    <t>In the diagram above, A, B, C, D, E, and F all have a different AS.
    B will normally prefer the path via C to send traffic to E, as this represents the shorter AS path for B. 
    If E were to prepend a further two instances of its own AS number when advertising its routes to C, then 
    B will now see a different situation, where the AS Path via D represents the shorter path. Through 
    the use of selective prepending E is able to alter the routing decision of B, even though B is not an adjacent 
    neighbour of E. The result is that traffic from A and B will be passed via D and F to reach E, rather than via C. 
    In this way prepending implements action at a distance where the routing decisions made by non-adjacent 
    ASs can be influenced by selective AS Path prepending.</t>
          </section>

    <section title="Problems">
      <t>Since it is so commonly used, what is the problem with the excessive use of AS Path Prepending? Here are
      a few examples:</t>
      
      <section title="Cascading and ripple effects of prepending across the Internet">
 
      <t>Care should be taken in prepending, as prepending can cause ripple effects with multiple AS's performing the same 
      set of prepends in the same direction, resulting in unintended routing where the valid preferred path becomes now de-preferred.
      </t> 
      
         <t><figure align="center">
          <artwork><![CDATA[      

                         <-5x     <-5x     <-5x                          
               +---+    +---+    +---+    +---+
           +---| D |----| F |----| H |----| J |  
           |   +---+    +---+    +---+    +---+
+---+   +---+             |                 |                
| A |---| B |             |                 |              
+---+   +---+        13x<-|                 |             
           |   +---+    +---+    +---+    +---+
           +---| C |----| E |----| G |----| I |
               +---+    +---+    +---+    +---+ 

       
      ]]></artwork>
        </figure></t>     
      
    <t>In the diagram above A, B, C, D, E, F G, H, I, and J are all part of different ASes.
    B will normally prefer the path via D to send traffic to J, as this represents the preferred path to B, due to E prepending 13 instances of its own 
    AS number when advertising routes to C. ISP J decides to prepend 5 instances of its own AS when advertising to H, and ISP H decides to do the 
    same and prepends 5 instances of its own AS when advertising to F.  ISP F decides as well to prepend 5 instances of its own AS when 
    advertising to D.  B now sees 19 AS hops for prefixes coming from D to get to J which should be the preferred path compared to 18 AS hops 
    coming from C which is now preferred. We now have a route leak to I as B now sends all of its traffic through I to reach J.  This is the typical 
    scenario where route leaks occur where providers decide to de-prefer a path. However as the same de-preference of a path gets cascaded in the 
    same direction, as a result, the path that should never be preferred as its as-path is very high in this case 18 AS hops ends up being the preferred 
    path resulting in a route leak. Usage of BGP large communities along with conditional prepending, along with care being taken when prepending is 
    performed between providers, can help mitigate the adverse impacts of prepending.</t>
 
      </section>
      
      
      <section title="Excessive Prepending">
 
      <t>The risk of excessive use of AS Path Prepending can be illustrated with real-world examples that have been 
      anonymized using documentation prefixes <xref target="RFC5737"/> and ASs <xref target="RFC5398"/> . Consider the 
      prefix 198.51.100.0/24 which is normally announced with an inordinate amount of prepending. A recent analysis 
      revealed that 198.51.100.0/24 is announced to the world along the following AS path:</t>
      
      <t>64496 64511 64511 64511 64511 64511 64511 64511 64511 64511 64511 64511 64511 64511 64511 64511 64511
      64511 64511 64511 64511 64511 64511 64511</t>

      <t>In this example, the origin AS64511 appears 23 consecutive times before being passed on to a single 
      upstream (AS64496), which passes it on to the global Internet, prepended-to-all. An attacker, wanting to intercept or 
      manipulate traffic to this prefix, could enlist a datacenter to allow announcements 
      of the same prefix with a fabricated AS path such as 999999 64496 64511. Here the fictional AS999999 represents 
      the shady datacenter.  This malicious route would be preferred due to the shortened AS path length and might 
      go unnoticed by the true origin, even if route-monitoring had been implemented. Standard BGP route monitoring 
      checks a route’s origin and upstream and both would be intact in this scenario. The length of the prepending gives 
      the attacker room to craft an AS path that would appear plausible to the casual observer, comply with origin validation 
      mechanisms, and not be detected by off-the-shelf route monitoring.</t>
           </section>
      
         <section title="Prepending during a routing leak">
      <t>In April 2010, a service provider experienced a routing leak. While analyzing the leak something peculiar was noticed. 
      When we ranked the approximately 50,000 prefixes involved in the leak based on how many ASs accepted the leaked 
      routes, most of the impact was constrained to Country A routes. However, two of the top five most-propagated leaked 
      routes (listed in the table below) were Country B routes.</t>
      <t>During the routing leak, nearly all of the ASs of the Internet preferred the Country A leaked routes for 192.0.2.0/21 and 
      198.51.100.0/22 because, at the time, these two Country B prefixes were being announced to the entire Internet along the following 
      excessively prepended AS path: 64496 64500 64511 64511 64511 64511 64511 64511. Virtually 
      any illegitimate route would be preferred over the legitimate route. In this case, the victim is all but ensuring their victimhood.</t>
      <t>There was only a single upstream seen in the prepending example from above, so the prepending was achieving nothing 
      except incurring risk. You would think such mistakes would be relatively rare, 
      especially now, 10 years later.  As it turns out, there is quite a lot of prepending-to-all going on right now and during leaks, it 
      doesn’t go well for those who make this mistake. While one can debate the merits of prepending to a subset of multiple transit 
      providers, it is difficult to see the utility in prepending to every provider. In this configuration, the prepending is no longer shaping 
      route propagation. It is simply incentivizing ASs to choose another origin if one were to suddenly appear whether by mistake 
      or otherwise.</t>
                 </section>

          <section title="Prepending to All">
      
      <t>Based on analysis done in 2019 <xref target="Excessive AS Path Prepending"/>, out of approximately 750,000 routes in the IPv4 
      global routing table, nearly 60,000 BGP routes are prepended 
      to 95% or more of hundreds of BGP sources. About 8% of the global routing table, or 1 out of every 12 BGP routes, is configured with 
      prepends to virtually the entire Internet. The 60,000 routes include entities of every stripe: governments, financial institutions, even 
      important parts of Internet infrastructure.</t>

      <t>Much of the worst propagation of leaked routes during big leak events have been due to routes being prepended-to-all.
           The AS64505 leak of April 2014 (>320,000 prefixes) was prepended-to-all. And the AS64506 leak of June 2015 (>260,000 prefixes)
          was also prepended-to-all. Prepended-to-all prefixes are those seen as prepended by all (or nearly all) of the ASs of the Internet.
          In this configuration, prepending is no longer shaping route propagation but is simply incentivizing ASs to choose another origin 
          if one were to suddenly appear whether by mistake or otherwise. The percentage of the IPv4 table that is prepended-to-all is 
          growing at 0.5% per year. The IPv6 table is growing slower at 0.2% per year. The reasons for using prepend-to-all appears 
          to be due to 1) the AS forgetting to remove the prepending for one of its transit providers when it is no longer needed and 2) the 
          AS attempting to de-prioritize traffic from transit providers over settlement-free peers and 3) there are simply a lot of errors in 
          BGP routing. Consider the prepended AS path below:</t>

        <t>64496 64501 64501 64510 64510 64501 64510 64501 64501
                         64510 64510 64501 64501 64510</t>

        <t>The prepending here involves a mix of two distinct ASNs (64501 and 64510) with the last two digits transposed.</t>      
           </section>
         
            <section title="Memory">       
      <t>Long AS Paths cause an increase in memory usage by BGP speakers. A concern about an AS Path longer than 255 is the 
      extra complexity required to process it, because it needs to be encoded 
       in more than one AS_SEQUENCE in the AS_PATH BGP path attribute.</t>
         </section>
         
               <section title="Errant announcement">  
      <t>It is possible for an Internet-wide outage to occur because of a single errant routing announcement. For example, AS64496 
      could announce its one prefix with an extremely long AS path. Someone could enter their ASN instead of the prepend count.
      64496 modulo 256 = 240 prepends, and when a path lengths exceeded 255, routers could crash.</t>
          </section>
              </section>
          
              <section title="Alternatives to AS Path Prepend">
              
 
      <t>Various options, to provide path preference without needing to use AS Path Prepend, include:</t>
      
             <t><list style="symbols">
            <t>Use predefined communities that are mapped to a particular behavior when propagated.</t>
            <t>Announce more specific routes on the preferred path.</t>
            <t>The BGP Origin Code is an attribute that is used for path selection and can be used as a high order tie-breaker.
            The three origin codes are IGP, EGP and INCOMPLETE. When AS Paths are of equivalent length, users could advertise 
            paths, with IGP or EGP origin, over the preferred path while the other ASBRs (which would otherwise need to prepend N times) 
            advertises with an INCOMPLETE origin code. </t>
            <t>The Multi Exit Discriminator (MED) is an optional non-transitive attribute that can be used to influence path preference instead of using as-path.
            MED is non transitive so it cannot influence an AS more than 1 AS hop away.</t> 
            <t>Local-preference optional non-transitive attribute, above as-path in BGP path selection, can be used to 
            influence route preference within the local operators AS administrative domain. Local-preference can shield the operator domain from 
            traffic shifts off the preferred path to a de-preferred path caused by excess prepending done by service providers across the Internet. If all service 
            providers across the Internet set local-preference inbound conditionally with Large Community set on preferred paths, the impacts of 
            suboptimal routing, as well as other routing issues resulting from excess prepending, can be mitigated.</t>
            </list></t>      
      
         <t><figure align="center">
          <artwork><![CDATA[      

                         <-5x     <-5x     <-5x                          
       LP 110  +---+    +---+    +---+    +---+
           +---| D |----| F |----| H |----| J |  
           |   +---+    +---+    +---+    +---+
+---+   +---+             |                 |                
| A |---| B |             |                 |              
+---+   +---+        13x<-|                 |             
           |   +---+    +---+    +---+    +---+
           +---| C |----| E |----| G |----| I |
               +---+    +---+    +---+    +---+ 

       
      ]]></artwork>
        </figure></t>     
      
    <t>In the diagram above A, B, C, D, E, F G, H, I, J are all part of a different AS.
    B will normally prefer the path via D to send traffic to J, as this represents the preferred path to B, due to E prepending 13 instances of its own 
    AS number when advertising routes to C. ISP J decides to prepend 5 instances of its own AS when advertising to H, and ISP H decides to do the 
    same and prepends 5 instances of its own AS when advertising to F.  ISP F decides to also prepend 5 instances of its own AS when 
    advertising to D.  B now sees 19 AS hops for prefixes coming from D to get to J which should be the preferred path compare to 18 AS hops 
    coming from C which is now preferred. We now have suboptimal routing to I as B now sends all of its traffic through I to reach J.  This suboptimal routing on B can 
    be prevented locally within the operator domain by setting local-preference inbound, which is above as-path length in the best path selection, to 
    higher then default 100 to 110 inbound from D, thus shielding the operator B from being influenced by the excessive prepend cascading ripple 
    affect by F, H, J. Note that A still sees the cascading ripple affect of excess prepending, however A, or any service provider AS downstream 
    of B, ingressing B, will be shunted to D via local-preference and the suboptimal routing is now mitigated for all downstream AS to the left of B that prefer 
    the path through B.</t>				  
				  
          </section>
      
        <section title="Best Practices">
        <t>Many of the best practices, or lack thereof, can be illustrated from the preceding examples. Here's a summary of the
        best current practices when using AS Path Prepending:</t>
        
              <t><list style="symbols">
            <t>Network operators should ensure prepending is absolutely necessary as many networks have excessive prepending.
             It is best to innumerate what the routing policies are intended to achieve before concluding that prepending is a solution</t>
             <t>The neighbor you are prepending may have an unconditional preference for customer routes and prepending doesn't work. 
             It's helpful to check with neighbors to see if they will honor the prepend to avoid wasting effort and potentially causing further vulnerabilities.</t>
            <t>Use of local-preference inbound on preferred paths between service providers to help mitigate the adverse affects of prepending</t>
            <t>As can be seen from the following diagram (reproduced from <xref target="Excessive AS Path Prepending"/>), prepending more than 
            5 times rarely provides any benefit. Note that routing patterns may change over time and may be different in various parts of the internet.
            A looking glass, as provided by many Internet Service Providers, can be used to get a better understanding of as-path length of an IP address 
            prefix of interest. </t>
                   </list></t>
      
              <t><figure align="left">
          <artwork><![CDATA[      
       
  +------------------------------------+
90|                                    |
  |      X                             |
80|     X X                            |
  |     X X                            |
70|     X X                            |
  |    X  X                            |
60|    X  X                            |
  |    X  X                            |
50|   X    X                           |
  |   X    X                           |
40|   X     X                          |
  |   X     X                          |
30|   X     X                          |
  |   X      X                         |
20|   X       XX                       |
  |  XX         XX                     |
10| XX            XXXX                 |
  |XX                 XXXXXXXXXXXXXXXXX|
  +------------------------------------+
              5         10          15
      AS Path Length in IPv4
      
X Axis = unique AS Paths in millions
       
      ]]></artwork>
        </figure></t>
            
<t><list style="symbols">
            <t>Don't prepend ASNs that you don't own.</t>
            <t>Don't prepend if your AS is single homed.</t>
            <t>Prepending-to-all is a self-inflicted and needless risk that serves little purpose. Those excessively prepending their routes 
        should consider this risk and adjust their routing configuration.</t>
            <t>The Internet is typically around 5 ASs deep with the largest AS_PATH being 16-20 ASNs. Some have 
      added 100 or more AS Path Prepends and operators should therefore consider limiting the maximum AS-path 
      length being accepted through aggressive filter policies.</t>
                         </list></t>
                         
    </section>

    <section title="IANA Considerations">
      <t></t>
    </section>

    <section title="Security Considerations">
      <t/>
      <t>Long prepending may make a network more vulnernable to route hijacking which will exist whenever there is 
      a well connected peer that is willing to forge their AS_PATH or allows announcements with a fabricated AS path.
      Accepting routes with extremely long AS_PATHs may cause increased memory usage and possible router crashes.
      Using Autonomous System Provider Authorization (ASPA) objects in the Resource Public Key Infrastructure (RPKI), to verify the 
      BGP AS_PATH attribute of advertised routes, would provide detection and mitigation of route leaks and improbable AS paths.</t>
      <t>For a more comprehensive discussion of BGP Operations and Security, see <xref target="RFC7454"/>.   </t>
    </section>

    <section title="Acknowledgement">
      <t/>

      <t>The authors would like to thank Greg Skinner, Randy Bush, David Farmer, 
      Nick Hilliard, Martijn Schmidt, Michael Still, Geoff Huston, Jeffrey Haas, Alejandro Acosta and Martin Pels for contributing to this document.</t>
    </section>
  </middle>
    
     <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119"?>
      <?rfc include='reference.RFC.4271'?>
      <?rfc include='reference.RFC.7454'?>
    </references>
    
    <references title="Informative References">
      <?rfc include='reference.RFC.5398'?>
      <?rfc include='reference.RFC.8195'?>
      <?rfc include='reference.RFC.5737'?>
      
      <reference anchor="Path Prepending in BGP"
                 target="https://labs.apnic.net/index.php/2019/10/27/path-prepending-in-bgp/">
        <front>
          <title>Path Prepending in BGP</title>
          <author initials="J." surname="Huston">
            <organization/>
          </author>
          <date year="2019"/>
        </front>
        <seriesInfo name="Article" value="APNIC"/>
      </reference>      
      
      <reference anchor="Excessive AS Path Prepending"
                 target="https://blog.apnic.net/2019/07/15/excessive-bgp-as-path-prepending-is-a-self-inflicted-vulnerability/">
        <front>
          <title>Excessive AS Path Prepending</title>
          <author initials="D." surname="Madory">
            <organization/>
          </author>
          <date year="2019"/>
        </front>
        <seriesInfo name="Article" value="APNIC"/>
      </reference>            
      
    </references>

  </back>
</rfc>
