RFC 2065
Domain Name System Security Extensions
part 1 of 9 ๐
Title Block ๐
okay bestie, this is RFC 2065 ๐ and its title is Domain Name System Security Extensions. It's a Standards Track doc, so it's a real protocol spec, not just vibes. D. Eastlake, 3rd (CyberCash) and C. Kaufman (Iris) wrote it, and it's dated January 1997. It updates RFC 1034 and RFC 1035 โจ
Status of this Memo ๐ฆ
this doc specifies an Internet standards track protocol for the Internet community, and it's basically begging for discussion and suggestions ๐ซถ For the standardization state and status of this protocol, check the current "Internet Official Protocol Standards" (STD 1) ๐ Distribution of this memo is unlimited, so share it with everyone ๐
Abstract ๐ธ
the Domain Name System (DNS) is a critical part of the Internet's infrastructure ๐ฅ but honestly? It has no strong security mechanisms to guarantee data integrity or authentication ๐ญ These extensions fix that for security aware resolvers and applications by using cryptographic digital signatures ๐ง The signatures live in secured zones as resource records. Even through non-security aware DNS servers, security can still be provided in many cases ๐
The extensions also let you store authenticated public keys in the DNS ๐๏ธ That storage can support general public key distribution as well as DNS security, which is so iconic. The stored keys let security aware resolvers learn the authenticating keys of zones beyond the ones they were first configured with. Keys tied to DNS names can be retrieved to support other protocols ๐ There's a whole range of key types and algorithms, too โจ
On top of all that, the security extensions provide for the optional authentication of DNS protocol transactions ๐
Acknowledgments ๐
the significant contributors to this document (listed in alphabetical order) get a huge thank you from the authors ๐ซถ
- Harald T. Alvestrand
- Madelyn Badger
- Scott Bradner
- Matt Crawford
- James M. Galvin
- Olafur Gudmundsson
- Edie Gunter
- Sandy Murphy
- Masataka Ohta
- Michael A. Patton
- Jeffrey I. Schiller
Table of Contents ๐บ๏ธ
1. Overview of Contents....................................3
2. Overview of the DNS Extensions.........................4
2.1 Services Not Provided..................................4
2.2 Key Distribution.......................................5
2.3 Data Origin Authentication and Integrity...............5
2.3.1 The SIG Resource Record..............................6
2.3.2 Authenticating Name and Type Non-existence...........7
2.3.3 Special Considerations With Time-to-Live.............7
2.3.4 Special Considerations at Delegation Points..........7
2.3.5 Special Considerations with CNAME RRs................8
2.3.6 Signers Other Than The Zone..........................8
2.4 DNS Transaction and Request Authentication.............8
3. The KEY Resource Record.................................9
3.1 KEY RDATA format......................................10
3.2 Object Types, DNS Names, and Keys.....................10
3.3 The KEY RR Flag Field.................................11
3.4 The Protocol Octet....................................13
3.5 The KEY Algorithm Number and the MD5/RSA Algorithm....13
3.6 Interaction of Flags, Algorithm, and Protocol Bytes...14
3.7 KEY RRs in the Construction of Responses..............15
3.8 File Representation of KEY RRs........................16
4. The SIG Resource Record................................16
4.1 SIG RDATA Format......................................17
4.1.1 Signature Data......................................19
4.1.2 MD5/RSA Algorithm Signature Calculation.............20
4.1.3 Zone Transfer (AXFR) SIG............................21
4.1.4 Transaction and Request SIGs........................22
4.2 SIG RRs in the Construction of Responses..............23
4.3 Processing Responses and SIG RRs......................24
4.4 Signature Expiration, TTLs, and Validity..............24
4.5 File Representation of SIG RRs........................25
5. Non-existent Names and Types...........................26
5.1 The NXT Resource Record...............................26
5.2 NXT RDATA Format......................................27
5.3 Example...............................................28
5.4 Interaction of NXT RRs and Wildcard RRs...............28
5.5 Blocking NXT Pseudo-Zone Transfers....................29
5.6 Special Considerations at Delegation Points...........29
6. The AD and CD Bits and How to Resolve Securely.........30
6.1 The AD and CD Header Bits.............................30
6.2 Boot File Format......................................32
6.3 Chaining Through Zones................................32
6.4 Secure Time...........................................33
7. Operational Considerations.............................33
7.1 Key Size Considerations...............................34
7.2 Key Storage...........................................34
7.3 Key Generation........................................35
7.4 Key Lifetimes.........................................35
7.5 Signature Lifetime....................................36
7.6 Root..................................................36
8. Conformance............................................36
8.1 Server Conformance....................................36
8.2 Resolver Conformance..................................37
9. Security Considerations................................37
References................................................38
Authors' Addresses........................................39
Appendix: Base 64 Encoding................................40
1. Overview of Contents ๐งญ
this doc extends the Domain Name System (DNS) protocol so it can do DNS security and public key distribution ๐ It assumes you already know the DNS well, especially as described in RFCs 1033, 1034, and 1035 ๐ค
Section 2 gives you the overview of the extensions and the three things they do: key distribution, data origin authentication and integrity, and transaction and request security ๐
Section 3 is all about the KEY resource record ๐ We cover its structure, how it's used in DNS responses, and how it's written in a file. These resource records represent the public keys of entities named in the DNS, and they're used for key distribution ๐
Section 4 is the SIG digital signature resource record โ๏ธ We look at its structure, how it shows up in DNS responses, and its file representation. These resource records authenticate other resource records in the DNS, and they can optionally authenticate DNS transactions and requests too ๐ฆ
Section 5 is the NXT resource record and how it works in DNS responses ๐ The NXT RR lets you prove, in an authenticated way, that a name doesn't exist, or that a particular type doesn't exist for a name that does ๐
Section 6 explains how a resolver can be set up with a starting key or keys and then go on to resolve DNS requests securely ๐ฅ It covers how resolvers and servers interact across every combination of security aware and security non-aware. It also defines two extra query header bits for signaling between resolvers and servers ๐
Section 7 looks at operational considerations like key generation, lifetime, and storage ๐ ๏ธ
Section 8 defines the levels of conformance for resolvers and servers ๐
Section 9 gives a few paragraphs on overall security considerations ๐ญ
There's an Appendix on base 64 encoding, which is used in the file representation of some RR's defined in this document ๐
2. Overview of the DNS Extensions โจ
the DNS protocol security extensions give you three distinct services ๐ First up is key distribution, which Section 2.2 covers below. Then there's data origin authentication, described in Section 2.3 below. Last is transaction and request authentication, described in Section 2.4 below. It's a whole trio ๐ซถ
Special considerations about "time to live", CNAMEs, and delegation points are also covered in Section 2.3 ๐ง
2.1 Services Not Provided ๐
it's part of the DNS's design philosophy that the data in it is public, and that the DNS gives the same answers to everyone who asks ๐ธ
Following that philosophy, nothing has been added to include access control lists or any other way of telling inquirers apart ๐ซ
Also, no effort has been made to provide confidentiality for queries or responses ๐คซ (This service may be available via IPSEC [RFC 1825].)
2.2 Key Distribution ๐
resource records (RRs) are defined to associate keys with DNS names ๐ This lets the DNS act as a public key distribution mechanism, which supports DNS data origin authentication and other security services ๐
The syntax of a KEY resource record (RR) is described in Section 3 โจ It includes an algorithm identifier, the actual public key parameters, and a bunch of flags. Those flags indicate the type of entity the key is associated with, and/or assert that there is no key associated with that entity ๐
Under the conditions described in Section 3.7, security aware DNS servers will automatically try to return KEY resources as additional information, alongside the resource records you actually asked for ๐ง That means fewer queries are needed, which is lowkey genius ๐
2.3 Data Origin Authentication and Integrity ๐
okay so the big idea here is signatures. Every resource record can get a cryptographically generated digital signature attached to it in the DNS. Usually there's one private key that signs for the whole zone ๐ซถ If a security aware resolver reliably learns the zone's public key, it can check that signed data from that zone was properly authorized and is reasonably current โจ The plan is to keep the zone private key offline and use it to re-sign every record in the zone every so often ๐
This data origin authentication key belongs to the zone, not to the servers holding copies of the data. So even if one server gets compromised (or even ALL the servers for a zone), that doesn't automatically wreck the resolver's confidence about whether data is genuine. Lowkey iconic design ๐
A resolver can learn a zone's public key either by reading it from DNS or by having it configured statically. To read it reliably from DNS, the key itself has to be signed ๐ง So for a reasonable level of security, the resolver needs at least the public key of one zone configured locally, so it can check signatures. From that starting point, it can securely pull in the public keys of other zones, as long as the zones in between are secure and their signed keys are reachable ๐ธ (ngl, it's more secure to manually configure the keys of several zones, because then one compromised zone can't fake info from the others. It's also way more annoying to manage, especially when keys change ๐ญ)
Adding origin authentication and integrity doesn't change the on-the-wire DNS protocol beyond adding the signature resource type and, practically, the key resource type needed for key distribution. Existing resolver and server implementations can support this as long as they can handle those extra resource types (see Section 8) ๐ The one exception: CNAME referrals from a secure zone can't be authenticated if they come from non-security aware servers (see Section 2.3.5) ๐
If you had to fetch every signature separately after getting the data, that'd mean extra trips to the server and slower performance ๐ To avoid that, security aware servers always try to send along the signature(s) that are needed โก
2.3.1 The SIG Resource Record ๐
The syntax for a SIG resource record (signature) is in Section 4 โจ It tells you the type of the RR(s) being signed, the name of the signer, when the signature was created, when it expires (after that it's no longer to be believed ๐ซ), its original time to live (this can be longer than the current TTL, but it can't be shorter), the cryptographic algorithm being used, and the actual signature itself ๐ฆ
Every name in a secured zone gets at least one SIG resource record for each resource type under that name. The exceptions are glue RRs and delegation point NS RRs ๐ A security aware server that supports the performance-enhanced version of the DNS protocol security extensions will try to return the matching SIGs along with the RRs it fetches. If a server doesn't support that, the resolver has to pull back ALL the SIG records for a name and pick out the one or ones that sign the RR(s) it actually cares about ๐ค
2.3.2 Authenticating Name and Type Non-existence ๐
Here's the tea: the security mechanism above only lets you sign RRs that already exist in a zone. "Data origin" authentication isn't obviously provided for a domain name that doesn't exist in a zone, or for a type that doesn't exist on a name that does exist ๐ณ That gap gets filled by the NXT RR, which authenticatably asserts a range of non-existent names in a zone, plus the non-existence of types for the name just before that range ๐งฉ
Section 5 below covers the NXT RR ๐
2.3.3 Special Considerations With Time-to-Live โณ
A digital signature stops verifying if anything about the data changes between the moment it was signed and the moment it's verified ๐ That's a problem, because we actually WANT the TTL field to tick down while records sit in caches ๐
You could leave the TTL out of the signature, but then sneaky servers could set absurdly long TTL values and nobody would notice ๐ฟ So instead, the signature includes the "original" TTL, and that value gets communicated alongside the current TTL. Sneaky servers can still mess with the TTL, but a security aware resolver caps the TTL it actually uses at the original signed value ๐ก๏ธ Signatures also carry a time signed and an expiration time. A resolver that knows the absolute time can securely figure out whether a signature has expired โฐ Still, signature expiration can't replace the TTL, because the TTL is mainly a database consistency mechanism. Plus, non-security aware servers that depend on TTL still have to be supported ๐ซ
2.3.4 Special Considerations at Delegation Points ๐ฟ
DNS security wants each zone to be one unit of data that's completely under the zone owner's control and signed with the zone's key ๐ฐ But the operational DNS sees the leaf nodes of a zone, which are also the apex nodes of a subzone (aka delegation points), as "really" belonging to the subzone ๐คทโโ๏ธ Those nodes show up in two master files and can have RRs signed by BOTH the upper and lower zone's keys. A retrieval could come back with a mix of those RRs and SIGs, especially since one server could be serving both the zone above and the zone below a delegation point ๐
Generally, there must be a zone KEY RR for the subzone in the superzone, and the copy signed in the superzone is the one that controls โ For all but one other RR type that should show up in both zones, the subzone's data is more authoritative. To avoid conflicts, only the KEY RR in the superzone should be signed, and the NS and any A (glue) RRs should only be signed in the subzone ๐ง The SOA and any other RRs whose owner is the zone name should only appear in the subzone, so they get signed there. The NXT RR type is the exception: it always appears differently and authoritatively in both the superzone and subzone (if both are secure), as described in Section 5 ๐
2.3.5 Special Considerations with CNAME RRs ๐
โ ๏ธ Heads up, bestie: there's a real problem when security related RRs share an owner name with a CNAME RR and get retrieved from a non-security-aware server ๐ฑ
Basically, an initial retrieval for the CNAME (or any other type) won't pull back any associated signature, key, or NXT RR ๐ โโ๏ธ For types other than CNAME, you get that type at the target name of the CNAME (or the chain of CNAMEs), and the CNAME gets returned as additional info. And if you do a specific retrieval for type SIG, you won't get the SIG at the original CNAME domain name, you'll get the SIG at the target name instead ๐
So the general rule is that security aware servers MUST be used to securely CNAME in DNS ๐ Security aware servers have to do three things: (1) allow KEY, SIG, and NXT RRs alongside CNAME RRs, (2) suppress CNAME processing when retrieving these types, as well as when retrieving the type CNAME, and (3) automatically return the SIG RRs that authenticate the CNAME or CNAMEs encountered while resolving a query โจ This is a glow-up from the previous DNS standard, which didn't allow any other RR type at a node where a CNAME RR was present ๐ โโ๏ธ
2.3.6 Signers Other Than The Zone ๐โโ๏ธ
There are two cases where a SIG resource record gets signed by something other than the zone private key ๐๏ธ The first is dynamic update, where an entity is allowed to authenticate and update its own records. The entity's public key has to be present in the DNS and appropriately signed, but the other RR(s) can be signed with the entity's key. The second is transaction and request authentication, which is covered in Section 2.4 right below ๐
2.4 DNS Transaction and Request Authentication ๐จ
The data origin authentication described above protects the resource records you retrieve, but it doesn't protect DNS requests or message headers ๐ฌ
If a server falsely sets header bits, there's honestly not a lot you can do about it ๐คทโโ๏ธ BUT, you CAN add transaction authentication ๐ That means a resolver can be sure it's actually getting messages from the server it thinks it queried, that the response matches the query it sent, and that nothing got diddled with in transit ๐ต๏ธโโ๏ธ You do this by optionally adding a special SIG resource record at the end of the reply, which digitally signs the concatenation of the server's response and the resolver's query ๐ฆ
Requests can be authenticated too, by including a special SIG RR at the end of the request. Honestly, authenticating requests doesn't do anything useful in the current DNS, and almost all current DNS servers just ignore requests with a non-empty additional information section ๐ That said, this syntax for signing requests is defined so it can be used for authenticating future secure dynamic update requests or things like that ๐ฎ
The private keys used for transaction and request security belong to the host composing the request or reply message, NOT to the zone involved ๐ฅ๏ธ The matching public key is normally stored in and retrieved from the DNS ๐ธ
Since requests and replies are super variable, message authentication SIGs can't be pre-calculated ๐ฎโ๐จ So the private key has to stay online, for example in software or in a directly connected piece of hardware ๐
3. The KEY Resource Record ๐
The KEY resource record (RR) is used to document a key associated with a Domain Name System (DNS) name ๐ It's a public key, since only public keys get stored in the DNS. That key can belong to a zone, a host or other end entity, or a user ๐งโ๐ป A KEY RR, like any other RR, is authenticated by a SIG RR ๐ซถ Security aware DNS implementations MUST be designed to handle at least two simultaneously valid keys of the same type associated with a name ๐
The type number for the KEY RR is 25 โจ
3.1 KEY RDATA format ๐
okay so the RDATA for a KEY RR is made of flags, a protocol octet, the algorithm number, and the public key itself ๐ here's the layout:
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| flags | protocol | algorithm |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| /
/ public key /
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-|
the meaning of the KEY RR owner name, flags, and protocol octet is explained in Sections 3.2, 3.3 and 3.4 below respectively ๐ง and the flags and algorithm must be examined before any data after the algorithm octet, because they control the format and even whether there's any following data at all ๐ the algorithm and public key fields get the tea in Section 3.5, and the format of the public key depends on the algorithm ๐
3.2 Object Types, DNS Names, and Keys ๐
the public key in a KEY RR belongs to the object named in the owner name โจ
this DNS name can refer to up to three different categories of things ๐ญ for example, dee.cybercash.com could be (1) a zone, (2) a host or other end entity , and (3) the mapping into a DNS name of the user or account dee@cybercash.com ๐ so there are flags (more on those below) in the KEY RR that tell you which of these roles the owner name and public key are linked to ๐ฅ also, an appropriate zone KEY RR MUST occur at the apex node of a secure zone and at every leaf node which is a delegation point (and thus the same owner name as the apex of a subzone) within a secure zone ๐
ngl, using the same name for all three categories is discouraged ๐ it's also possible to use the same key for different things with the same name or even different names, but that's strongly discouraged too ๐ซ especially because using a zone key as a non-zone key will usually mean the corresponding private key has to be kept on line, and that makes it more vulnerable ๐ฉ
in addition to the name type bits, there are extra flag bits, including the "type" field, the "experimental" bit, the "signatory" field, and so on, which get covered below ๐ฆ
3.3 The KEY RR Flag Field ๐
okay so here's the flags field, bit by bit ๐
in the "flags" field:
Bit 0 and 1 are the key "type" field. Bit 0 being a one means use of the key is prohibited for authentication. Bit 1 being a one means use of the key is prohibited for confidentiality. If this field is zero, then use of the key for authentication and/or confidentiality is permitted. Note that DNS security only makes use of keys for authentication ๐ the confidentiality use flagging is there for other protocols that use keys. Implementations not intended to support key distribution for confidentiality MAY require that the confidentiality use prohibited bit be on for keys they serve. If both bits of this field are one (the "no key" value), there is no key information and the RR stops after the algorithm octet. With this "no key" value, a signed KEY RR can authenticatably assert that, for example, a zone is not secured ๐ โโ๏ธ
Bit 2 is the "experimental" bit. It's ignored if the type field indicates "no key", and the following description assumes that type field is non-zero ๐งช keys may be associated with zones, entities, or users for experimental, trial, or optional use, in which case this bit will be one. If this bit is a zero, it means that the use or availability of security based on the key is "mandatory". So if this bit is off for a zone key, the zone should be assumed secured by SIG RRs, and any responses indicating the zone is not secured should be considered bogus ๐จ if this bit is a one for a host or end entity, it might sometimes operate in a secure mode and at other times operate without security ๐คทโโ๏ธ the experimental bit, like every other part of the KEY RR, only works if the KEY RR is appropriately signed by a SIG RR. The experimental bit must be zero for safe secure operation and should only be a one for a minimal transition period โณ
Bits 3-4 are reserved and must be zero. ๐
Bit 5 on indicates that this is a key associated with a "user" or "account" at an end entity, usually a host. The coding of the owner name is the same as the one used for the responsible individual mailbox in the SOA and RP RRs: the owner name is the user name as the name of a node under the entity name ๐งโ๐ป for example, "j.random_user" on host.subdomain.domain could have a public key associated through a KEY RR with the name j\.random_user.host.subdomain.domain, with the user bit set to one. It could be used in a security protocol where authentication of a user is wanted. This key might be useful in IP or other security for a user level service such as telnet, ftp, rlogin, etc. ๐
Bit 6 on indicates that this is a key associated with the non-zone "entity" whose name is the RR owner name. This will commonly be a host, but in some parts of the DNS tree it could be some other type of entity, such as a telephone number [RFC 1530] ๐ this is the public key used in connection with the optional DNS transaction authentication service if the owner name is a DNS server host. It could also be used in an IP-security protocol where authentication at the host level, rather than the user level, is wanted, such as routing, NTP, etc. ๐ฐ๏ธ
Bit 7 is the "zone" bit and indicates that this is a zone key for the zone whose name is the KEY RR owner name. This is the public key used for DNS data origin authentication ๐
Bit 8 is reserved to be the IPSEC [RFC 1825] bit and indicates that this key is valid for use with that security standard. This key could be used in connection with secured communication on behalf of an end entity or user whose name is the owner name of the KEY RR, if the entity or user bits are on. The presence of a KEY resource with the IPSEC and entity bits on and the experimental and no-key bits off is an assertion that the host speaks IPSEC ๐
Bit 9 is reserved to be the "email" bit and indicates that this key is valid for use with MIME security multiparts. This key could be used in connection with secured communication on behalf of an end entity or user whose name is the owner name of the KEY RR, if the entity or user bits are on ๐ง
Bits 10-11 are reserved and must be zero. ๐งธ
Bits 12-15 are the "signatory" field. If non-zero, they indicate that the key can validly sign RRs or updates of the same name. If the owner name is a wildcard, then RRs or updates with any name within the wildcard's scope can be signed. There are fifteen different non-zero values possible for this field, and any differences in their meaning are reserved for definition alongside DNS dynamic update or other new DNS commands ๐งฉ zone keys always have authority to sign any RRs in the zone, no matter what this field says. Like every other part of the KEY RR, the signatory field only works if the KEY RR is appropriately signed by a SIG RR ๐ซถ
3.4 The Protocol Octet ๐ธ
it's expected that some keys stored in DNS will be used with Internet protocols other than DNS (keys with the zone bit or a non-zero signatory field), and some with IPSEC and/or email (keys with the IPSEC and/or email bit set) ๐ฆ the protocol octet exists to show that a key is valid for that kind of use, and, for end entity keys or the host part of user keys, that the secure version of that protocol is implemented on that entity or host ๐ฅ
Values between 1 and 191 decimal inclusive are available for assignment by IANA for such protocols. ๐ the 63 values between 192 and 254 inclusive won't be assigned to a specific protocol, and they're available for experimental use under bilateral agreement ๐งช value 0 means, for a particular key, that it isn't valid for any particular additional protocol beyond those indicated in the flag field ๐ โโ๏ธ and value 255 means the key is valid for all assigned protocols (the ones in the 1 to 191 range) ๐
the plan is that new uses of DNS stored keys would first be implemented, and operational experience gathered, using the experimental range of the protocol octet ๐งโ๐ฌ if demand for widespread deployment over the indefinite future justifies it, a value in the assigned range would then be designated for the protocol โจ finally, (1) if the protocol became so widespread alongside other protocols that share its key values that duplicate RRs become a serious burden, and (2) if the protocol provides substantial facilities not available in any protocol that already has a flags field bit allocated, then one of the remaining flag field bits may be allocated to the protocol ๐ when such a bit has been allocated, a key can be indicated as valid for that protocol at the same time, and the entity or host can be flagged as implementing the secure version of that protocol at the same time as other protocols that have flag field bits assigned ๐
3.5 The KEY Algorithm Number and the MD5/RSA Algorithm โจ
okay so this octet is the key algorithm, and it's the same vibe as the algorithm field over on the SIG resource ๐ MD5/RSA is algorithm number 1. Numbers 2 through 252 are open for assignment if there's a good enough reason, BUT giving out a new algorithm can seriously mess with interoperability, so it needs an IETF standards action (not just vibes) ๐
Number 254 is reserved for private use and will never get a specific algorithm assigned ๐ For 254, the public key area in the packet diagram starts with a length byte, followed by an Object Identifier (OID) of that length. The OID says which private algorithm is in use, and whatever's left in the area is whatever that algorithm needs ๐ง
Number 253 is the "expiration date algorithm" ๐ It's for when you want expiration dates or other labelling fields on SIGs but zero actual security. It's expected to show up only with some modes of DNS dynamic update. For 253 the public key area is null. Values 0 and 255 are reserved ๐ธ
If the type field does not have the "no key" value and the algorithm field is 1 (the MD5/RSA algorithm), the public key field is laid out like this:
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| pub exp length| public key exponent /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| /
+- modulus /
| /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-/
To keep things interoperable, the exponent and modulus are each limited to 2552 bits ๐ The public key exponent is a variable-length unsigned integer. Its length in octets is one octet if it's between 1 and 255, and if it's longer than 255 bytes, it's a zero octet followed by a two-octet unsigned length. The public key modulus is a multiprecision unsigned integer, and you can work out its length from RDLENGTH and the preceding RDATA fields (including the exponent) ๐ฆ Leading zero bytes are prohibited in both the exponent and the modulus.
3.6 Interaction of Flags, Algorithm, and Protocol Bytes ๐
Lots of combos are possible here: the no-key type value, the algorithm byte, the protocol byte, and any protocol-indicating flags (like the reserved IPSEC flag) ๐งฉ Fun fact: the zone flag bit being on, or the signatory field being non-zero, counts as a DNS protocol flag being on. Here's what each combo means:
NK = no key type value
AL = algorithm byte
PR = protocols indicated by protocol byte or protocol flags
x represents any valid non-zero value(s).
AL PR NK Meaning
0 0 0 Illegal, claims key but has bad algorithm field.
0 0 1 Specifies total lack of security for owner.
0 x 0 Illegal, claims key but has bad algorithm field.
0 x 1 Specified protocols insecure, others may be secure.
x 0 0 Useless. Gives key but no protocols to use it.
x 0 1 Useless. Denies key but for no protocols.
x x 0 Specifies key for protocols and asserts that
those protocols are implemented with security.
x x 1 Algorithm not understood for protocol.
Remember that a protocol byte of 255 means all protocols with assigned protocol byte values ๐
3.7 KEY RRs in the Construction of Responses ๐ซถ
An explicit request for KEY RRs doesn't trigger any special extra processing, except, of course, for the matching SIG RR from a security aware server ๐
Security aware DNS servers MUST include KEY RRs as additional information in responses where it makes sense, including these cases:
- On retrieval of NS RRs, the zone key KEY RR(s) for the zone served by those name servers MUST be included as additional information if space is available ๐ A secure zone always has at least one KEY RR like this, even if it's the no-key type value that says the subzone is insecure. If not all the additional info fits, the KEY RR(s) outrank type A or AAAA glue RRs. And if a KEY RR like this doesn't fit on a retrieval, the retrieval must be considered truncated ๐ญ
- On retrieval of type A or AAAA RRs, the end entity KEY RR(s) MUST be included if space is available ๐ When A or AAAA RRs get included as additional info, their KEY RRs come along too, but with lower priority than the relevant A or AAAA RRs.
3.8 File Representation of KEY RRs ๐
KEY RRs can show up as lines in a zone data master file ๐ The flag field, protocol, and algorithm number octets get written as unsigned integers. Quick heads up: if the type field has the "no key" value or the algorithm is 253, nothing appears after the algorithm octet ๐
The rest of the public key gets written in base 64 (see Appendix) โจ It can be chopped into any number of whitespace-separated substrings, all the way down to single base 64 digits, and they get stuck back together to get the full thing. These substrings can stretch across lines using normal parentheses ๐
Okay, one more important bit: the public key can have internal sub-fields, but those don't show up in the master file ๐ง For example, algorithm 1 has a public exponent size, then a public exponent, then a modulus. Algorithm 254 has an OID size, an OID, and then algorithm-dependent info. Either way, only one logical base 64 string ends up in the master file ๐
4. The SIG Resource Record โจ
The SIG or "signature" resource record (RR) is the fundamental way data gets authenticated in the secure Domain Name System (DNS) ๐ So honestly? It's the heart of all the security stuff ๐
The SIG RR authenticates other RRs of a particular type, class, and name in a way that can't be forged ๐ It binds them to a time interval and the signer's domain name. This is done with cryptographic techniques and the signer's private key ๐ And the signer is frequently the owner of the zone the RR came from ๐ฆ
4.1 SIG RDATA Format ๐
okay so the RDATA part of a SIG RR looks like this ๐ and the signature field is what keeps all of it protected ๐ no cap, this is the main event โจ
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| type covered | algorithm | labels |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| original TTL |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| signature expiration |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| time signed |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| key footprint | /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ signer's name /
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| /
+- signature /
/ /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
the SIG RR type value is 24 ๐ข
the "type covered" is the type of the other RRs covered by this SIG ๐
the algorithm number is an octet that tells you which digital signature algorithm was used. it's parallel to the algorithm octet on the KEY RR, so they match up ๐ MD5/RSA (the one this doc describes) is number 1. numbers 2 through 252 are up for grabs should there be sufficient reason to allocate them, BUT bestie, picking a new algorithm could seriously mess with interoperability across the whole global DNS system, so it needs an IETF standards action ๐จ
number 254 is reserved for private use and won't ever get a specific algorithm assigned. for 254, the "signature" area starts with a length byte, followed by an Object Identifier (OID) of that length. the OID tells you which private algorithm is in play, and whatever's left of the area is whatever that algorithm needs ๐ง
number 253 is the "expiration date algorithm" ๐ฆ it's for when you want the expiration date or other non-signature fields of the SIG without any actual security. it's anticipated that this one will only be used with some modes of DNS dynamic update. for 253, the signature field is null. and values 0 and 255 are reserved ๐
the "labels" octet is an unsigned count of how many labels are in the original SIG RR owner name. it doesn't count the null label for root, and it doesn't count any initial "*" for a wildcard ๐ธ if a secured retrieval came from wildcard substitution, the resolver needs to use the original form of the name when verifying the digital signature. this field helps figure out that original form faster, so authenticating the signed data takes less effort โจ
if the RR shows up with a longer name than "labels" says, the resolver can tell it came from wildcard substitution. but if the RR owner name looks shorter than the labels count, the SIG RR must be considered corrupt and ignored ๐ซ the max number of labels allowed in the current DNS is 127, but the whole octet is reserved, since it'd be needed if DNS names ever got expanded to 255 labels. here's a table of examples. the value of "labels" is across the top, the retrieved owner name is down the left, and the entry is the name to use for signature verification, except "bad" means the RR is corrupt ๐
labels= | 0 | 1 | 2 | 3 | 4 |
--------+-----+------+--------+----------+----------+
.| . | bad | bad | bad | bad |
d.| *. | d. | bad | bad | bad |
c.d.| *. | *.d. | c.d. | bad | bad |
b.c.d.| *. | *.d. | *.c.d. | b.c.d. | bad |
a.b.c.d.| *. | *.d. | *.c.d. | *.b.c.d. | a.b.c.d. |
the "original TTL" field lives in the RDATA so it can avoid two problems. first, caching servers decrementing the real TTL field would cause authentication problems. second, unscrupulous servers could manipulate the real TTL field and cause security problems. the original TTL is protected by the signature, but the current TTL field isn't ๐
NOTE: the "original TTL" must be restored into the covered RRs when the signature is verified. this means all RRs for a particular type, name, and class must have the same TTL to start with. no mixing TTLs, bestie ๐
the SIG is valid until the "signature expiration" time, which is an unsigned number of seconds since the start of 1 January 1970, GMT, ignoring leap seconds. (see also Section 4.4.) SIG RRs should not have a date signed significantly in the future. and to stop network requests that update a zone dynamically from getting misordered, monotonically increasing "time signed" dates may be necessary ๐ฐ๏ธ
the "time signed" field is also an unsigned number of seconds since the start of 1 January 1970, GMT, ignoring leap seconds ๐
a SIG RR with an expiration date before its time signed must be considered corrupt and ignored. no exceptions, periodt ๐ญ
the "key footprint" is a 16 bit quantity. it helps you efficiently pick between multiple keys that might apply, and it's a quick check that a public key about to be used for the computationally expensive signature check is possibly valid โจ what it means depends on the algorithm. for MD5/RSA, it's the next to the bottom two octets of the public key modulus needed to decode the signature field. that is to say, the most significant 16 of the least significant 24 bits of the modulus, in network order ๐
the "signer's name" field is the domain name of the signer who generated the SIG RR. this is the owner of the public KEY RR that can verify the signature. it's frequently the zone that contained the RR(s) being authenticated. the signer's name may be compressed with standard DNS name compression when it's sent over the network ๐ซถ
the structure of the "signature" field is described below ๐
4.1.1 Signature Data ๐
except for algorithm number 253, where it's null, the actual signature portion of the SIG RR binds the other RDATA fields to all of the "type covered" RRs with that owner name and class. those covered RRs are thereby authenticated. to pull this off, a data sequence gets built like this:
data = RDATA | RR(s)...
where "|" is concatenation, RDATA is all the RDATA fields in the SIG RR itself before (and not including) the signature, and RR(s) are all the RR(s) of the type covered, with the same owner name and class as the SIG RR, in canonical form and order. how this data sequence gets processed into the signature is algorithm dependent ๐ง
for DNS security purposes, the canonical form of an RR is the RR with (1) domain names fully expanded (no name compression via pointers), (2) all domain name letters set to lower case, and (3) the original TTL substituted for the current TTL โจ
for DNS security purposes, the canonical order for RRs is to sort them in ascending order by name. labels get treated as a left justified unsigned octet sequence in network (transmission) order, where a missing octet sorts before a zero octet. (see also the ordering discussion in Section 5.1.) within any particular name, they're sorted similarly by type and then RDATA as a left justified unsigned octet sequence. EXCEPT that the type SIG RR(s) covering any particular type appear immediately after the other RRs of that type. (this special consideration for SIG RR(s) in ordering really only applies to calculating the AXFR SIG RR, as explained in section 4.1.3 below.) so if at name a.b there are two A RRs and one KEY RR, their order, with SIGs, for concatenating the "data" to be signed would be like this ๐
a.b. A ....
a.b. A ....
a.b. SIG A ...
a.b. KEY ...
a.b. SIG KEY ...
SIGs covering type ANY should not be included in a zone ๐ โโ๏ธ
4.1.2 MD5/RSA Algorithm Signature Calculation ๐งฎ
for the MD5/RSA algorithm, the signature works out like this:
hash = MD5 ( data )
signature = ( 01 | FF* | 00 | prefix | hash ) ** e (mod n)
MD5 is the message digest algorithm documented in RFC 1321. "|" is concatenation. "e" is the private key exponent of the signer, and "n" is the modulus of the signer's public key. 01, FF, and 00 are fixed octets of the corresponding hexadecimal value. "prefix" is the ASN.1 BER MD5 algorithm designator prefix specified in PKCS1, which is:
hex 3020300c06082a864886f70d020505000410 [NETSEC].
this prefix is included to make it easier to use RSAREF or similar packages ๐ท the FF octet gets repeated the maximum number of times such that the value of the quantity being exponentiated is one octet shorter than the value of n.
(the above specifications are identical to the corresponding part of Public Key Cryptographic Standard #1 [PKCS1].) ๐
the size of n, including most and least significant bits (which will be 1), SHALL be not less than 512 bits and not more than 2552 bits ๐ n and e SHOULD be chosen such that the public exponent is small ๐ธ
leading zeros bytes are not permitted in the MD5/RSA algorithm signature ๐ซ
a public exponent of 3 minimizes the effort needed to decode a signature ๐โโ๏ธ but using 3 as the public exponent may be weak for confidentiality uses. if the same data can be collected encrypted under three different keys with an exponent of 3, then, using the Chinese Remainder Theorem, the original plain text can be easily recovered. this weakness isn't significant for DNS because we only seek authentication, not confidentiality ๐
4.1.3 Zone Transfer (AXFR) SIG โจ
okay bestie, the SIG mechanisms we just covered authenticate every zone-signed RR for one name, class, and type ๐
But if you want zone transfers to be complete AND secure, you need a bigger move: a SIG RR owned by the zone name, with a type covered of AXFR ๐ฆ It covers every zone-signed RR in the zone and their zone SIGs, but not the AXFR SIG itself (no infinite loop, obviously ๐). The RRs get ordered and concatenated for hashing the way Section 4.1.1 describes. (Also peep the ordering discussion in Section 5.1 ๐ง)
The AXFR SIG has to be calculated last of all the zone key signed SIGs. When you sign the zone, you order everything that's getting signed, plus all the associated glue RRs and delegation point NS RRs. Then you do one pass inserting all the zone SIGs. As you go, you hash each RR into an RRset hash and the zone hash. When the name or type changes, you calculate and insert the RRset zone SIG, clear the RRset hash, and hash that SIG into the zone hash. Glue RRs and delegation point NSs aren't zone signed, but zone apex NSs are, so keep that straight ๐ Once you've processed all the starting RRs, use the cumulative zone hash RR to calculate and insert an AXFR SIG covering the zone. Any other computational technique that gives the same results is totally allowed โจ
The AXFR SIG really belongs to the zone as a whole, not just the zone name. It should be correct for the zone name, but otherwise the labels field of an AXFR SIG is meaningless ๐ It only gets retrieved as part of a zone transfer. After you validate the AXFR SIG, the zone MAY be considered valid without checking the internal zone signed SIGs in the zone. However, any RRs authenticated by SIGs signed by entity keys or the like MUST still be validated. The AXFR SIG SHOULD be sent first in a zone transfer, so the receiver can tell right away that they might be able to skip verifying the other zone signed SIGs ๐โโ๏ธ
RRs authenticated by a dynamic update key, and not by the zone key (see Section 3.2), are not included in the AXFR SIG. They may originate in the network and might not, in general, be migrated to the recommended off line zone signing procedure (see Section 7.2). So those RRs aren't directly signed by the zone, aren't in the AXFR SIG, and are only protected against being left out of zone transfers to the extent that the server and communication can be trusted ๐ฅบ
4.1.4 Transaction and Request SIGs ๐
A response message from a security aware server may optionally contain a special SIG as the last item in the additional information section, which authenticates the transaction. ๐
This SIG has a "type covered" field of zero, which is not a valid RR type (lol, that's the whole trick ๐). It's calculated using the "data" (see Section 4.1.2) of the entire preceding DNS reply message, including the DNS header but not the IP header, concatenated with the entire DNS query message that produced this response, including the query's DNS header but not its IP header. That is:
data = full response (less final transaction SIG) | full query
Verification of the transaction SIG by the requesting resolver shows that the query and response weren't tampered with in transit, that the response corresponds to the intended query, and that the response comes from the queried server. The transaction SIG is signed by the server host key, not the zone key ๐
A DNS request may be optionally signed by including one or more SIGs at the end of the query. These SIGs are identified by having a "type covered" field of zero. They sign the preceding DNS request message, including the DNS header but not the IP header, and not the beginning or any preceding request SIGs at the end. Request SIGs are included in the "data" used to form any optional response transaction SIG ๐
WARNING: Request SIGs are unnecessary for currently defined queries and will cause almost all existing DNS servers to completely ignore a query. However, such SIGs may be needed to authenticate future DNS secure dynamic update or other requests. ๐จ
4.2 SIG RRs in the Construction of Responses ๐ธ
Security aware DNS servers MUST, for every authoritative RR the query will return, attempt to send the available SIG RRs which authenticate the requested RR. Here's how SIG RRs get included in responses:
- When an RR set is placed in a response, its SIG RR gets higher priority for inclusion than other additional RRs that may need to be included. If there's no space for it, the response MUST be considered truncated, except as provided in 2 below. ๐ฆ
- When a SIG RR is present in the zone for an additional information section RR, the response MUST NOT be considered truncated merely because there's no space for its SIG RR. ๐ โโ๏ธ
- SIGs that authenticate non-authoritative data (glue records and NS RRs for subzones) are unnecessary and MUST NOT be sent. (Quick side note: KEYs for subzones are controlling in a superzone, so the superzone's signature on the KEY MUST be included, unless the KEY was additional information and the SIG didn't fit. ๐)
- If a SIG covers any RR that would be in the answer section of the response, its automatic inclusion MUST be the answer section. If it covers an RR that would appear in the authority section, its automatic inclusion MUST be in the authority section. If it covers an RR that would appear in the additional information section, it MUST appear in the additional information section. This is a change from the existing standard, which only contemplates NS and SOA RRs in the authority section ๐
- Optionally, DNS transactions may be authenticated by a SIG RR at the end of the response in the additional information section (Section 4.1.4). These SIG RRs are signed by the DNS server originating the response. Although the signer field MUST be the name of the originating server host, the owner name, class, TTL, and original TTL are meaningless. The class and TTL fields SHOULD be zero. To conserve space, the owner name SHOULD be root (a single zero octet). If transaction authentication is desired, that SIG RR must be considered higher priority for inclusion than any other RR in the response ๐
4.3 Processing Responses and SIG RRs ๐ง
Here are the rules for processing SIG RRs that show up in a response:
- A security aware resolver that receives a response from what it believes is a security aware server, via a secure communication with the AD bit (see Section 6.1) set, MAY choose to accept the RRs as received without verifying the zone SIG RRs. โ
- In other cases, a security aware resolver SHOULD verify the SIG RRs for the RRs of interest. This may involve starting additional queries for SIG or KEY RRs, especially when the response came from an insecure server. (As explained in 4.2 above, it won't be possible to secure CNAMEs being served up by non-secure resolvers ๐)
NOTE: Implementers might expect the above SHOULD to be a MUST. However, local policy or the calling application may not require the security services. ๐คทโโ๏ธ
- If SIG RRs are received in response to a user query that explicitly specifies the SIG type, no special processing is required. ๐
If the message doesn't pass reasonable checks, or the SIG doesn't check out against the signed RRs, the SIG RR is invalid and should be ignored. If all of the SIG RR(s) that claim to authenticate a set of RRs are invalid, then that set of RR(s) is not authenticated ๐ซ
If the SIG RR is the last RR in a response in the additional information section and has a type covered of zero, it's a transaction signature of the response and the query that produced it. It MAY be optionally checked, and the message rejected if the checks fail. But even if the checks succeed, a transaction authentication SIG does not authenticate any RRs in the message. Only a proper SIG RR signed by the zone, or by a key tracing its authority to the zone or to static resolver configuration, can authenticate RRs ๐ If a resolver doesn't implement transaction and/or request SIGs, it MUST ignore them without error.
If all reasonable checks indicate that the SIG RR is valid, then RRs verified by it should be considered authenticated โจ
4.4 Signature Expiration, TTLs, and Validity โณ
Security aware servers must not consider SIG RRs to authenticate anything after their expiration time, and must not consider any RR to be authenticated after its signatures have expired. Within that constraint, servers should keep following DNS TTL aging. So authoritative servers should keep following the zone refresh and expire parameters, and a non-authoritative server should count down the TTL and discard RRs when the TTL hits zero. โฐ Also, when RRs go out in a query response, the TTL should be trimmed so that current time plus the TTL doesn't go past the signature expiration time. In general, the TTL on a transmitted RR works out to:
min(sigExpTim,max(zoneMinTTL,min(originalTTL,currentTTL)))
4.5 File Representation of SIG RRs ๐
A SIG RR can be represented as a single logical line in a zone data file [RFC1033], but there are some special considerations, described below. (It doesn't make sense to include a transaction or request authenticating SIG RR in a file, since those are transient authentications covering data like an ephemeral transaction number, so they have to be calculated in real time โก)
The signer, covered type, and times have no particular problems. The time fields appear in the form YYYYMMDDHHMMSS, where YYYY is the year, the first MM is the month number (01-12), DD is the day of the month (01-31), HH is the hour in 24 hour notation (00-23), the second MM is the minute (00-59), and SS is the second (00-59) ๐ฐ๏ธ
The original TTL and algorithm fields appear as unsigned integers ๐ข
If the original TTL, which applies to the type signed, is the same as the TTL of the SIG RR itself, it may be omitted. The date field that follows it is larger than the maximum possible TTL, so there's no ambiguity ๐
The "labels" field doesn't appear in the file representation, since it can be calculated from the owner name ๐งฎ
The key footprint appears as an unsigned decimal number ๐
The signature itself can be very long, though. It's the last data field, represented in base 64 (see Appendix), and it may be divided up into any number of white space separated substrings, down to single base 64 digits. Those substrings are concatenated to get the full signature. These substrings can be split between lines using the standard parenthesis ๐ซถ
5. Non-existent Names and Types โจ
okay so the SIG RR stuff from Section 4 is giving STRONG authentication for RRs that actually exist in a zone ๐ but it's not clear above how to authenticatably deny that a name exists in a zone, or that a type exists for a name that does exist ๐
The nonexistence of a name in a zone is shown by the NXT ("next") RR for the name interval that contains the nonexistent name. If the server is security aware, the NXT RR and its SIG go in the authority section along with the error โจ The same goes for a nonexistent type under an existing name. This is a change to the existing standard, which only contemplates NS and SOA RRs in the authority section ๐ NXT RRs also get returned if someone makes an explicit query for the NXT type.
If a zone has a complete set of NXT records, then any query for any name and any type sent to a security aware server serving that zone will always get a reply containing at least one signed RR ๐ซถ
NXT RRs don't show up in zone master files, since they can be derived from the rest of the zone ๐
5.1 The NXT Resource Record
The NXT resource record is how you securely say that RRs with an owner name in a certain name interval don't exist in a zone, and also what zone signed RR types are present for an existing name ๐
The owner name of the NXT RR is an existing name in the zone. Its RDATA is a "next" name plus a type bit map. Having the NXT RR means that generally no name between its owner name and the name in its RDATA area exists, and that no other zone signed types exist under its owner name. This implies a canonical ordering of all domain names in a zone ๐ธ
The ordering works like this: labels get sorted as unsigned left justified octet strings, where the absence of an octet sorts before a zero value octet, and upper case letters are treated as lower case letters. Names then get sorted by the highest level label first, then, within names that share that highest level label, by the next lower label, and so on down to leaf node labels. Since we're talking about a zone, the zone name itself always exists and every other name is the zone name with some prefix of lower level labels. So the zone name itself always sorts first ๐ง
There's a potential problem with the last NXT in a zone! It wants an owner name that is the last existing name in canonical order, which is easy, but it's not obvious what goes in its RDATA to cover the entire remainder of the name space ๐ญ This is handled by treating the name space as circular and putting the zone name in the RDATA of the last NXT in a zone ๐ฅ
There are special considerations because of how NXT RRs interact with wildcards, explained below ๐ฆ
The NXT RRs for a zone SHOULD be automatically calculated and added to the zone by the same recommended off-line process that signs the zone (see Section 7.2). The NXT RR's TTL SHOULD not exceed the zone minimum TTL.
5.2 NXT RDATA Format
The RDATA for an NXT RR is simply a domain name followed by a bit map ๐
The type number for the NXT RR is 30.
1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| next domain name /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| type bit map /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The NXT RR type bit map has one bit per RR type present for the owner name, kinda like the WKS socket bit map ๐ฆ The first bit represents RR type zero (an illegal type that should not be present). A one bit means at least one RR of that type is present for the owner name. A zero means no such RR is present. All bits that aren't specified because they're past the end of the bit map are assumed to be zero. Note that bit 30, for NXT, will always be on, so the minimum bit map length is actually four octets ๐ The NXT bit map should be printed as a list of RR type mnemonics or decimal numbers, similar to the WKS RR.
The domain name may be compressed with standard DNS name compression when it's sent over the network. The size of the bit map can be inferred from the RDLENGTH and the length of the next domain name โจ
5.3 Example
Okay, picture this: the zone foo.tld has entries for ๐
big.foo.tld,
medium.foo.tld.
small.foo.tld.
tiny.foo.tld.
Then a query to a security aware server for huge.foo.tld would get an error reply with authority section data that includes something like the following ๐
big.foo.tld. NXT medium.foo.tld. A MX SIG NXT
big.foo.tld. SIG NXT 1 3 ( ;type-cov=NXT, alg=1, labels=3
19960102030405 ;signature expiration
19951211100908 ;time signed
21435 ;key footprint
foo.tld. ;signer
MxFcby9k/yvedMfQgKzhH5er0Mu/vILz45IkskceFGgiWCn/GxHhai6VAuHAoNUz4YoU
1tVfSCSqQYn6//11U6Nld80jEeC8aTrO+KKmCaY= ;signature (640 bits)
)
Notice that this response implies big.foo.tld is an existing name in the zone, so it has other RR types associated with it besides NXT ๐ But only the NXT (and its SIG) RR shows up in the response to this query for huge.foo.tld, which is a nonexistent name ๐ญ
5.4 Interaction of NXT RRs and Wildcard RRs
So, in a way, a wildcard RR makes every possible name in an interval exist ๐ That means there shouldn't be an NXT RR that covers any part of that interval. So if .X.ZONE exists, you'd expect an NXT RR that ends at X.ZONE and one that starts with the last name covered by *.X.ZONE. But that "last name covered" is something super ugly and long, like \255\255\255....X.zone. So the NXT for the interval after it just gets the owner name *.X.ZONE and an RDATA of the next name after the wildcard. This "" type owner name is not expanded when the NXT is returned as authority information for a query about a nonexistent name ๐ง
If there could be any wildcard RRs in a zone, and therefore wildcard NXTs, you have to be careful interpreting the results of explicit NXT retrievals, since the owner name may be a wildcard expansion ๐
Here's the sketchy part ๐ญ The existence of one or more wildcard RRs covering a name interval makes it possible for a malicious server to hide any more specifically named RRs in the internal. The server can just falsely return the wildcard match NXT instead of the more specifically named RRs. If there's a zone wide wildcard, there will be an NXT RR whose owner name is the wild card and whose RDATA is the zone name. In that case a server could conceal the existence of any more specific RRs in the zone ๐ It would be possible to design a stricter NXT feature that eliminates this possibility. But it would be more complex, and it might be so constraining that it makes any dynamic update feature very difficult ๐ค
5.5 Blocking NXT Pseudo-Zone Transfers
In a secure zone, a resolver can query for the initial NXT associated with the zone name ๐ฆ Using the next domain name RDATA field from that RR, it can query for the next NXT RR. By repeating this, it can walk through all the NXTs in the zone. If there are no wildcards, it can use this technique to find all names in a zone. If it does type ANY queries, it can incrementally get all information in the zone, and so it can defeat attempts to administratively block zone transfers ๐
If there are any wildcards, this NXT walking technique won't find any more specific RR names in the part of the name space the wildcard covers ๐ซถ By doing explicit retrievals for wildcard names, a resolver could figure out which intervals are covered by wildcards, but it still couldn't find any names inside those intervals with these techniques, except by trying every name ๐ธ
If you want to block NXT walking, the recommended method is to add a zone wide wildcard of the KEY type, with the no-key type value and with no type (zone, entity, or user) bit on ๐ This will cause there to be one zone covering NXT RR and leak no information about what real names exist in the zone โจ But this protection from pseudo-zone transfers comes at the cost of giving up the data origin authentication of nonexistent names that NXT RRs can provide ๐ญ If an entire zone is covered by a wildcard, a malicious server can return an RR produced by matching the resulting wildcard NXT, and it can hide all the real data and delegations in the zone that have more specific names ๐
5.6 Special Considerations at Delegation Points
A name (other than root) that's the head of a zone also appears as the leaf in a superzone ๐ If both are secure, there will always be two different NXT RRs with the same name. They can be told apart by their signers and next domain name fields. Security aware servers should return the correct NXT automatically when they need to authenticate the nonexistence of a name, and both NXTs, if available, on an explicit query for type NXT ๐ฅ
Insecure servers will never automatically return an NXT, and some implementations may only return the NXT from the subzone on explicit queries ๐
6. The AD and CD Bits and How to Resolve Securely
Retrieving or resolving authentic data from the Domain Name System (DNS) starts with one or more trusted public keys for one or more zones ๐ With trusted keys, a resolver that's willing to do cryptography can work its way securely through the secure DNS zone structure to the zone of interest, as described in Section 6.3. Those trusted public keys would normally be configured in a way similar to what's described in Section 6.2. But as a practical matter, a security aware resolver would still gain some confidence in the results it returns even if it wasn't configured with any keys, as long as it trusted what it got from a local well known server as a starting point ๐
Data stored at a security aware server needs to be internally categorized as Authenticated, Pending, or Insecure. There's also a fourth transient state, Bad, which indicates that all SIG checks have explicitly failed on the data. Bad data is not retained at a security aware server ๐ญ Authenticated means the data has a valid SIG under a KEY that's traceable, via a chain of zero or more SIG and KEY RRs, to a KEY configured at the resolver through its boot file ๐ Pending data has no authenticated SIGs and at least one additional SIG that the resolver is still trying to authenticate ๐ Insecure data is data that is known to never be able to become Authenticated or be found Bad, because it's in or has been reached via a non-secured zone ๐ง How to handle and flag based on these data labels is described in Section 6.1 โจ
The proper validation of signatures requires a reasonably secure shared opinion of the absolute time between resolvers and servers, as described in Section 6.4 โฐ
6.1 The AD and CD Header Bits โจ
okay so two bits that were just sitting there unused got allocated out of the DNS query/response header ๐ The AD (authentic data) bit says, in a response, that the data included has been verified by the server giving it. The CD (checking disabled) bit says, in a query, that non-verified data is fine with the resolver sending the query ๐
They come out of the must-be-zero Z field like this:
1 1 1 1 1 1
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ID |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
|QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| QDCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ANCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| NSCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
| ARCOUNT |
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
these bits are zero in old servers and resolvers ๐ธ So the responses from old servers never get flagged as authenticated for security aware resolvers, and queries from non-security aware resolvers don't assert the checking disabled bit, which means security aware servers will only answer them with authenticated data ๐ฆ Aware resolvers MUST not trust the AD bit unless they trust the server they're talking to and either have a secure path to it or use DNS transaction security ๐ฅ
any security aware resolver that's willing to do cryptography SHOULD assert the CD bit on all queries ๐ The whole point is to cut DNS latency by letting security aware servers answer before they've resolved whether the data is valid โฑ๏ธ
security aware servers never return Bad data ๐ For non-security aware resolvers, or security aware resolvers that ask for service by keeping the CD bit clear, security aware servers MUST return only Authenticated or Insecure data, with the AD bit set in the response โจ Security aware resolvers can tell whether data is Insecure or Authentic by the absence of SIG RRs ๐ง Security aware servers MAY return Pending data to security aware resolvers requesting the service, by clearing the AD bit in the response ๐ The AD bit MUST NOT be set on a response unless all of the RRs in the response are either Authenticated or Insecure ๐
6.2 Boot File Format ๐
two boot file directives get added in this section, bestie ๐ซถ
the format for a boot file directive that configures a starting zone key looks like this, for a public key:
pubkey name flags protocol algorithm key-data
name is the owner name (if the line gets translated into a KEY RR). flags says what type of key it is, and it's the same as the flag octet in the KEY RR. protocol and algorithm mean the same thing they do in the KEY RR too ๐ The stuff after the algorithm depends on the algorithm, and for private algorithms (algorithm 254) it starts with the algorithm's identifying OID and that OID's length ๐งฉ If the "no key" type value is set in flags, or the algorithm is 253, then the key-data after the algorithm is null. When it's there, the key-data gets treated as an octet stream and encoded in base 64 (see Appendix) ๐
a file of keys for cross certification or other purposes can be set up through the keyfile directive:
keyfile filename
the file looks like a master file, except it can only contain KEY and SIG RRs, with the SIGs signed under a key configured with the pubkey directive ๐
okay so you'd think everyone should start with the key for the root zone, right? ๐ค Nope, this has problems ๐ญ Updating every DNS resolver in the world whenever the root key changes would be way too much work. There might not even be a root key for a while. And lots of organizations will want their "interior" DNS implementations to trust only their own zone ๐ Those interior resolvers can then go through the organization's zone servers to get data outside the organization's domain, and they should only be configured with the key for the organization's DNS apex ๐
6.3 Chaining Through Zones ๐ฆ
starting with one or more trusted keys for a zone, it should be possible to get signed keys for its subzones that have a key and, if the zone isn't root, for its superzone โจ Every authoritative secure zone server MUST also include the KEY RR for a super-zone, signed by the secure zone, via a keyfile directive ๐ช That's what makes it possible to climb the tree of zones if you start below root. A secure sub-zone is marked by a KEY RR with non-null key information showing up with the NS RRs for the sub-zone, and those are what let you go back down the tree of zones ๐ณ
a resolver should keep track of how many successive secure zones it traveled through from a starting point to any secure zone it can reach ๐ In general, the lower that distance number is, the more confidence you can have in the data ๐ Data configured via a boot file directive should get a distance number of zero. If a query runs into different data for the same query with different distance values, the one with the larger value should be ignored ๐ โโ๏ธ
a security conscious resolver should completely refuse to step from a secure zone into a non-secure zone, unless the non-secure zone is certified as non-secure, or only experimentally secure, by an authenticated KEY RR for that zone with the no-key type value, or by a KEY RR with the experimental bit set ๐ Otherwise, the resolver is getting bogus or spoofed data ๐
if legitimate non-secure zones show up while you're traversing the DNS tree, then no zone that can only be reached through information from those non-secure zones can be trusted as secure ๐ฑ Since that non-secure zone data could have been spoofed, the "secure" zone reached through it could be counterfeit. The "distance" to data in such zones, or zones reached through such zones, could be set to 512 or more, since that's bigger than the largest possible distance through secure zones in the DNS. Even so, continuing to apply secure checks inside "secure" zones reached through non-secure zones is good practice, and it will, in practice, add a little bit of extra security โจ
6.4 Secure Time โฐ
coordinating how the time fields in SIG RRs get interpreted requires that reasonably consistent time is available to the hosts implementing the DNS security extensions ๐ฐ๏ธ
there are a bunch of time synchronization protocols out there, including the Network Time Protocol (NTP, RFC1305) ๐ If you use protocols like that, they MUST be used securely so that time can't be spoofed ๐ Otherwise, say a host gets its clock turned back. It might then believe old SIG and KEY RRs that were valid once but aren't anymore ๐ฌ
7. Operational Considerations ๐ ๏ธ
this section talks about a bunch of things to think about for running the Domain Name System (DNS) securely with these protocol extensions ๐
7.1 Key Size Considerations ๐
there are a number of factors that affect the public key size you pick for the DNS security extension ๐ฅบ Annoyingly, these factors usually don't all point the same way. Picking the zone key size should generally be done by the zone administrator, based on their local conditions ๐ง
for most schemes, larger keys are more secure but slower ๐ข With a small public exponent, verification (the most common operation) for the MD5/RSA algorithm varies roughly with the square of the modulus length. Signing varies with the cube of the modulus length, and key generation (the least common operation) varies with the fourth power of the modulus length ๐ต The current best algorithms for factoring a modulus and breaking RSA security vary roughly with the 1.6 power of the modulus itself. So going from a 640 bit modulus to a 1280 bit modulus only increases verification time by a factor of 4, but it increases the work factor of breaking the key by over 2^900 ๐คฏ An upper bound of 2552 bits has been established for the MD5/RSA DNS security algorithm, for interoperability purposes ๐
however, larger keys make the KEY and SIG RRs bigger ๐ฆ That raises the chance of DNS UDP packet overflow, and the possible need to use higher overhead TCP in responses ๐ง
the recommended minimum RSA algorithm modulus size, 640 bits, is believed by the authors to be secure at this time, but high level zones in the DNS tree may want to set a higher minimum, perhaps 1000 bits, for security reasons ๐ (Since the United States National Security Agency generally permits export of encryption systems using an RSA modulus of up to 512 bits, use of a modulus that small, i.e. n, must be considered weak ๐ โโ๏ธ)
for a key that's only used to secure data and not to secure other keys, 640 bits should be adequate at this time ๐ธ
7.2 Key Storage ๐๏ธ
it is recommended that zone private keys and the zone file master copy be kept and used only on off-line, non-network connected, physically secure machines ๐ Every so often, an application can be run to add authentication to a zone by adding SIG and NXT RRs, and by adding no-key type KEY RRs for subzones where a real KEY RR isn't provided ๐ง Then the augmented file can be transferred, maybe by sneaker-net, to the networked zone primary server machine ๐โโ๏ธ
the idea is a one way information flow to the network, so tampering from the network is avoided ๐ฆ Keeping the zone master file on-line and just cycling it through an off-line signer doesn't do this ๐ค The on-line version could still get tampered with if the host it lives on gets compromised. For maximum security, the master copy of the zone file should be off net and shouldn't be updated based on unsecured network mediated communication ๐ซ
note, though, that secure resolvers must be configured with some trusted on-line public key information (or a secure path to such a resolver), or they won't be able to authenticate ๐
non-zone private keys, like host or user keys, generally have to be kept on-line so they can be used for real-time purposes, like DNS transaction security, IPSEC session set-up, or secure mail ๐จ
7.3 Key Generation ๐ฒ
careful key generation is sometimes overlooked, but it's absolutely essential in any cryptographically secure system ๐ฅน The strongest algorithms with the longest keys are still useless if an adversary can guess enough to shrink the likely key space so it can be searched exhaustively ๐ต๏ธโโ๏ธ Suggestions can be found in RFC 1750 ๐
it is strongly recommended that key generation also happens off-line, perhaps on the machine used to sign zones (see Section 7.2) ๐ซถ
7.4 Key Lifetimes โณ
okay bestie, no key should be used forever ๐ โโ๏ธ the longer a key is in use, the more likely it has been compromised through carelessness, accident, espionage, or cryptanalysis ๐ฌ and if key rollover is a rare event, there's a real risk that when the time finally comes to change the key, nobody on site remembers how, or the procedures have quietly gone stale ๐
key lifetime is a matter of local policy ๐ but these considerations suggest that no zone key should have a lifetime significantly over four years ๐๏ธ a reasonable maximum for zone keys that are kept off-line and carefully guarded is 13 months, with the intent that they be replaced every year ๐ for end entity and user keys used for IP-security or the like, and kept on line, a reasonable maximum is 36 days, with the intent that they be replaced monthly or more often ๐ and in some cases, an entity key lifetime of somewhat over a day may be reasonable ๐
7.5 Signature Lifetime โ๏ธ
signature expiration times MUST be set far enough in the future that it is quite certain new signatures can be generated before the old ones expire ๐ซถ but setting expiration too far into the future could be a problem too ๐ญ if bad data or signatures were ever generated, a long expiration could mean a long time to flush out that badness ๐ซ
it is recommended that signature lifetime be a small multiple of the TTL, but not less than a reasonable re-signing interval ๐
7.6 Root ๐
it should be noted that in DNS, the root is a zone unto itself ๐ณ so the root zone key should only be seen signing itself, or signing RRs with names one level below root, such as .aq, .edu, or .arpa โจ implementations MAY reject as bogus any purported root signature of records with a name more than one level below root ๐ โโ๏ธ the root zone contains the root KEY RR, signed by a SIG RR under the root key itself ๐
8. Conformance ๐
levels of server and resolver conformance are defined, and we're about to go through all of them ๐
8.1 Server Conformance ๐ฅ๏ธ
two levels of server conformance are defined ๐ซถ
Minimal server compliance is the ability to store and retrieve (including zone transfer) SIG, KEY, and NXT RRs. Any secondary, caching, or other server for a secure zone MUST be at least minimally compliant, and even then, some things, such as secure CNAMEs, will not work without full compliance ๐ญ
Full server compliance adds the following on top of basic compliance:
- the ability to read SIG, KEY, and NXT RRs in zone files
- the ability, given a zone file and private key, to add appropriate SIG and NXT RRs, possibly via a separate application
- proper automatic inclusion of SIG, KEY, and NXT RRs in responses
- suppression of CNAME following on retrieval of the security type RRs
- recognizing the CD query header bit and setting the AD query header bit, as appropriate
- proper handling of the two NXT RRs at delegation points
primary servers for secure zones MUST be fully compliant ๐ and for completely successful secure operation, all secondary, caching, and other servers handling the zone SHOULD be fully compliant as well ๐
8.2 Resolver Conformance ๐
two levels of resolver compliance are defined ๐ธ
a basic compliance resolver can handle SIG, KEY, and NXT RRs when they are explicitly requested ๐
a fully compliant resolver ๐
- understands KEY, SIG, and NXT RRs
- maintains appropriate information in its local caches and database to indicate which RRs have been authenticated, and to what extent they have been authenticated
- performs additional queries as necessary to attempt to obtain KEY, SIG, or NXT RRs from non-security aware servers
- normally sets the CD query header bit on its queries
9. Security Considerations ๐จ
this document describes technical details of extensions to the Domain Name System (DNS) protocol ๐ they're meant to provide data integrity and origin authentication, public key distribution, and optional transaction and request security ๐
now, the serious part ๐ฅน at most, these extensions guarantee the validity of resource records, including KEY resource records, retrieved from the DNS ๐ง they do NOT magically solve other security problems ๐ for example, with secure DNS you can have high confidence in the IP address you retrieve for a host name ๐ however, that does not stop someone from substituting an unauthorized host at that address, or from capturing packets sent to that address and falsely responding with packets that appear to come from that address ๐ฑ any reasonably complete security system will require the protection of many additional facets of the Internet ๐ก๏ธโจ
References ๐
- [NETSEC] Network Security: PRIVATE Communications in a PUBLIC World, Charlie Kaufman, Radia Perlman, & Mike Speciner, Prentice Hall Series in Computer Networking and Distributed Communications, 1995. ๐
- [PKCS1] PKCS #1: RSA Encryption Standard, RSA Data Security, Inc., 3 June 1991, Version 1.4. ๐
- [RFC1032] Stahl, M., "Domain Administrators Guide", RFC 1032, November 1987. ๐๏ธ
- [RFC1033] Lottor, M., "Domain Administrators Operations Guide", RRFC 1033, November 1987. ๐๏ธ
- [RFC1034] Mockapetris, P., "Domain Names - Concepts and Facilities", STD 13, RFC 1034, November 1987. ๐
- [RFC1035] Mockapetris, P., "Domain Names - Implementation and Specifications", STD 13, RFC 1035, November 1987. ๐
- [RFC1305] Mills, D., "Network Time Protocol (v3)", RFC 1305, March 1992. โฐ
- [RFC1321] Rivest, R., "The MD5 Message-Digest Algorithm", RFC 1321, April 1992. ๐งฎ
- [RFC1530] Malamud, C., and M. Rose, "Principles of Operation for the TPC.INT Subdomain: General Principles and Policy", RFC 1530, October 1993. ๐
- [RFC1750] Eastlake, D., Crocker, S., and J, Schiller, "Randomness Requirements for Security", RFC 1750, December 1994. ๐ฒ
- [RFC1825] Atkinson, R., "Security Architecture for the Internet Protocol", RFC 1825, August 1995. ๐ฐ
- [RSA FAQ] RSADSI Frequently Asked Questions periodic posting. ๐
Authors' Addresses ๐
Donald E. Eastlake 3rd CyberCash, Inc. 318 Acton Street Carlisle, MA 01741 USA
Telephone: +1 508-287-4877 +1 508-371-7148 (fax) +1 703-620-4200 (main office, Reston, Virginia, USA) EMail: dee@cybercash.com
Charles W. Kaufman Iris Associates 1 Technology Park Drive Westford, MA 01886 USA
Telephone: +1 508-392-5276 EMail: charlie_kaufman@iris.com
Appendix: Base 64 Encoding ๐ง
the following encoding technique is taken from RFC 1521 by N. Borenstein and N. Freed ๐ it's reproduced here in an edited form for convenience โจ
a 65-character subset of US-ASCII is used, which means 6 bits can be represented per printable character ๐ค the extra 65th character, "=", is used to signify a special processing function ๐ซง
the encoding process represents 24-bit groups of input bits as output strings of 4 encoded characters ๐งฉ going from left to right, a 24-bit input group is formed by concatenating 3 8-bit input groups ๐ those 24 bits are then treated as 4 concatenated 6-bit groups, and each of those gets translated into a single digit in the base 64 alphabet ๐ข
each 6-bit group is used as an index into an array of 64 printable characters, and the character referenced by that index is placed in the output string ๐ฏ
Table 1: The Base 64 Alphabet ๐
Value Encoding Value Encoding Value Encoding Value Encoding
0 A 17 R 34 i 51 z
1 B 18 S 35 j 52 0
2 C 19 T 36 k 53 1
3 D 20 U 37 l 54 2
4 E 21 V 38 m 55 3
5 F 22 W 39 n 56 4
6 G 23 X 40 o 57 5
7 H 24 Y 41 p 58 6
8 I 25 Z 42 q 59 7
9 J 26 a 43 r 60 8
10 K 27 b 44 s 61 9
11 L 28 c 45 t 62 +
12 M 29 d 46 u 63 /
13 N 30 e 47 v
14 O 31 f 48 w (pad) =
15 P 32 g 49 x
16 Q 33 h 50 y
special processing is performed if fewer than 24 bits are available at the end of the data being encoded ๐ง a full encoding quantum is always completed at the end of a quantity ๐ when fewer than 24 input bits are available in an input group, zero bits are added (on the right) to form an integral number of 6-bit groups ๐ซง padding at the end of the data is performed using the '=' character ๐ฉท since all base 64 input is an integral number of octets, only the following cases can arise:
- the final quantum of encoding input is an integral multiple of 24 bits; here, the final unit of encoded output will be an integral multiple of 4 characters with no "=" padding ๐
- the final quantum of encoding input is exactly 8 bits; here, the final unit of encoded output will be two characters followed by two "=" padding characters ๐ธ
- the final quantum of encoding input is exactly 16 bits; here, the final unit of encoded output will be three characters followed by one "=" padding character ๐ฆ
and that's the whole spec, bestie ๐โจ
๐ฆ where this page comes from
- ietf: rfc2065 1997-01
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms