Vulnerability Database

362,176

Total vulnerabilities in the database

TsDProxy: X-Forwarded-For header injection allows IP spoofing in proxied requests to backend services — github.com/almeidapaulopt/tsdproxy

Improper Neutralization of Special Elements in Output Used by a Downstream Component ('Injection')

Description

The HTTP reverse proxy handler in tsdproxy does not strip the X-Forwarded-For (or X-Real-IP) header from incoming requests before calling r.SetXForwarded(). This allows an authenticated Tailscale user to inject arbitrary X-Forwarded-For values that are forwarded verbatim to backend services.

// internal/proxymanager/port.go -- Rewrite function Rewrite: func(r *httputil.ProxyRequest) { r.SetURL(pconfig.GetFirstTarget()) r.Out.Host = r.In.Host // Strips tsdproxy identity headers (correct) r.Out.Header.Del(consts.HeaderID) r.Out.Header.Del(consts.HeaderRemoteUser) r.Out.Header.Del(consts.HeaderXForwardedUser) // ... other identity headers deleted ... // X-Forwarded-For is NOT deleted before SetXForwarded! // X-Real-IP is NOT deleted at all! r.SetXForwarded() // APPENDS client IP to attacker-controlled XFF list },

Per Go's httputil.ProxyRequest.SetXForwarded() documentation: > If the inbound request has an existing X-Forwarded-For header, SetXForwarded appends the inbound request's remote address to the list.

Result when attacker sends X-Forwarded-For: 127.0.0.1:

  • Backend receives: X-Forwarded-For: 127.0.0.1, <real-tailscale-client-ip>
  • If backend reads first element as "original client", attacker appears as 127.0.0.1

X-Real-IP is not handled at all -- if the attacker sets X-Real-IP: 127.0.0.1, it is forwarded to the backend verbatim without any overriding or stripping.

Many backend applications trust the first element of X-Forwarded-For (or X-Real-IP) for:

  • IP-based access control (admin panels restricted to 127.0.0.1)
  • Rate limiting tied to source IP
  • Audit logging
  • Geo-blocking or network-segment restrictions

This is particularly impactful in tsdproxy's intended use case where the backend service is only accessible through tsdproxy -- making the proxy's header handling the sole enforcement point.

CVSS

CVSS v3.1: AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:H/A:N = 7.7

Severity

High

Affected Code / Files

  • internal/proxymanager/port.go -- newPortProxy Rewrite closure
  • Missing: r.Out.Header.Del("X-Forwarded-For") before r.SetXForwarded()
  • Missing: r.Out.Header.Del("X-Real-IP") unconditional strip

Steps to Reproduce

  1. Deploy tsdproxy with a backend service that restricts /admin to 127.0.0.1 via X-Forwarded-For (e.g., Nginx with real_ip_header X-Forwarded-For and real_ip_recursive on)
  2. As an authenticated Tailscale user (non-admin), make a request through the proxy:
curl -H &quot;X-Forwarded-For: 127.0.0.1&quot; \ https://&lt;proxy-hostname&gt;.ts.net/admin
  1. Backend receives: X-Forwarded-For: 127.0.0.1, <your-tailscale-ip>
  2. Nginx real_ip_recursive resolves left-most non-trusted IP; if tailscale range is the only trusted range, 127.0.0.1 becomes the "real" IP, bypassing admin restriction.

For the X-Real-IP vector:

curl -H &quot;X-Real-IP: 127.0.0.1&quot; \ https://&lt;proxy-hostname&gt;.ts.net/admin # Backend receives X-Real-IP: 127.0.0.1 verbatim

PoC Script (if used)

#!/bin/bash # Demonstrate XFF injection through tsdproxy PROXY_HOST=&quot;${1}&quot; # e.g. myapp.my-tailnet.ts.net curl -v \ -H &quot;X-Forwarded-For: 127.0.0.1&quot; \ -H &quot;X-Real-IP: 127.0.0.1&quot; \ &quot;https://${PROXY_HOST}/&quot; # Expected: backend sees XFF: 127.0.0.1, &lt;tailscale-ip&gt; # backend sees X-Real-IP: 127.0.0.1 (unmodified)

Impact

An authenticated Tailscale user who should only have regular user access can:

  1. Bypass IP-based admin restrictions on the backend application by spoofing X-Forwarded-For to 127.0.0.1
  2. Appear as any arbitrary IP address in audit logs
  3. Bypass rate limiting tied to source IP
  4. Bypass geo-blocking or network-segment restrictions enforced by the backend

This is especially impactful because tsdproxy is designed as the sole access point for backend services that are otherwise network-isolated -- making the proxy the only enforcement boundary.

Fix: Add r.Out.Header.Del("X-Forwarded-For") and r.Out.Header.Del("X-Real-IP") in the Rewrite closure before calling r.SetXForwarded(). This ensures only the real Tailscale client IP appears in the XFF chain.

Credits

Reported by Vishal Shukla (@shukla304) using sechub.dev AI Agent

Support

If this disclosure work has been useful, sponsoring helps fund continued open-source security audits -- appreciated either way.

  • Published: Jul 14, 2026
  • Updated: Jul 15, 2026
  • GHSA: GHSA-pqg7-v6wh-3pfp
  • Severity: High
  • Exploit:
  • CISA KEV:

CVSS v3:

  • Severity: High
  • Score: 8.5
  • AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:H/A:N

CWEs:

Frequently Asked Questions

A security vulnerability is a weakness in software, hardware, or configuration that can be exploited to compromise confidentiality, integrity, or availability. Many vulnerabilities are tracked as CVEs (Common Vulnerabilities and Exposures), which provide a standardized identifier so teams can coordinate patching, mitigation, and risk assessment across tools and vendors.

CVSS (Common Vulnerability Scoring System) estimates technical severity, but it doesn't automatically equal business risk. Prioritize using context like internet exposure, affected asset criticality, known exploitation (proof-of-concept or in-the-wild), and whether compensating controls exist. A "Medium" CVSS on an exposed, production system can be more urgent than a "Critical" on an isolated, non-production host.

A vulnerability is the underlying weakness. An exploit is the method or code used to take advantage of it. A zero-day is a vulnerability that is unknown to the vendor or has no publicly available fix when attackers begin using it. In practice, risk increases sharply when exploitation becomes reliable or widespread.

Recurring findings usually come from incomplete Asset Discovery, inconsistent patch management, inherited images, and configuration drift. In modern environments, you also need to watch the software supply chain: dependencies, containers, build pipelines, and third-party services can reintroduce the same weakness even after you patch a single host. Unknown or unmanaged assets (often called Shadow IT) are a common reason the same issues resurface.

Use a simple, repeatable triage model: focus first on externally exposed assets, high-value systems (identity, VPN, email, production), vulnerabilities with known exploits, and issues that enable remote code execution or privilege escalation. Then enforce patch SLAs and track progress using consistent metrics so remediation is steady, not reactive.

SynScan combines attack surface monitoring and continuous security auditing to keep your inventory current, flag high-impact vulnerabilities early, and help you turn raw findings into a practical remediation plan.