From 87a41cf558523b6b0f5d7102e976b33745ae77d7 Mon Sep 17 00:00:00 2001 From: Oleg Guba Date: Thu, 5 Jun 2025 14:14:15 -0700 Subject: [PATCH] [plugin/cache] create a copy of a response to ensure original data is never modified 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 4a6377b9ad..6dc6dc0a21 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.