-
Notifications
You must be signed in to change notification settings - Fork 19
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
Do not be case-sensitive when checking http headers #2277
Conversation
Hello williamlardier,My role is to assist you with the merge of this Available options
Available commands
Status report is not available. |
ffd13b2
to
eb725d6
Compare
Request integration branchesWaiting for integration branch creation to be requested by the user. To request integration branches, please comment on this pull request with the following command:
Alternatively, the |
eb725d6
to
89a7f0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need the extra conversion to lowercase, can't we just fix the 'X-Forwarded-For' where it is defined instead?
This adds a (small) overhead to every check, slightly increasing latency... and small things add up, over time...
// Request headers in nodejs are lower-cased, so we should not | ||
// be case-sentive when looking for the header, as http headers | ||
// are case-insensitive. | ||
const ipFromHeader = request.headers[extractClientIPFromHeader.toLowerCase()]?.toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking a few lines above, we already retrieve the x-forwarded-for header:
const clientIp = (requestConfig ? remoteAddress : request.headers['x-forwarded-for'] || remoteAddress)?.toString() ?? '';
this seems inconsistent, please take the chance to review and clean this...
Esp. if requestConfig
is not provided, we kind of bindly trust the x-forwarded-for
header : is this really expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we really need the extra conversion to lowercase, can't we just fix the 'X-Forwarded-For' where it is defined instead?
We could do it but the headers are case-insensitive anyway, so the current code is not following the standard and we might have more issues in the future...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking a few lines above, we already retrieve the x-forwarded-for header:
const clientIp = (requestConfig ? remoteAddress : request.headers['x-forwarded-for'] || remoteAddress)?.toString() ?? '';
this seems inconsistent, please take the chance to review and clean this...
Esp. if requestConfig is not provided, we kind of bindly trust the x-forwarded-for header : is this really expected?
I am not aware of any deployment today that does not set the requestConfig
, but this header retrieval was introduced in https://scality.atlassian.net/browse/ARSN-57, so here: https://github.com/scality/Arsenal/pull/1693/files#diff-ca8ab692737b69e1ab977a7a6104be671972410cafadea45b119e8259070ad1bR11
If the question is whether we should trust the header blindly or not: as long as the proxy is not trusted we should not trust the header. I will remove this logic to be on the safe side.
Previously we were not using IP conditions so it was only about displaying the info in logs, hence the previous change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extractClientIPFromHeader probably does not work if not equal to x-forwarded-for
Please elaborate what you mean by "does not work": it's a string field, that can be any header: e.g., we can have a custom header set by nginx and use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extractClientIPFromHeader probably does not work if not equal to x-forwarded-for
Please elaborate what you mean by "does not work": it's a string field, that can be any header: e.g., we can have a custom header set by nginx and use it.
"does not work" was too quick, I missed the condition on requestConfig
extractClientIPFromHeader
probably does not work if not equal to x-forwarded-for
Issue: ARSN-453
/create_integration_branches |
Integration data createdI have created the integration data for the additional destination branches.
The following branches will NOT be impacted:
You can set option
The following options are set: create_integration_branches |
Waiting for approvalThe following approvals are needed before I can proceed with the merge:
The following options are set: create_integration_branches |
/approve |
I have successfully merged the changeset of this pull request
The following branches have NOT changed:
Please check the status of the associated issue ARSN-453. Goodbye williamlardier. The following options are set: approve, create_integration_branches |
This is affecting policies evaluation in both the S3 and IAM services, when there is a condition on the IP.
No impact for S3C because the header is already properly formatted, but not in Zenko.
Issue: ARSN-453