Skip to content

fix(security): prevent X-Forwarded-For IP spoofing#1265

Open
jwidan wants to merge 1 commit intoEqual-Vote:mainfrom
jwidan:fix/ip-spoof
Open

fix(security): prevent X-Forwarded-For IP spoofing#1265
jwidan wants to merge 1 commit intoEqual-Vote:mainfrom
jwidan:fix/ip-spoof

Conversation

@jwidan
Copy link
Collaborator

@jwidan jwidan commented Mar 8, 2026

Description

This PR stops an IP spoofing vulnerability that let users forge their request origin and bypass the one vote per network setting. Before this PR, the backend indiscriminately trusted all proxy connections with app.enable('trust proxy'). This let anyone inject arbitrary IP addresses into their X-Forwarded-For HTTP headers, tricking the backend into believing they were voting from a different IP.

Because this application is hosted within Azure AKS, we will still trust ['loopback', 'linklocal', 'uniquelocal'] private subnets. If there are more hops that go through external IPs, please let me know. While my previously successful spoofs no longer work with this PR when testing locally (taking loopback out), I'm not sure if this would work in production so please review :)

* Disables indiscriminately trusting all arbitrary client proxy headers
* Trusts internal routing hops
@netlify
Copy link

netlify bot commented Mar 8, 2026

Deploy Preview for bettervoting ready!

Name Link
🔨 Latest commit d60d85d
🔍 Latest deploy log https://app.netlify.com/projects/bettervoting/deploys/69adbf9384850500089cbba1
😎 Deploy Preview https://deploy-preview-1265--bettervoting.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant