close
Skip to content

Potential X-Forwarded-For parsing improvements #1453

@ttt733

Description

@ttt733

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 {
    ...
}
  1. 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.)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions