The Wayback Machine - https://web.archive.org/web/20210802174135/https://github.com/labstack/echo/pull/1478
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

Safer/trustable extraction of real ip from request #1478

Merged
merged 4 commits into from Feb 24, 2020

Conversation

@tmshn
Copy link
Contributor

@tmshn tmshn commented Jan 15, 2020

IP address extraction using HTTP header requires additional care. Otherwise attackers might have a chance to deceive wrong ip address.

I fixed this problem.

See also: #855

I wrote detailed doc in labstack/echox#134, tl; dr:

  • Don't use HTTP header unless it's reported by trustable client
  • For XFF header, use rightmost untrustable value, not the leftmost value.
  • When proxing, don't relay incoming X-Real-IP unless it's reported by trustable client

Especially about XFF header parsing, see implementations from other players:

Another note about XFF header:

@codecov
Copy link

@codecov codecov bot commented Jan 15, 2020

Codecov Report

Merging #1478 into master will increase coverage by 0.36%.
The diff coverage is 96.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1478      +/-   ##
==========================================
+ Coverage   84.42%   84.79%   +0.36%     
==========================================
  Files          27       28       +1     
  Lines        2093     2157      +64     
==========================================
+ Hits         1767     1829      +62     
- Misses        212      213       +1     
- Partials      114      115       +1
Impacted Files Coverage Δ
echo.go 85.75% <ø> (ø) ⬆️
context.go 90.43% <0%> (-0.73%) ⬇️
ip.go 100% <100%> (ø)
middleware/proxy.go 66% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 504f39a...d669727. Read the comment docs.

@tmshn tmshn force-pushed the tmshn:trustable-ip branch 4 times, most recently from bdff2da to 44976af Jan 18, 2020
@tmshn tmshn force-pushed the tmshn:trustable-ip branch from a6a92c0 to b54cdb6 Feb 9, 2020
@tmshn tmshn changed the title [WIP] Safer/trustable extraction of real ip from request Safer/trustable extraction of real ip from request Feb 9, 2020
@vishr
vishr approved these changes Feb 24, 2020
@vishr vishr merged commit 7c5af01 into labstack:master Feb 24, 2020
12 checks passed
12 checks passed
@github-actions
ubuntu-latest @ Go 1.11
Details
@github-actions
ubuntu-latest @ Go 1.12
Details
@github-actions
ubuntu-latest @ Go 1.13
Details
@github-actions
macos-latest @ Go 1.11
Details
@github-actions
macos-latest @ Go 1.12
Details
@github-actions
macos-latest @ Go 1.13
Details
@github-actions
windows-latest @ Go 1.11
Details
@github-actions
windows-latest @ Go 1.12
Details
@github-actions
windows-latest @ Go 1.13
Details
@codecov
codecov/patch 96.92% of diff hit (target 84.42%)
Details
@codecov
codecov/project 84.79% (+0.36%) compared to 504f39a
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@vishr
Copy link
Member

@vishr vishr commented Feb 24, 2020

@tmshn thanks for your work!

@tmshn tmshn deleted the tmshn:trustable-ip branch Feb 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants