From 27273a3a269b4ef83ef49590e70dddd2cd61980a Mon Sep 17 00:00:00 2001 From: Oleg Guba Date: Fri, 6 Jun 2025 05:14:41 -0700 Subject: [PATCH] [plugin/cache] create a copy of a response to ensure original data is never modified (#7357) Signed-off-by: Oleg Guba --- plugin/cache/cache.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin/cache/cache.go b/plugin/cache/cache.go index 4a6377b9a..6dc6dc0a2 100644 --- a/plugin/cache/cache.go +++ b/plugin/cache/cache.go @@ -182,6 +182,7 @@ func (w *ResponseWriter) RemoteAddr() net.Addr { // WriteMsg implements the dns.ResponseWriter interface. func (w *ResponseWriter) WriteMsg(res *dns.Msg) error { + res = res.Copy() mt, _ := response.Typify(res, w.now().UTC()) // key returns empty string for anything we don't want to cache.