aws / aws/aws-appsync-community

The resolver context includes the authorization header

Open
#300 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
507
Forks
37
PR merge metrics
No merged PRs in 30d

Description

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

![image](https://github.com/aws/aws-appsync-community/assets/82075/89109e0d-78f5-4e57-af39-c80ee1b87777)

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:

- A simple console.log leaks it:

```
export function request(ctx) {
console.log(ctx)
// ...
}
```

- Passing it to a Lambda, either via the ```payload``` or with a direct lambda resolver and then log the event (very common for debugging):

```
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](https://github.com/aws/aws-appsync-community/assets/82075/45dc6210-d718-4a70-a20d-b821b2253458)

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

![image](https://github.com/aws/aws-appsync-community/assets/82075/f1489dea-b545-4537-9faf-330443f31eb2)

Contributor guide

Open the contributing guide

Research direction

No repository file, test, or implementation entry point is identified in the issue. Start by reviewing the resolver context field ctx.request.headers.authorization and the documented identity and logging behavior. Done means the authorization token is no longer exposed in resolver context or is safely truncated, with coverage for resolver and Lambda logging paths.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, graphql
Domain
api, security
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.