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

Consider processing XFO values only as much as needed #6

Open
jub0bs opened this issue Sep 3, 2024 · 0 comments
Open

Consider processing XFO values only as much as needed #6

jub0bs opened this issue Sep 3, 2024 · 0 comments

Comments

@jub0bs
Copy link

jub0bs commented Sep 3, 2024

Function getIPAddrList contains the following comment:

// Possible performance improvements:
// Here we are parsing _all_ of the IPs in the XFF headers, but we don't need all of
// them. Instead, we could start from the left or the right (depending on strategy),
// parse as we go, and stop when we've come to the one we want. But that would make
// the various strategies somewhat more complex.

Indeed. At the moment, because that function splits the values of the XFO fields on commas, adversaries could send a maliciously long XFO header full of commas in order to cause many allocations; see rs/cors#170.

If the various strategies were modified to rely on Go 1.23's iterators (one for each direction), performance could be improved.

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

No branches or pull requests

1 participant