<?xml version="1.0" encoding="US-ASCII"?>
<!DOCTYPE rfc SYSTEM 'rfc2629.dtd'>

<?rfc rfcedstyle="yes" ?>
<?rfc symrefs="yes" ?>
<?rfc sortrefs="yes" ?>

<rfc number="4808" category="info">
	<front>
		<title abbrev='TCP-MD5 Key Change'>
			Key Change Strategies for TCP-MD5
		</title>
		<author initials="S.M." surname="Bellovin"
		    fullname="Steven M. Bellovin">
			<organization>
				Columbia University
			</organization>
			<address>
				<postal>
					<street>1214 Amsterdam Avenue</street>
					<street>MC 0401</street>
					<city>New York</city>
					<region>NY</region>
					<code>10027</code>
					<country>US</country>
				</postal>
				<phone>+1 212 939 7149</phone>
				<email>bellovin@acm.org</email>
			</address>
		</author>
		<date month="March" year="2007" />
		<abstract>
		<t>
			The TCP-MD5 option is most commonly used to secure
			BGP sessions between routers.  However, changing
			the long-term key is difficult, since the change
			needs to be synchronized between different
			organizations.
			We describe single-ended strategies that will permit
			(mostly) unsynchronized key changes.
		</t>
		</abstract>
	</front>

	<middle>
<?rfc needLines="25" ?>
		<section title='Introduction' anchor='intro'>
		<t>
			The TCP-MD5 option <xref target="RFC2385"/>
			is most commonly used to secure
			BGP sessions between routers.  However, changing
			the long-term key is difficult, since the change
			needs to be synchronized between different
			organizations.
			Worse yet, if the keys are out of sync,
			it may break the connection between the
			two routers, rendering repair attempts difficult.
		</t>
		<t>
			The proper solution involves some sort of
			key management protocol.  
			Apart from the complexity of such things,
			RFC 2385 was not written with key changes
			in mind.  In particular, there is no
			KeyID field in the option, which means that
			even a key management protocol would run
			into the same problem.
		</t>
		<t>
			Fortunately, a heuristic permits key
			change despite this protocol deficiency.
			The change can be installed unilaterally at
			one end of a connection; it is fully
			compatible with the existing protocol.
		</t>
		<section title="Terminology">
			<t>
				The key words "MUST", "MUST NOT",
				"REQUIRED", "SHALL", "SHALL NOT",
				"SHOULD", "SHOULD NOT", "RECOMMENDED",
				"MAY", and "OPTIONAL" in this
				document are to be interpreted as
				described in <xref target="RFC2119"/>.
			</t>
		</section>
		</section>
		<section title='The Algorithm'>
		<t>
			Separate algorithms are necessary for
			transmission and reception.  Reception is
			easier; we explain it first.
		</t>
			<section title='Reception'>
			<t>
				A receiver has a list of valid keys.  Each
				key has a (conceptual)
				timestamp associated with it.
				When a segment arrives, each key is tried in
				turn.  The segment is discarded if and only if
				it cannot be validated by any key in the list.
			</t>
			<t>
				In principle, there is no need to test
				keys in any particular order.  For performance
				reasons, though, a simple most-recently-used (MRU) strategy --
				try the last valid key first -- should
				work well.  More complex mechanisms,
				such as examining the TCP sequence number
				of an arriving segment to see whether it
				fits in a hole, are almost certainly
				unnecessary.  On the other hand,
				validating that a received segment is putatively
				legal, by checking its sequence number
				against the advertised window, can help
				avoid denial of service attacks.
			</t>
			<t>
				The newest key that has successfully
				validated a segment is marked as the
				"preferred" key; see below.
			</t>
			<t>
				Implicit in this scheme is the assumption
				that older keys will eventually be
				unneeded and can be removed.  Accordingly, 
				implementations SHOULD provide an
				indication of when a key was last
				used successfully.
			</t>
			</section>
			<section title='Transmission' anchor='transmission'>
			<t>
				Transmission is more complex, because
				the sender does not know which keys
				can be accepted at the far end.
				Accordingly, the conservative strategy
				is to delay using any new keys for
				a considerable amount of time, probably
				measured in days.  This time interval
				is the amount of asynchronicity the
				parties wish to permit; it is agreed upon
				out of band and configured manually.
			</t>
			<t>
				Some automation is possible, however.
				If a key has been used successfully to 
				validate an incoming segment, clearly the
				other side knows it.  Accordingly, any
				key marked as "preferred" by the receiving
				part of a stack
				SHOULD be used for transmissions.
			</t>
			<t>
				A sophisticated implementation could
				try alternate keys if the TCP retransmission
				counter gets too high.  (This is analogous
				to dead gateway detection.)
				In particular, if a key change has just
				been attempted but such segments are
				not acknowledged, it is reasonable to fall
				back to the previous key and issue an
				alert of some sort.  
				Similarly, an implementation with a new
				but unused key could occasionally try to
				use it, much in the way that TCP implementations
				probe closed windows.  Doing this avoids
				the "silent host" problem discussed in
				<xref target='single' />.
				This should be done
				at a moderately slow rate.  
			</t>
			<t>
				Note that there is an ambiguity when an
				acknowledgment is received for a segment
				transmitted with two different keys.
				The TCP Timestamp option
				<xref target="RFC1323"/> can be used
				for disambiguation.
			</t>
			</section>
		</section>
		<section title="Operations">
			<section title="Single-Ended Operations" anchor="single">
			<t>
				Suppose only one end of the connection
				has this algorithm implemented.  The new
				key is provisioned on that system, with
				a start time far in the future -- sufficiently
				far, in fact, that it will not be used
				spontaneously.  After the key is ready,
				the other end is notified, out-of-band,
				that a key change can commence.
			</t>
			<t>
				At some point, the other end is upgraded.
				Because it does not have multiple keys
				available, it will start using the new
				key immediately for its transmission, and
				will drop all segments that use the old key.
				As soon as it tries to transmit, the
				upgraded side will designate the new key
				as preferred, and will use it for all of
				its transmissions.  Note specifically that
				this will include retransmissions of
				any segments rejected because they used the
				old key.  
			</t>
			<t>
				There is a problem if the unchanged machine
				is a "silent host" -- a host
				that has nothing to say, and hence does
				not transmit.  The best way to avoid this
				is for an upgraded machine to try a
				variety of keys in the event of repeated
				unacknowledged packets, 
				and to probe for new unused keys during silent
				periods, as discussed in 
				<xref target='transmission'/>.
				Alternatively, application-level
				KeepAlive messages may be used to ensure
				that neither end of the connection is
				completely silent.  See, for example,
				Section 4.4 of <xref target='RFC4271'/>
				or Section 3.5.4 of <xref target='RFC3036'/>.
			</t>
			</section>
			<section title="Double-Ended Operations">
			<t>
				Double-ended operations are similar, save
				that both sides deploy the new key at
				about the same time.  One should be
				configured to start using the new
				key at a point where it is reasonably
				certain that the other side would have
				it installed, too.  Assuming that
				has in fact happened, the new key
				will be marked "preferred" on both
				sides.
			</t>
			</section>
			<section title='Monitoring'>
			<t>
				As noted, implementations should monitor
				when a key was last used for transmission
				or reception.  Any monitoring mechanism
				can be used; most likely, it will be
				one or both of a MIB object or
				objects and the
				vendor's usual
				command-line mechanism for displaying
				data of this type.  Regardless, the
				network operations center should keep
				track of this.  When a new key has
				been used successfully for both transmission
				and reception for a reasonable amount of
				time -- the exact value isn't crucial,
				but it should probably be longer than
				twice the maximum segment lifetime -- the
				old key can be marked for deletion.  There
				is an implicit assumption here that
				there will not be substantial overlap
				in the usage period of such keys; monitoring
				systems should look for any such anomalies,
				of course.
			</t>
			</section>
		</section>
		<section title="Moving Forward">
		<t>
			As implied in <xref target="intro"/>,
			this is an interim strategy, intended to make
			TCP-MD5 operationally usable today.  We do not
			suggest or recommend it as a long-term solution.
			In this section, we make some suggestions about
			the design of a future TCP authentication option.
		</t>
		<t>
			The first and most obvious change is to
			replace keyed MD5 with a stronger MAC
			<xref target='RFC4278'/>.
			Today, HMAC-SHA1 <xref target='RFC4634'/> is
			the preferred choice, though others such as 
			UMAC <xref target='RFC4418'/> should be considered
			as well.
		</t>
		<t>
			A new authentication option should contain some form
			of a Key ID field.  Such an option would permit
			unambiguous identification of which key was used to
			create the MAC for a given segment, sparing the
			receiver the need to engage in the sort of heuristics
			described here.
			A Key ID is useful with
			both manual and automatic key management.
			(Note carefully that we do not prescribe any
			particular Key ID mechanism here.  Rather, we are
			stating a requirement: there must be a simple,
			low-cost way to select a particular key, and it must
			be possible to rekey without tearing down
			long-lived connections.)
		</t>
		<t>
			Finally, an automated key management mechanism
			should be defined.  The general reasoning
			for that is set forth in <xref target='RFC4107'/>;
			specific issues pertaining to BGP and TCP are given
			in <xref target='RFC3562'/>.
		</t>
		</section>
		<section title="Security Considerations">
		<t>
			In theory, accepting multiple keys simultaneously
			makes life easier for an attacker.  In practice,
			if the recommendations in 
			<xref target='RFC3562'/> are followed, this
			should not be a problem.
		</t>
		<t>
			New keys must be communicated securely.
			Specifically, new key messages must be
			kept confidential and must be properly
			authenticated.
		</t>
		<t>
			Having multiple keys makes CPU denial-of-service
			attacks easier.  This suggests that keeping the
			overlap period reasonably
			short is a good idea.  In
			addition, the Generalized TTL Security Mechanism 
			<xref target="RFC3682" />, if applicable to
			the local topology, can help.
			Note that most of the time, only one key will exist;
			virtually all of the remaining time
			there will be only two keys in existence.
		</t>
		</section>
		<section title="IANA Considerations">
		<t>
			There are no IANA actions required.  The TCP-MD5
			option number is defined in 
			<xref target='RFC2385'/>, and is currently
			listed by IANA.
		</t>
		</section>
		<section title="Acknowledgments">
		<t>
			I'd like to thank
				Ron Bonica,
				Randy Bush,
				Ross Callon,
				Rob Evans,
				Eric Rescorla,
				and
				Sam Weiler
			for their comments and inspiration.
		</t>
		</section>
	</middle>
	<back>
<?rfc needLines="10" ?>
	<references title='Normative References'>
	<?rfc include="reference.RFC.1323.xml" ?>
	<?rfc include="reference.RFC.2119.xml" ?>
	<?rfc include="reference.RFC.2385.xml" ?>
	</references>
	<references title='Informative References'>
	<?rfc include="reference.RFC.3036.xml" ?>
	<?rfc include="reference.RFC.3562.xml" ?>
	<?rfc include="reference.RFC.3682.xml" ?>
	<?rfc include="reference.RFC.4107.xml" ?>
	<?rfc include="reference.RFC.4271.xml" ?>
	<?rfc include="reference.RFC.4278.xml" ?>
	<?rfc include="reference.RFC.4418.xml" ?>
	<?rfc include="reference.RFC.4634.xml" ?>
	</references>
	</back>
</rfc>
