Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add prioritize option for header check order #75

Open
Chheung opened this issue Dec 20, 2022 · 1 comment · May be fixed by #76
Open

Add prioritize option for header check order #75

Chheung opened this issue Dec 20, 2022 · 1 comment · May be fixed by #76

Comments

@Chheung
Copy link

Chheung commented Dec 20, 2022

So X-Forwarded-For header can be exploited with this library if we add XFF header in the request.
On Nginx, we can use the alternative X-Real-IP header for $remote_addr value.

Maybe we can add something like below?

app.use( clientIp.mw({ prioritize: ["x-real-ip",], }) );

This will push change header priority list from default
[ 'x-client-ip', 'x-forwarded-for', 'cf-connecting-ip', 'fastly-client-ip', 'true-client-ip', 'x-real-ip', 'x-cluster-client-ip', 'x-forwarded', 'forwarded-for', 'forwarded', 'x-appengine-user-ip', ];

to

[ 'x-real-ip', 'x-client-ip', 'x-forwarded-for', 'cf-connecting-ip', 'fastly-client-ip', 'true-client-ip', 'x-cluster-client-ip', 'x-forwarded', 'forwarded-for', 'forwarded', 'x-appengine-user-ip', ];

Screen Shot 2022-12-20 at 4 27 59 PM

Screen Shot 2022-12-20 at 4 31 43 PM

@Chheung
Copy link
Author

Chheung commented Dec 20, 2022

I will make a PR on this.
#76

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 a pull request may close this issue.

1 participant