Skip to content

CSP Header is not updated #6955

@pinny13

Description

@pinny13

Checkboxes for prior research

Describe the bug

After reading https://aws.amazon.com/blogs/developer/middleware-stack-modular-aws-sdk-js/ I tried to update my client's CSP policy. When I make the call I can see that middleware args does have my connect-src value, but I see get error saying that call failed due to CSP polity and the print out of the header does NOT include *.amazonaws.com

How can I fix that?

Regression Issue

  • Select this option if this issue appears to be a regression.

SDK version number

@aws-sdk/package-name@version, ...

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

calling from a React component in the browser

Reproduction Steps

client.middlewareStack.add(
    (next) => async (args: any) => {
      // Add CSP headers to the request
      if (!args.request.headers) {
        args.request.headers = {};
      }

      args.request.headers["Content-Security-Policy"] = [
        "default-src 'self';",
        "script-src 'self' 'unsafe-inline' *.awswaf.com;",
        "connect-src 'self' *.amazonaws.com;",
        "img-src 'self' data: https:;",
        "style-src 'self' 'unsafe-inline';",
        "frame-ancestors 'none';",
        "object-src 'none'",
      ].join(" ");

      console.log("!!! ARGS !!!", args);
      // Call the next middleware in the stack
      // return next(args);

      const result = await next(args);
      return result;
    },
    {
      step: "build",
      name: "addSecurityHeadersMiddleware",
    }
  );

  return client;
};

Observed Behavior

CSP is not updated

Expected Behavior

CSP should be updated

Possible Solution

No response

Additional Information/Context

No response

Metadata

Metadata

Assignees

Labels

bugThis issue is a bug.closed-for-stalenessp2This is a standard priority issueresponse-requestedWaiting on additional info and feedback. Will move to \"closing-soon\" in 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions