[GH-ISSUE #5189] Netbird management does not resolve X-Forwarded-For header correctly #10042

Open
opened 2026-08-05 01:24:25 -04:00 by saavagebueno · 2 comments
Owner

Originally created by @Muska-Ami on GitHub (Jan 26, 2026).
Original GitHub issue: https://github.com/netbirdio/netbird/issues/5189

Describe the problem

When I remove ReverseProxy.TrustedHTTPProxies configuration, it works, but netbird doesn't resolve the X-Forwarded-For header correctly.

This is a example XFF header:

X-Forwarded-For: 1.1.1.1, 8.8.8.8
# X-Forwarded-For: <client>, <proxy1>, <proxy2>, ...

As the XFF header defintion, we should use the first IP as client IP (1.1.1.1), but netbird use the last one (8.8.8.8), finally it get the proxy's IP(LB or CDN) and treat it as client IP.

PS: I've removed X-Real-IP header and only X-Forwarded-For header present. So I'm sure this is a bug related to netbird.

Originally posted by @Muska-Ami in #1970

To Reproduce

Steps to reproduce the behavior:

  1. Deploy management service under a OpenResty proxy and then proxy through a CDN

Expected behavior

Netbird should use the first IP of XFF header.

Are you using NetBird Cloud?

No

Additional context

https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-For

Have you tried these troubleshooting steps?

  • Reviewed client troubleshooting (if applicable)
  • Checked for newer NetBird versions
  • Searched for similar issues on GitHub (including closed ones)
  • Restarted the NetBird client
  • Checked firewall settings
Originally created by @Muska-Ami on GitHub (Jan 26, 2026). Original GitHub issue: https://github.com/netbirdio/netbird/issues/5189 **Describe the problem** > When I remove `ReverseProxy.TrustedHTTPProxies` configuration, it works, but netbird doesn't resolve the `X-Forwarded-For` header correctly. > > This is a example XFF header: > > ``` > X-Forwarded-For: 1.1.1.1, 8.8.8.8 > # X-Forwarded-For: <client>, <proxy1>, <proxy2>, ... > ``` > > As the XFF header defintion, we should use the first IP as client IP (1.1.1.1), but netbird use the last one (8.8.8.8), finally it get the proxy's IP(LB or CDN) and treat it as client IP. > > PS: I've removed `X-Real-IP` header and only `X-Forwarded-For` header present. So I'm sure this is a bug related to netbird. _Originally posted by @Muska-Ami in [#1970](https://github.com/netbirdio/netbird/issues/1970#issuecomment-3798500658)_ **To Reproduce** Steps to reproduce the behavior: 1. Deploy management service under a OpenResty proxy and then proxy through a CDN **Expected behavior** Netbird should use the first IP of XFF header. **Are you using NetBird Cloud?** No **Additional context** https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/X-Forwarded-For **Have you tried these troubleshooting steps?** - [x] Reviewed [client troubleshooting](https://docs.netbird.io/how-to/troubleshooting-client) (if applicable) - [x] Checked for newer NetBird versions - [x] Searched for similar issues on GitHub (including closed ones) - [x] Restarted the NetBird client - [x] Checked firewall settings
saavagebueno added the triage-needed label 2026-08-05 01:24:25 -04:00
Author
Owner

@lixmal commented on GitHub (Jan 27, 2026):

Note: The first IP is user-controllable; attackers can insert arbitrary IPs there. Instead we need to traverse the list from right to left until the first non trusted proxy IP is found

<!-- gh-comment-id:3803245805 --> @lixmal commented on GitHub (Jan 27, 2026): Note: The first IP is user-controllable; attackers can insert arbitrary IPs there. Instead we need to traverse the list from right to left until the first non trusted proxy IP is found
Author
Owner

@Muska-Ami commented on GitHub (Jan 27, 2026):

This should not implement a check on netbird but proxy side.

This should be set up on a frontend proxy, or just using remote connect IP as client IP.

<!-- gh-comment-id:3803303455 --> @Muska-Ami commented on GitHub (Jan 27, 2026): This should not implement a check on netbird but proxy side. This should be set up on a frontend proxy, or just using remote connect IP as client IP.
Sign in to join this conversation.
No Label triage-needed
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#10042