fix: AWS region selection for SigV4 signing unmanaged endpoints #14037
+154
−12
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
A couple of bugs are reported with issues using HTTP Request with AWS Credentials. n8n uses SigV4 signing (as opposed to SigV4a) which requires that the service's region is included in the signing request, and the region must match the region the service endpoint is hosted in.
Mostly the problems seem to be S3, where the code expects that the second part of the URL will be a region (service.region.amazonaws.com), where with S3 it is slightly different (bucket.s3-region.amazonaws.com or bucket.s3.amazonaws.com), resulting in attempts to sign with service identifiers like "aws:amz:s3:s3" instead of "aws:amz:s3:us-east-1".
This PR should simultaneously fix the S3 issues, and issues where someone's default credentials specify a region they are working in, but they use a global endpoint such as IAM or Route53 where the URL does not contain a region, and being hosted in us-east-1, the only acceptable signing region is us-east-1.
This all said, I have personally come down this rabbit hole because I am having trouble using HTTP Request with AWS IAM, and the error I get is not that the region is unexpected, but that the signature doesn't match at all. I still haven't resolved this problem and I may have to resort to running local copies to do some deep debugging. However, if one of the team is able to check over this PR, and locally test the behaviour of using HTTP Request with AWS IAM, it may be that you can more quickly root out the problem. Ultimately it ought to be a simple use case to specify AWS credentials, and use them for an HTTP Request node:
https://iam.amazonaws.com/
POST
(GET is also supported, but POST seems most canonical)x-www-url-encoded
Action=ListUsers&Version=2010-05-08
For anyone happening into this issue, the correct behaviour can be easily emulated with curl:
EDIT: The IAM issue is an unrelated bug for which a fix is offered in #14060
Related Linear tickets, Github issues, and Community forum posts
fixes #10459
fixes #12216
fixes N8N-7962
Related to (kinda): #14060
Review / Merge checklist
release/backport
(if the PR is an urgent fix that needs to be backported)