Commit 37a81ee018 for bind

commit 37a81ee0185d8852ee83f60ffe951e2eeb4b8dbc
Author: Martin Basti <mbasti@isc.org>
Date:   Fri Nov 27 13:49:16 2026 +0000

    Obscure shared secrets in "rndc showconf" output

    "rndc showconf -user" and "-effective" printed TSIG key secrets and
    cookie-secret verbatim. The control channel is authenticated but not
    encrypted, so anyone able to observe the traffic could learn them,
    including the rndc key itself when it is defined in named.conf.

    Print the configuration with CFG_PRINTER_XKEY, as
    "named-checkconf -p -x" does.

    Assisted-by: Claude:claude-mythos-5-2

diff --git a/bin/named/server.c b/bin/named/server.c
index 238f057529..7013776085 100644
--- a/bin/named/server.c
+++ b/bin/named/server.c
@@ -13128,7 +13128,7 @@ named_server_showconf(named_server_t *server, isc_lex_t *lex,
 		goto cleanup;
 	}

-	cfg_printx(config, 0, emit_text, &dzarg);
+	cfg_printx(config, CFG_PRINTER_XKEY, emit_text, &dzarg);
 	result = dzarg.result;

 cleanup:
diff --git a/bin/rndc/rndc.rst b/bin/rndc/rndc.rst
index bad12f66c6..cbd6ef08c3 100644
--- a/bin/rndc/rndc.rst
+++ b/bin/rndc/rndc.rst
@@ -579,6 +579,9 @@ Currently supported commands are:
    valiation``), are shown as configured, not as currently set, and zones that
    are dynamically added using ``rndc addzone`` are not visible.

+   Shared secrets (``secret`` in ``key`` statements and ``cookie-secret``)
+   are replaced with question marks, as in ``named-checkconf -p -x``.
+
    See also :option:`rndc showzone`.

 .. option:: showzone zone [class [view]]
diff --git a/bin/tests/system/showconf/ns1/named.conf.j2 b/bin/tests/system/showconf/ns1/named.conf.j2
index a21e0861ab..b94157f2ec 100644
--- a/bin/tests/system/showconf/ns1/named.conf.j2
+++ b/bin/tests/system/showconf/ns1/named.conf.j2
@@ -4,6 +4,7 @@ options {
 	dnssec-validation no;
 	minimal-responses no;
 	allow-new-zones yes;
+	cookie-secret "ebc7701beabb4a40ebc7701beabb4a40";
 };

 {% include "_common/controls.conf.j2" %}
diff --git a/bin/tests/system/showconf/tests_showconf.py b/bin/tests/system/showconf/tests_showconf.py
index 88045a1bd6..11fa09b5ca 100644
--- a/bin/tests/system/showconf/tests_showconf.py
+++ b/bin/tests/system/showconf/tests_showconf.py
@@ -55,3 +55,17 @@ def test_showconf(ns1):
     response = ns1.rndc("showconf", raise_on_exception=False)
     assert response.rc != 0
     assert "rndc: 'showconf' failed: unexpected end of input" in response.err
+
+
+# Shared secrets must never be sent over the control channel, which is
+# authenticated but not encrypted.
+def test_showconf_secrets(ns1):
+    for mode in ("-user", "-effective", "-builtin"):
+        config = ns1.rndc(f"showconf {mode}")
+        assert "1234abcd8765" not in config.out
+        assert "ebc7701beabb4a40ebc7701beabb4a40" not in config.out
+
+    for mode in ("-user", "-effective"):
+        config = ns1.rndc(f"showconf {mode}")
+        assert 'secret "????????????";' in config.out
+        assert 'cookie-secret "????????????????????????????????";' in config.out