Commit Graph

137 Commits

Author SHA1 Message Date
Tom Gundersen b038f6d1d8 Merge pull request #2231 from phomes/resolve-misc2
Resolve misc2
2015-12-28 17:27:42 +01:00
Lennart Poettering 160fbda907 resolved: update DNSSEC TODO 2015-12-28 14:46:39 +01:00
Lennart Poettering ee3d6aff9b resolved: use RRSIG expiry and original TTL for cache management
When we verified a signature, fix up the RR's TTL to the original TTL
mentioned in the signature, and store the signature expiry information
in the RR, too. Then, use that when adding RRs to the cache.
2015-12-28 14:46:39 +01:00
Lennart Poettering ca994e853c resolved: only keep a single list of supported signature algorithms
This removes dnssec_algorithm_supported() and simply uses the
algorithm_to_gcrypt() result as indication whether a DNSSEC algorithm is
supported.

The patch also renames "algorithm" to "md_algorithm", in a few cases, in
order to avoid confusion between DNSSEC signature algorithms and gcrypt
message digest algorithms.
2015-12-28 14:46:39 +01:00
Lennart Poettering e0240c64b7 resolved: add ECDSA signature support 2015-12-28 14:46:39 +01:00
Lennart Poettering ea3a892fe3 resolved: split out RSA-specific code from dnssec_verify_rrset()
In preparation for ECDSA support.
2015-12-28 01:18:55 +01:00
Lennart Poettering fbf1a66d78 resolved: simplify MD algorithm initialization a bit 2015-12-28 01:18:55 +01:00
Lennart Poettering af22c65b27 resolved: add SHA384 digest support 2015-12-28 01:18:55 +01:00
Thomas Hindoe Paaboel Andersen c03cba007a resolve: remove unused variables 2015-12-28 00:05:17 +01:00
Lennart Poettering b652d4a209 resolved: add an automatic downgrade to non-DNSSEC mode
This adds a mode that makes resolved automatically downgrade from DNSSEC
support to classic non-DNSSEC resolving if the configured DNS server is
not capable of DNSSEC. Enabling this mode increases compatibility with
crappy network equipment, but of course opens up the system to
downgrading attacks.

The new mode can be enabled by setting DNSSEC=downgrade-ok in
resolved.conf. DNSSEC=yes otoh remains a "strict" mode, where DNS
resolving rather fails then allow downgrading.

Downgrading is done:

- when the server does not support EDNS0+DO
- or when the server supports it but does not augment returned RRs with
  RRSIGs. The latter is detected when requesting DS or SOA RRs for the
  root domain (which is necessary to do proofs for unsigned data)
2015-12-26 19:09:11 +01:00
Lennart Poettering ed29bfdce6 resolved: if we accepted unauthenticated NSEC/NSEC3 RRs, use them for proofs
But keep track that the proof is not authenticated.
2015-12-26 19:09:10 +01:00
Lennart Poettering d1c4ee3248 resolved: be stricter when searching for a DS RR for a DNSKEY RR 2015-12-26 19:09:10 +01:00
Lennart Poettering 3ecc3df8ff update DNSSEC TODO 2015-12-26 19:09:10 +01:00
Lennart Poettering db5b0e92b3 resolved: tighten search for NSEC3 RRs a bit
Be stricter when searching suitable NSEC3 RRs for proof: generalize the
check we use to find suitable NSEC3 RRs, in nsec3_is_good(), and add
additional checks, such as checking whether all NSEC3 RRs use the same
parameters, have the same suffix and so on.
2015-12-26 19:09:10 +01:00
Lennart Poettering 13b78323ba resolved: when doing NSEC3 proof, first find right NSEC3 suffix
When doing an NSEC3 proof, before detrmining whether a name is the
closest encloser we first need to figure out the longest common suffix
we have with any NSEC3 RR in the reply.
2015-12-26 19:09:10 +01:00
Lennart Poettering e7ff0e0b39 resolved: properly implement RRSIG validation of wildcarded RRsets
Note that this is still not complete, one additional step is still
missing: when we verified that a wildcard RRset is properly signed, we
still need to do an NSEC/NSEC3 proof that no more specific RRset exists.
2015-12-26 19:09:10 +01:00
Lennart Poettering 3e92a71901 resolved: update TODO 2015-12-18 14:48:50 +01:00
Lennart Poettering 105e151299 resolved: add support NSEC3 proofs, as well as proofs for domains that are OK to be unsigned
This large patch adds a couple of mechanisms to ensure we get NSEC3 and
proof-of-unsigned support into place. Specifically:

