From df4b97097c48378267da97236583b31d3935ac8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= Date: Sat, 18 Apr 2026 05:41:10 +0800 Subject: [PATCH] Loopback outbound: Avoid directly modifying potential shared ctx (#5960) Fixes https://github.com/XTLS/Xray-core/issues/5958 --- proxy/loopback/loopback.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/proxy/loopback/loopback.go b/proxy/loopback/loopback.go index ab3360ae..2f54fe74 100644 --- a/proxy/loopback/loopback.go +++ b/proxy/loopback/loopback.go @@ -45,9 +45,11 @@ func (l *Loopback) Process(ctx context.Context, link *transport.Link, _ internet ctx = session.ContextWithContent(ctx, content) - inbound := session.InboundFromContext(ctx) - if inbound == nil { - inbound = &session.Inbound{} + inbound := &session.Inbound{} + originInbound := session.InboundFromContext(ctx) + if originInbound != nil { + // get a shallow copy to avoid modifying the inbound tag in upstream context + *inbound = *originInbound } inbound.Tag = l.config.InboundTag