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

fix: AWS region selection for SigV4 signing unmanaged endpoints #14037

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Zordrak
Copy link

@Zordrak Zordrak commented Mar 19, 2025

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:

  • URL: https://iam.amazonaws.com/
  • Type: POST (GET is also supported, but POST seems most canonical)
  • Content-Type: x-www-url-encoded
  • Content: Action=ListUsers&Version=2010-05-08

For anyone happening into this issue, the correct behaviour can be easily emulated with curl:

curl  \
  -X POST
  --user "${AWS_ACCESS_KEY_ID}":"${AWS_SECRET_ACCESS_KEY}" \
  --aws-sigv4 "aws:amz:us-east-1:iam" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d 'Action=ListUsers&Version=2010-05-08' \
  "https://iam.amazonaws.com/"

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

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created. -- NOTE As a pure bugfix, should require no docfix.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

Sorry, something went wrong.

@CLAassistant
Copy link

CLAassistant commented Mar 19, 2025

CLA assistant check
All committers have signed the CLA.

@n8n-assistant n8n-assistant bot added community Authored by a community member node/improvement New feature or request in linear Issue or PR has been created in Linear for internal review labels Mar 19, 2025
@Joffcom
Copy link
Member

Joffcom commented Mar 19, 2025

Hey @Zordrak,

Thanks for the PR, We have created "GHC-1270" as the internal reference to get this reviewed.

One of us will be in touch if there are any changes needed, in most cases this is normally within a couple of weeks but it depends on the current workload of the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Authored by a community member in linear Issue or PR has been created in Linear for internal review node/improvement New feature or request
Projects
None yet
3 participants