kataras / kataras/iris

Potential X-Forwarded-For parsing improvements

Open
#1,453 5 comments 0 reactions 0 assignees View on GitHub
🏋️‍♀️ type:task 🚀 status:implemented
Dominant language
Go
Stars
25.6k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

I noticed a couple of potential issues which might be hard to debug, for people using RemoteAddr() functions.

1. It does not seem to me that this comparison in `context.go` should care about string case. (Some people might expect to be able to configure `X-FORWARDED-FOR` rather than `X-Forwarded-For` and expect the same functionality.)
```
if headerName == xForwardedForHeaderKey {
...
}
```
2. This is maybe something that could be corrected in server configurations outside of the library, but simply taking the first IP in the X-Forwarded-For list opens up client spoofing. The issue (and a potential solution) is explained in more detail at the bottom of this article: https://husobee.github.io/golang/ip-address/2015/12/17/remote-ip-go.html. (Their solution would also probably require new Configuration options allowing users to specify the private subnets they want excluded, though.)

Contributor guide

Open the contributing guide

Research direction

Start in context.go at the headerName comparison and trace RemoteAddr() handling of X-Forwarded-For. Compare the current first-address behavior with the linked article’s trusted/private-subnet discussion. Done means the intended case handling and spoofing-resistant configuration are specified and covered by relevant tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.