A BGP session is a long-lived TCP connection on port 179, and anyone who can inject or spoof packets into it can reset it, flood the routing process or, at worst, tamper with the routes it carries. Three IETF mechanisms protect the session itself: the TCP MD5 Signature Option (RFC 2385), the TCP Authentication Option, TCP-AO (RFC 5925), and the Generalized TTL Security Mechanism, GTSM (RFC 5082). This guide compares them as protocols, explains how TCP-AO key rollover works and why MD5 keys rarely change, and sets out a vendor-neutral deployment and key management approach. It is written for network engineers running eBGP and iBGP at the enterprise edge, in data centres, at internet exchanges and in provider networks. Route origin and path validation are a separate problem covered in the BGP and Routing Security Guide.
Key takeaways
- Layer the controls. A control-plane ACL for TCP 179, GTSM on directly connected peers and TCP-AO or MD5 authentication address different threats; RFC 7454 (BCP 194) recommends the ACL and GTSM and says TCP-AO "SHOULD be preferred when implemented".
- MD5 is legacy but common. RFC 5925 obsoletes RFC 2385, yet MD5 remains the most used option because both ends support it; it has no key identifier, so hitless key change depends on implementation tricks.
- TCP-AO fixes the key problem. KeyID and RNextKeyID allow key changes "with zero segment loss", per-connection traffic keys and replay protection for long-lived sessions, with HMAC-SHA-1-96 and AES-128-CMAC-96 as mandatory algorithms.
- GTSM is cheap and effective, within limits. Requiring TTL or Hop Limit 255 on arrival blocks spoofed packets from off-link hosts, but it is "not a substitute for authentication" and offers little on multihop sessions.
- The keys are the weak point. Session keys are shared secrets that are often set once and never rotated; treat them like any other machine credential with an owner, a vault and a rotation schedule.
Threats to BGP sessions
BGP runs over TCP, so it inherits TCP's exposure. The table separates threats to the session from threats to routing content, because session protection only addresses the first group.
| Threat | Effect | Session control that helps | Not addressed by session controls |
|---|---|---|---|
| Spoofed TCP RST or SYN from a remote host | Session reset, route withdrawal and flapping | TCP-AO or MD5 (segments without a valid MAC are discarded); GTSM; ACL | Covered by the session control |
| Packet flood at TCP 179 (CPU exhaustion) | Routing process starves, sessions drop | ACL and rate limiting; GTSM drops off-link packets before expensive processing | Volumetric attacks on links (ATT&CK T1498 Network Denial of Service) |
| Injected or modified segments by an on-path attacker | False updates or session disruption | TCP-AO or MD5 integrity check | Confidentiality: neither option encrypts |
| Replay of captured segments | Disruption of long-lived sessions | TCP-AO (sequence number extension) | Covered by the session control |
| Unauthorised router forming a session | Route injection from a rogue speaker | Authentication keys; neighbour ACL; explicit peer configuration | Covered by the session control |
| Hijacks and route leaks from a legitimate peer | Traffic misdirection | None: the peer is authenticated | Needs RPKI, prefix filters and ASPA; see RPKI vs BGP Prefix Filtering |
RFC 6952 adds the operational threat: access lists alone do not stop spoofing or man-in-the-middle attacks on BGP sessions, and static keys that never change become guessable or exposed over time, for example when an administrator who knew them leaves.
Before any authentication, RFC 7454 says the device SHOULD "discard all packets directed to TCP port 179 on the local device and sourced from an address not known or permitted" to be a neighbour, and MAY rate-limit BGP traffic. Apply this in the control-plane policy (CoPP or the equivalent loopback filter) on every BGP speaker.
TCP MD5
RFC 2385 (August 1998) defines TCP option Kind 19, Length 18, carrying a 16-byte MD5 digest in every segment. The digest covers the TCP pseudo-header, the TCP header without options (checksum zeroed), the segment data and a shared key. Implementations should accept printable ASCII keys of up to 80 bytes.
- Weaknesses: the RFC itself notes MD5 is vulnerable to collision search and that some consider it too weak; there is no algorithm field, so the hash cannot be upgraded; and every connection between a pair uses the same key directly.
- No key identifier: keys can change mid-connection only if both ends synchronise. RFC 4808 (Informational, March 2007) describes the interim workaround: the receiver accepts a list of keys and tries each one, while the sender switches to a new key after an agreed period or once that key has validated an incoming segment. It warns that accepting multiple keys eases CPU denial of service, so the overlap should be short, and that silent peers make it hard to tell whether the new key works.
- Status: RFC 5925 obsoletes RFC 2385, and RFC 7454 calls MD5 superseded but "still the most used mechanism due to its availability in vendors' equipment".
In practice, MD5 key changes on most platforms reset the session unless the platform implements key chains with overlapping accept and send lifetimes. That reset cost is the main reason MD5 keys at internet exchanges and with transit providers often stay unchanged for years.
TCP-AO
RFC 5925 (Standards Track, June 2010) uses option Kind 29. It was designed to replace MD5 with stronger, agile algorithms and proper key management hooks.
- Master Key Tuple (MKT): each MKT holds the socket pair it applies to, a flag for whether TCP options are included in the MAC, a SendID and RecvID, the master key, and the KDF and MAC algorithms. Components "MUST NOT change during a connection"; you add a new MKT instead.
- Traffic keys: derived from the MKT, the IP addresses, ports and both Initial Sequence Numbers, so every connection gets unique keys even when the master key is reused.
- KeyID and RNextKeyID: each segment says which MKT produced its MAC (KeyID) and which MKT the sender is ready to receive next (RNextKeyID). This is what allows key changes "with zero segment loss".
- Replay protection: a 32-bit Sequence Number Extension emulates a 64-bit sequence space, protecting very long-lived sessions such as BGP.
- Algorithms: RFC 5926 makes HMAC-SHA-1-96 and AES-128-CMAC-96 mandatory for MACs, with KDF_HMAC_SHA1 and KDF_AES_128_CMAC as KDFs. The default MAC is 96 bits, so the option is 16 bytes, 2 shorter than MD5.
- Out of scope: TCP-AO does not negotiate keys or parameters, does not encrypt and does not authenticate ICMP. Master keys are configured manually or by an out-of-band system.
- No mixing: "An endpoint MUST NOT use TCP-AO for the same connection in which TCP MD5 is used."
TCP-AO key rollover
- Configure a new MKT (new KeyID and master key) on both routers alongside the existing one. Both remain valid for receipt.
- On one router, set the new KeyID as the preferred next key. That router advertises it in RNextKeyID.
- The peer sees the RNextKeyID and starts sending with the new MKT; once both directions use the new key, traffic continues without a reset.
- Confirm in the session statistics that segments are being authenticated with the new KeyID and that the authentication failure counters are not rising.
- Remove the old MKT from both routers after an agreed grace period.
Many platforms express this as a key chain with send and accept lifetimes per key. Keep accept lifetimes overlapping by at least the time needed to update both ends, and agree the KeyID numbering with external peers, because SendID and RecvID must match across the session.
Interoperability notes
- Algorithms: use one of the two RFC 5926 mandatory MACs with external peers. Extensions such as HMAC-SHA-256 only interoperate when both sides derive keys the same way and use the same MAC length, as the Linux kernel documentation warns.
- Include options flag: both ends must agree whether TCP options are covered by the MAC; a mismatch fails every segment.
- Key encoding: agree whether the master key is entered as ASCII or hexadecimal; the same string encoded differently produces different keys.
- Migration from MD5: a connection cannot move from MD5 to TCP-AO, so migration requires a planned session reset. Some stacks let a listening socket accept both AO and MD5 peers, but a single peer cannot have keys of both types.
- Open source routing stacks: TCP-AO depends on the operating system's TCP implementation; confirm kernel and routing daemon support before planning, and treat support as per platform and release.
GTSM
RFC 5082 (Standards Track, October 2007, obsoleting the Experimental RFC 3682) relies on routers decrementing TTL. Both peers send BGP packets with TTL (IPv4) or Hop Limit (IPv6) 255; the receiver accepts packets for that session only if they arrive with 255, which means they most likely came from a directly connected neighbour. Packets for the session with any other value are classified "Dangerous" and can be dropped early, before they cost CPU.
- Where it fits: RFC 7454 says operators "SHOULD implement TTL security on directly connected BGP peerings". It must be configured on both ends.
- Multihop: the RFC 5082 multihop check (accepting 255 minus a configured hop count) is non-normative, and RFC 7454 notes that anyone inside the TTL diameter could spoof the TTL, so for iBGP between loopbacks rely on authentication and ACLs rather than GTSM.
- Limits: GTSM does not stop an attacker on the same link, does not prevent replay or on-path tampering, and can be defeated by some tunnel types.
Mechanisms compared
| Property | TCP MD5 (RFC 2385) | TCP-AO (RFC 5925, 5926) | GTSM (RFC 5082) |
|---|---|---|---|
| What it provides | Segment integrity and peer authentication with a shared key | Segment integrity, peer authentication, replay protection | Filtering of spoofed packets from off-link sources |
| Algorithm | MD5, fixed | HMAC-SHA-1-96 or AES-128-CMAC-96 (agile) | None (TTL check) |
| TCP option | Kind 19, 18 bytes | Kind 29, 16 bytes by default | None |
| Hitless key change | Implementation dependent (RFC 4808 workaround) | Built in (KeyID, RNextKeyID) | No keys |
| Per-connection keys | No | Yes (traffic keys from ISNs) | Not applicable |
| Encryption | No | No | No |
| Best use | Peers that only support MD5 | Default for new sessions where both ends support it | Every directly connected eBGP session, alongside authentication |
| IETF standing | Obsoleted by RFC 5925 | Preferred by RFC 7454 when implemented | Recommended by RFC 7454 for direct peers |
Key management for sessions
BGP session keys are machine credentials. RFC 6952 observes that routers with static keys often never change them because coordinating a pair is hard. Treat them as follows:
- Generate, do not invent: use random keys of at least 128 bits of entropy (for example 32 hexadecimal characters), unique per peering. Never reuse one key across an exchange or across customers.
- Store centrally: keep keys in a secrets vault referenced by your network automation, not in spreadsheets, tickets or email. Restrict who can read router configuration, since some platforms store session keys in a reversible form. See the Network Automation Security guide.
- Exchange securely: share keys with external peers over an encrypted channel or the peer's portal, never in the same email as the session details.
- Rotate on a schedule and on events: rotate TCP-AO keys on a defined period (for example annually) and immediately when staff with access leave, a configuration backup is exposed or a peer reports compromise.
- Own every key: record owner, peer, KeyID, creation date and next rotation date in your inventory. The Secrets Rotation Runbook Template can be adapted for peering keys.
Deployment approach
- Inventory sessions: list every BGP session with peer type (IXP route server, bilateral IXP, transit, customer, iBGP, data centre fabric), current protection and both ends' TCP-AO support.
- Apply the control-plane ACL and rate limiting on all BGP speakers first; this needs no peer coordination. Test in a lab, then deploy with logging to catch legitimate peers you missed.
- Enable GTSM on directly connected eBGP sessions, coordinated with each peer. Watch session state during the change window; a mismatch drops the session, and rollback is removing the setting on your side.
- Turn on TCP-AO for internal sessions (iBGP, fabric underlay and overlay) where you control both ends, starting with a pilot pair, then a region.
- Offer TCP-AO to external peers at the next maintenance or onboarding; keep MD5 only where the peer cannot support AO, and record those exceptions.
- Rehearse rollover: perform one TCP-AO key change on the pilot pair and confirm no session reset before rolling out schedules.
- Rollback plan: each change has a tested reversal (remove GTSM, revert to the previous key), and peer contacts are confirmed before the window. RFC 7454 notes session protection adds configuration and management overhead, so automate it.
Enterprises with two transit providers should prioritise the ACL, GTSM and authentication on those few sessions. Providers and large exchanges should automate key generation and peer onboarding so every new session gets TCP-AO or a documented MD5 exception by default.
Detection and measurement
- Log: BGP session state changes, authentication failures (missing or invalid MAC), GTSM drops and control-plane ACL hits; forward them to your monitoring platform.
- Alert: on flapping sessions, sudden increases in authentication failures from a peer and ACL hits from unexpected sources on TCP 179.
| Metric | Target |
|---|---|
| BGP speakers with a TCP 179 control-plane ACL | 100% |
| Directly connected eBGP sessions with GTSM | 100% where the peer agrees |
| Sessions using TCP-AO | 100% internal; rising for external |
| Session keys older than the rotation period | Zero |
| Unique key per peering | 100% |
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | SC-7, SC-8, SC-23, IA-3, SC-12 | Boundary protection of the control plane, transmission integrity, session authenticity, device authentication, key management |
| NIST CSF 2.0 | PR.IR-01, PR.DS-02, DE.CM-01 | Network protection, data-in-transit integrity, network monitoring |
| MITRE ATT&CK | T1557 Adversary-in-the-Middle; T1498 Network Denial of Service | On-path tampering and floods against routing infrastructure |
| IETF BCP 194 | RFC 7454 sections 4 and 5 | Protecting the BGP speaker and the session |
Practitioner checklist
- Inventory every BGP session with its current protection and the peer's TCP-AO support.
- Filter TCP 179 to configured neighbours and rate-limit BGP traffic on every speaker.
- Enable GTSM on all directly connected eBGP peerings, on both ends.
- Use TCP-AO with an RFC 5926 mandatory algorithm for all internal sessions.
- Move external peers from MD5 to TCP-AO at the next window and record remaining MD5 exceptions.
- Generate unique random keys per peering and store them in a vault, not in tickets or email.
- Rehearse a hitless TCP-AO key rollover before setting rotation schedules.
- Rotate keys on schedule and immediately after staff changes or configuration exposure.
- Alert on authentication failures, GTSM drops and session flaps.
Standards and references
- IETF: RFC 5925, The TCP Authentication Option
- IETF: RFC 5926, Cryptographic Algorithms for TCP-AO
- IETF: RFC 5082, The Generalized TTL Security Mechanism (GTSM)
- IETF: RFC 7454, BGP Operations and Security (BCP 194)
- IETF: RFC 2385, Protection of BGP Sessions via the TCP MD5 Signature Option
- IETF: RFC 4808, Key Change Strategies for TCP-MD5
- IETF: RFC 6952, Analysis of BGP, LDP, PCEP and MSDP Issues According to the KARP Design Guide
- Linux kernel documentation: TCP Authentication Option Linux implementation
Related NHI Mgmt Group resources: BGP and Routing Security Guide · RPKI vs BGP Prefix Filtering · RTBH and BGP Flowspec DDoS Mitigation Guide · RPKI and Route Origin Validation Deployment Guide