diff --git a/bin/tests/system/bailiwick/ans1/ans.py b/bin/tests/system/bailiwick/ans1/ans.py index be072a39e1..f0b152ac3d 100644 --- a/bin/tests/system/bailiwick/ans1/ans.py +++ b/bin/tests/system/bailiwick/ans1/ans.py @@ -29,6 +29,37 @@ ATTACKER_IP = "10.53.0.3" TTL = 3600 +class SiblingNsSpoofer(ResponseSpoofer, mode="sibling-ns"): + + qname = "trigger." + + async def get_responses( + self, qctx: QueryContext + ) -> AsyncGenerator[ResponseAction, None]: + response = qctx.prepare_new_response(with_zone_data=False) + + txt_rrset = dns.rrset.from_text( + qctx.qname, + TTL, + qctx.qclass, + dns.rdatatype.TXT, + '"spoofed answer with extra NS"', + ) + response.answer.append(txt_rrset) + + ns_rrset = dns.rrset.from_text( + "victim.", TTL, qctx.qclass, dns.rdatatype.NS, "ns.attacker." + ) + response.authority.append(ns_rrset) + + a_rrset = dns.rrset.from_text( + "ns.attacker.", TTL, qctx.qclass, dns.rdatatype.A, ATTACKER_IP + ) + response.additional.append(a_rrset) + + yield DnsResponseSend(response, authoritative=True) + + def main() -> None: spoofing_server().run() diff --git a/bin/tests/system/bailiwick/tests_bailiwick.py b/bin/tests/system/bailiwick/tests_bailiwick.py index 79ee8a4364..b068180265 100644 --- a/bin/tests/system/bailiwick/tests_bailiwick.py +++ b/bin/tests/system/bailiwick/tests_bailiwick.py @@ -77,3 +77,11 @@ def check_domain_hijack(ns4: NamedInstance) -> None: "TXT", '"correct answer from the domain under attack"', ) + + +def test_bailiwick_sibling_ns_referral(servers: Dict[str, NamedInstance]) -> None: + set_spoofing_mode(ans1="sibling-ns", ans2="none") + + ns4 = servers["ns4"] + send_trigger_query(ns4, "trigger.") + check_domain_hijack(ns4)