Skip to content

MIGRATION ISSUE: Issue using SignatureV4 signer with wildcards after upgrade from AWS SDK v2 to v3 #7014

@cwperks

Description

@cwperks

Pre-Migration Checklist

Which JavaScript Runtime is this issue in?

Node.js (includes AWS Lambda)

AWS Lambda Usage

  • Yes, my application is running on AWS Lambda.
  • No, my application is not running on AWS Lambda.

Describe the Migration Issue

After upgrading from AWS SDK v2 to v3, there are differences in signature calculation for requests that have a path containing a wildcard (*)

See the associated issue on OpenSearch-Dashboards repo here: opensearch-project/OpenSearch-Dashboards#9679 (comment)

If I add a snippet to encode the wildcard before signing, then the request succeeds:

if (request.path) {
  request.path = request.path.replace(/\*/g, '%2A');
}

I have tried setting uriEscapePath to true when creating the SignatureV4 signer, but it does not resolve the issue.

Code Comparison

v2 (link to connector)

signRequest(request, creds) {
  const signer = new AWS.Signers.V4(request, this.service);
  signer.addAuthorization(creds, new Date());
}

v3 (link to connector)

import { SignatureV4 } from '@aws-sdk/signature-v4';

async signRequest(request, credentials) {
  const signer = new SignatureV4({
    credentials,
    region: this.awsConfig.region,
    service: this.service,
    sha256: Sha256,
  });

  return signer.sign(request);
}

Observed Differences/Errors

In v2 the requests that had paths containing wildcard would succeed, but the same requests fail after upgrading AWS SDK to v3

Additional Context

No response

Metadata

Metadata

Assignees

Labels

v2-v3-inconsistencyBehavior has changed from v2 to v3, or feature is missing altogether

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions