CBOR tags for IPv4 and IPv6 addresses and prefixesSandelman Software Worksmcr+ietf@sandelman.caUniversität Bremen TZIGermanycabo@tzi.org
Internet
CBOR Working GroupInternet-DraftThis specification defines two CBOR Tags to be used with IPv6 and IPv4 addresses and prefixes.RFC-EDITOR-please-remove: This work is tracked at https://github.com/cbor-wg/cbor-network-addressIntroduction defines a number of CBOR Tags for common items.
Tags 260 and 261 were later defined through IANA .
These tags cover addresses (260), and prefixes (261).
Tag 260 distinguishes between IPv6, IPv4 and Ethernet through the length of the byte string only.
Tag 261 was not documented well enough to be used.This specification defines tags 54 and 52.
These new tags are intended to be used in preference to tags 260 and
261.
They provide formats for IPv6 and IPv4 addresses, prefixes,
and addresses with prefixes, achieving an explicit indication of IPv6 or IPv4.
The prefix format omits trailing zeroes in the address part.
(Due to the complexity of testing, the value of omitting trailing
zeros for the pure address format was considered non-essential and
support for that is not provided in this specification.)
This specification does not deal with 6- or 8-byte Ethernet addresses.TerminologyThe key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL
NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED",
"MAY", and "OPTIONAL" in this document are to be interpreted as
described in BCP 14 when, and only when, they
appear in all capitals, as shown here.ProtocolThree FormsAddressesThese tags can be applied to byte strings to represent a single address.This form is called the Address Format.PrefixesWhen applied to an array that starts with an unsigned integer, they represent a
CIDR-style prefix of that length.When the Address Format (i.e., without prefix) appears in a context where a prefix is expected, then it is to be assumed that all bits are relevant.
That is, for IPv4, a /32 is implied, and for IPv6, a /128 is implied.This form is called the Prefix Format.Interface DefinitionWhen applied to an array that starts with a byte string, which stands
for an IP address, followed by an unsigned integer giving the bit
length of a prefix built out of the first length bits of the
address, they represent information that is commonly used to specify
both the network prefix and the IP address of an interface.This form is called the Interface Format.IPv6IANA has allocated tag 54 for IPv6 uses.
(Note that this is the ASCII code for '6'.)An IPv6 address is to be encoded as a sixteen-byte byte string
(, major type 2), enclosed in Tag number 54.For example:An IPv6 prefix, such as 2001:db8:1234::/48 is to be encoded as a two element array, with the length of the prefix first.
Trailing zero bytes MUST be omitted.For example:An IPv6 address combined with a prefix length, such as being used for
configuring an interface, is to be encoded as a two element array,
with the (full-length) IPv6 address first and the length of the
associated network the prefix next.For example:Note that the address-with-prefix form can be reliably distinguished
from the prefix form only in the sequence of the array elements.IPv4IANA has allocated tag 52 for IPv4 uses.
(Note that this is the ASCII code for '4'.)An IPv4 address is to be encoded as a four-byte byte string
(, major type 2), enclosed in Tag number 52.For example:An IPv4 prefix, such as 192.0.2.0/24 is to be encoded as a two element array, with the length of the prefix first.
Trailing zero bytes MUST be omitted.For example:An IPv4 address combined with a prefix length, such as being used for
configuring an interface, is to be encoded as a two element array,
with the (full-length) IPv4 address first and the length of the
associated network the prefix next.For example, 192.0.2.1/24 is to be encoded as a two element array,
with the length of the prefix (implied 192.0.2.0/24) last.Note that the address-with-prefix form can be reliably distinguished
from the prefix form only in the sequence of the array elements.Encoder Considerations for PrefixesFor the byte strings used in representing prefixes,
an encoder MUST omit any right-aligned (trailing) sequence of bytes that are all zero.There is no relationship between the number of bytes omitted and the prefix length.
For instance, the prefix 2001:db8::/64 is encoded as:An encoder MUST take care to set all trailing bits in the final byte
to zero, if any. While decoders are expected to ignore them, such garbage entities could be used as a covert channel, or may reveal the state of what would otherwise be private memory contents. So for example, 2001:db8:1230::/44
MUST be encoded as:even though variations like:would be parsed in the exact same way.The same considerations apply to IPv4 prefixes.Decoder Considerations for PrefixesA decoder MUST consider all bits to the right of the prefix length to be zero.A decoder MUST handle the case where a prefix length specifies that more bits are relevant than are actually present in the byte-string. As a pathological case, ::/128 can be
encoded asA recommendation for implementations is to first create an array of 16 (or 4) zero bytes.Then taking whichever is smaller between (a) the length of the
included byte-string, and (b) the number of bytes covered by the
prefix-length rounded up to the next multiple of 8: fail if that
number is greater than 16 (or 4), and then copy that many bytes from
the byte-string into the array.Finally, looking at the last three bits of the prefix-length in bits
(that is, the prefix-length modulo 8), use a static array of 8 values
to force the lower, non-relevant bits to zero, or simply:
unused_bits = (-prefix_length_in_bits) & 7;
if (length_in_bytes > 0)
address_bytes[length_in_bytes - 1] &= (0xFF << unused_bits);
A particularly paranoid decoder could examine the lower non-relevant bits to determine if they are non-zero, and reject the prefix.
This would detect non-compliant encoders, or a possible covert channel.
if (length_in_bytes > 0 &&
(address_bytes[length_in_bytes - 1] & ~(0xFF << unused_bits))
!= 0)
fail();
CDDLFor use with CDDL , the typenames defined in
are recommended:Security ConsiderationsIdentifying which byte sequences in a protocol are addresses may allow an attacker or eavesdropper to better understand what parts of a packet to attack.
That information, however, is likely to be found in the relevant RFCs anyway, so this is not a significant exposure.The right-hand bits of the prefix, after the prefix-length, are ignored by this protocol.
A malicious party could use them to transmit covert data in a way that would not affect the primary use of this encoding.
Such abuse would be detected by examination of the raw protocol bytes.
Users of this encoding should be aware of this possibility.IANA ConsiderationsIANA has allocated two tags from the Specification Required area of
the Concise Binary Object Representation (CBOR) Tags :Tag 54 - IPv6Tag 52 - IPv4Tags 260 and 261IANA is requested to add the note "DEPRECATED in favor of 52 and 54" to registrations 260 and 261"ReferencesNormative ReferencesConcise Binary Object Representation (CBOR)The Concise Binary Object Representation (CBOR) is a data format whose design goals include the possibility of extremely small code size, fairly small message size, and extensibility without the need for version negotiation. These design goals make it different from earlier binary serializations such as ASN.1 and MessagePack.This document obsoletes RFC 7049, providing editorial improvements, new details, and errata fixes while keeping full compatibility with the interchange format of RFC 7049. It does not create a new version of the format.Concise Data Definition Language (CDDL): A Notational Convention to Express Concise Binary Object Representation (CBOR) and JSON Data StructuresThis document proposes a notational convention to express Concise Binary Object Representation (CBOR) data structures (RFC 7049). Its main goal is to provide an easy and unambiguous way to express structures for protocol messages and data formats that use CBOR or JSON.Key words for use in RFCs to Indicate Requirement LevelsIn many standards track documents several words are used to signify the requirements in the specification. These words are often capitalized. This document defines these words as they should be interpreted in IETF documents. This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.Ambiguity of Uppercase vs Lowercase in RFC 2119 Key WordsRFC 2119 specifies common key words that may be used in protocol specifications. This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the defined special meanings.Informative ReferencesConcise Binary Object Representation (CBOR) TagsIANAChangelog
03
02
01 added security considerations about covert channel