]> git.ipfire.org Git - thirdparty/bind9.git/commit
Fix updating summary RPZ DB for mixed-case RPZs
authorMichał Kępień <michal@isc.org>
Mon, 21 Sep 2020 07:28:36 +0000 (09:28 +0200)
committerMichał Kępień <michal@isc.org>
Mon, 21 Sep 2020 07:32:21 +0000 (09:32 +0200)
commit170b869294e5bc48d9158f26e41e7ff3505df00a
tree192a02af17fc9850544fc1d8544253135294c4f3
parent86f9da79640117e0917f4889a79bda284bc82591
Fix updating summary RPZ DB for mixed-case RPZs

Each dns_rpz_zone_t structure keeps a hash table of the names this RPZ
database contains.  Here is what happens when an RPZ is updated:

  - a new hash table is prepared for the new version of the RPZ by
    iterating over it; each name found is added to the summary RPZ
    database,

  - every name added to the new hash table is searched for in the old
    hash table; if found, it is removed from the old hash table,

  - the old hash table is iterated over; all names found in it are
    removed from the summary RPZ database (because at that point the old
    hash table should only contain names which are not present in the
    new version of the RPZ),

  - the new hash table replaces the old hash table.

When the new version of the RPZ is iterated over, if a given name is
spelled using a different letter case than in the old version of the
RPZ, the new variant will hash to a different value than the old
variant, which means it will not be removed from the old hash table.
When the old hash table is subsequently iterated over to remove
seemingly deleted names, the old variant of the name will still be
there, causing the name to be deleted from the summary RPZ database
(which effectively causes a given rule to be ignored).

The issue can be triggered not just by altering the case of existing
names in an RPZ, but also by adding sibling names spelled with a
different letter case.  This is because RBT code preserves case when
node splitting occurs.  The end result is that when the RPZ is iterated
over, a given name may be using a different case than in the zone file
(or XFR contents).

Fix by downcasing all names found in the RPZ database before adding them
to the summary RPZ database.

(cherry picked from commit dc8a7791bd27a7c264e901861875698ef343838c)
bin/tests/system/rpz/clean.sh
bin/tests/system/rpz/ns3/mixed-case-rpz-1.db.in [new file with mode: 0644]
bin/tests/system/rpz/ns3/mixed-case-rpz-2.db.in [new file with mode: 0644]
bin/tests/system/rpz/ns3/named.conf.in
bin/tests/system/rpz/setup.sh
bin/tests/system/rpz/tests.sh
lib/dns/rpz.c