aws / aws-appsync-community

The AWS AppSync community
https://aws.amazon.com/appsync
Apache License 2.0
506 stars 32 forks source link

The resolver context includes the authorization header #300

Open sashee opened 1 year ago

sashee commented 1 year ago

The ctx.request.headers.authorization contains the exact authorization header that the client sent in the request.

image

This is a very sensitive information as that allows anybody who can read it to send requests impersonating the user with that token. And since it's included in the context, it's very easy to accidentally log them:

export function request(ctx) {
  console.log(ctx)
  // ...
}
module.exports.handler = async (event) => {
  console.log(event)
  // ...
};

I think since the context already contains the identity with all important information about the caller, the authorization header should be removed or at least truncated.

Interestingly, AppSync resolver logging omits this:

image

And at the end of the request, it is truncated:

image

onlybakam commented 9 months ago

That's correct, when AppSync logs the context object, sensitive information is removed from the log message. However, we do not edit/redact any information that is logged via console.log functions. The identity data and header data is made available in the context to allow developers to take specific action based on the values