- Each item in an DnsAnswer gets two bit flags now:
  DNS_ANSWER_AUTHENTICATED and DNS_ANSWER_CACHEABLE. The former is
  necessary since DNS responses might contain signed as well as unsigned
  RRsets in one, and we need to remember which ones are signed and which
  ones aren't. The latter is necessary, since not we need to keep track
  which RRsets may be cached and which ones may not be, even while
  manipulating DnsAnswer objects.

- The .n_answer_cachable of DnsTransaction is dropped now (it used to
  store how many of the first DnsAnswer entries are cachable), and
  replaced by the DNS_ANSWER_CACHABLE flag instead.

- NSEC3 proofs are implemented now (lacking support for the wildcard
  part, to be added in a later commit).

- Support for the "AD" bit has been dropped. It's unsafe, and now that
  we have end-to-end authentication we don't need it anymore.

- An auxiliary DnsTransaction of a DnsTransactions is now kept around as
  least as long as the latter stays around. We no longer remove the
  auxiliary DnsTransaction as soon as it completed. THis is necessary,
  as we now are interested not only in the RRsets it acquired but also
  in its authentication status.
2015-12-18 14:48:50 +01:00
Lennart Poettering 73b8d8e928 resolved: update DNSSEC TODO 2015-12-14 21:32:17 +01:00
Lennart Poettering 72667f0890 resolved: add basic proof of non-existance support for NSEC+NSEC3
Note that this is not complete yet, as we don't handle wildcard domains
correctly, nor handle domains correctly that use empty non-terminals.
2015-12-14 21:28:39 +01:00
Lennart Poettering 0638401af3 resolved: initialize libgcrypt before using it 2015-12-14 21:28:39 +01:00
Lennart Poettering a1972a9185 resolved: rework how we get the gcrypt digest algorithm ID from DNSSEC digest ids
Let's move this into a function digest_to_gcrypt() that we can reuse
later on when implementing NSEC3 validation.
2015-12-14 21:28:39 +01:00
Lennart Poettering 203f1b35d9 resolved: rework dnssec validation results
This adds a new validation result DNSSEC_UNSUPPORTED_ALGORITHM which is
returned when we encounter an unsupported crypto algorithm when trying
to validate RRSIG/DNSKEY combinations. Previously we'd return ENOTSUPP
in this case, but it's better to consider this a non-error DNSSEC
validation result, since our reaction to this case needs to be more like
in cases such as expired or missing keys: we need to keep continue
validation looking for another RRSIG/DNSKEY combination that works
better for us.

This also reworks how dnssec_validate_rrsig_search() propagates errors
from dnssec_validate_rrsig(). Previously, errors such as unsupported
algorithms or expired signatures would not be propagated, but simply be
returned as "missing-key".
2015-12-11 14:14:27 +01:00
Lennart Poettering 547973dea7 resolved: chase DNSKEY/DS RRs when doing look-ups with DNSSEC enabled
This adds initial support for validating RRSIG/DNSKEY/DS chains when
doing lookups. Proof-of-non-existance, or proof-of-unsigned-zones is not
implemented yet.

With this change DnsTransaction objects will generate additional
DnsTransaction objects when looking for DNSKEY or DS RRs to validate an
RRSIG on a response. DnsTransaction objects are thus created for three
reasons now:

1) Because a user asked for something to be resolved, i.e. requested by
   a DnsQuery/DnsQueryCandidate object.
2) As result of LLMNR RR probing, requested by a DnsZoneItem.
3) Because another DnsTransaction requires the requested RRs for
   validation of its own response.

DnsTransactions are shared between all these users, and are GC
automatically as soon as all of these users don't need a specific
transaction anymore.

To unify the handling of these three reasons for existance for a
DnsTransaction, a new common naming is introduced: each DnsTransaction
now tracks its "owners" via a Set* object named "notify_xyz", containing
all owners to notify on completion.

A new DnsTransaction state is introduced called "VALIDATING" that is
entered after a response has been receieved which needs to be validated,
as long as we are still waiting for the DNSKEY/DS RRs from other
DnsTransactions.

This patch will request the DNSKEY/DS RRs bottom-up, and then validate
them top-down.

Caching of RRs is now only done after verification, so that the cache is
not poisoned with known invalid data.

The "DnsAnswer" object gained a substantial number of new calls, since
we need to add/remove RRs to it dynamically now.
2015-12-10 11:35:52 +01:00
Lennart Poettering aa89931749 resolved: when matching up DNSKEY and DS RRs, it's fine if we don't support the DNSKEY's algorithm
As long as we support the digest we are good.
2015-12-10 11:35:52 +01:00
Lennart Poettering 15accc2765 resolved: when matching up RRSIG and DNSKEY RRs, use the RRSIG's signer name, not the owner name
When the DNSKEY is in higher zone, then that's OK, and we need to check
the RRSIG's signer name against the DNSKEY hence.
2015-12-10 11:35:52 +01:00
Lennart Poettering 6c5e8fbf4e resolved: fix sorting of RRsets
We actually maintain an array of pointers to RRs, not of RRs themselves,
fix the qsort() invocation accordingly.
2015-12-10 11:35:52 +01:00
Lennart Poettering d12bf2bdff resolved: fix libgcrypt error checking
libgcrypt encodes the error source in the error code, we need to mask
that away before comparing error codes.
2015-12-10 11:28:02 +01:00
Thomas Hindoe Paaboel Andersen 22ebb9e4a9 resolve: remove unused variable 2015-12-06 13:49:33 +01:00
Lennart Poettering bb1fa24261 resolved: update DNSSEC TODO list a bit 2015-12-03 21:17:50 +01:00
Lennart Poettering 2cd8727718 resolved: maintain a short TODO list for DNSSEC support in the dnssec C files for now 2015-12-03 21:17:49 +01:00
Lennart Poettering 24710c48ed resolved: introduce a dnssec_mode setting per scope
The setting controls which kind of DNSSEC validation is done: none at
all, trusting the AD bit, or client-side validation.

For now, no validation is implemented, hence the setting doesn't do much
yet, except of toggling the CD bit in the generated messages if full
client-side validation is requested.
2015-12-03 21:17:49 +01:00
Lennart Poettering 896c567247 resolved: add a limit on the max DNSSEC RRSIG expiry skew we allow 2015-12-03 21:17:49 +01:00
Lennart Poettering 2a44bec4f6 resolved: make expiration error recognizable 2015-12-03 21:17:49 +01:00
Lennart Poettering 964ef14c25 resolved: support the RSASHA1_NSEC3_SHA1 pseudo-algorithm
RSASHA1_NSEC3_SHA1 is an alias for RSASHA1, used to do NSEC3 feature
negotiation. While verifying RRsets there's no difference, hence support
it here.
2015-12-03 00:39:44 +01:00
Lennart Poettering 2a32632159 resolved: don't accept expired RRSIGs 2015-12-03 00:26:58 +01:00
Lennart Poettering 2b442ac878 resolved: add basic DNSSEC support
This adds most basic operation for doing DNSSEC validation on the
client side. However, it does not actually add the verification logic to
the resolver. Specifically, this patch only includes:

- Verifying DNSKEY RRs against a DS RRs
- Verifying RRSets against a combination of RRSIG and DNSKEY RRs
- Matching up RRSIG RRs and DNSKEY RRs
- Matching up RR keys and RRSIG RRs
- Calculating the DNSSEC key tag from a DNSKEY RR

All currently used DNSSEC combinations of SHA and RSA are implemented. Support
for MD5 hashing and DSA or EC cyphers are not. MD5 and DSA are probably
obsolete, and shouldn't be added. EC should probably be added
eventually, if it actually is deployed on the Internet.
2015-12-02 22:50:11 +01:00