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

network: Use peer address after proxy fix for app rate limiter if available #5848

Merged
merged 8 commits into from Dec 6, 2023

Conversation

algorandskiy
Copy link
Contributor

@algorandskiy algorandskiy commented Nov 29, 2023

Summary

peer.RoutingAddr used to use conn.Addr to get remote IP. Changed to use remoteAddress in order to accommodate possible reverse proxy hiding nodes behind.

Additionally, changed X-Forwarded-For handing to allow the single reverse proxy use case (handle potentially adversarial "X-Forwared-For" headers from clients).
Before: did not use any values if there is a list of values in the first X-Forwarded-For header.
After: use the last value in the list "A, B, C" in the last X-Forwarded-For header.

Test Plan

Added a test ws proxy implementation and a unit test checking the addr is taken from a proxy-provided header.
Added unit tests for X-Forwarded-For and RoutingAddr changes.

@algorandskiy algorandskiy self-assigned this Nov 29, 2023
Copy link

codecov bot commented Nov 29, 2023

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (3abe5c8) 55.83% compared to head (9b70c0f) 29.16%.
Report is 3 commits behind head on master.

Files Patch % Lines
network/wsPeer.go 0.00% 5 Missing ⚠️
network/requestTracker.go 78.57% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #5848       +/-   ##
===========================================
- Coverage   55.83%   29.16%   -26.67%     
===========================================
  Files         477      477               
  Lines       67256    67269       +13     
===========================================
- Hits        37552    19621    -17931     
- Misses      27171    45590    +18419     
+ Partials     2533     2058      -475     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@algorandskiy algorandskiy marked this pull request as ready for review November 30, 2023 00:45
@algorandskiy algorandskiy changed the title WIP: Use peer address after proxy fix for app rate limiter if available network: Use peer address after proxy fix for app rate limiter if available Nov 30, 2023
Copy link
Contributor

@jannotti jannotti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a lot more to read, but need to stop early for the day.

config/localTemplate.go Outdated Show resolved Hide resolved
network/requestTracker.go Outdated Show resolved Hide resolved
network/requestTracker.go Show resolved Hide resolved
network/requestTracker.go Show resolved Hide resolved
Co-authored-by: Jason Paulos <jasonpaulos@users.noreply.github.com>
Copy link
Contributor

@gmalouf gmalouf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Easy to follow, feedback incorporated well. Agree with decision to apply the last in list rule solely X-Forwarded-For.

@algorandskiy algorandskiy merged commit 6592300 into algorand:master Dec 6, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants