Querystring handling incorrect for signature generation
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- aws, javascript
- Domain
- authentication, cloud, security
Research direction
Start in src/functions/auth/auth.mjs around lines 40-48 and compare the current HttpRequest construction with the AWS Signature Version 4 canonicalization documentation. Exercise the auth function with a Lambda function URL containing query parameters, ensuring URI and query values are passed separately. Done means requests with query strings produce valid signatures.
Written by the indexing model from the issue text.
Description
Came across the Protecting an AWS Lambda function URL with Amazon CloudFront and Lambda@Edge blog post. As I attempted to leverage the auth function in a more generalized solution, I encountered issues where the signature was invalid (example: The request signature we calculated does not match the signature you provided). After debugging and reviewing signature generation documentation, my issues were related to function url calls with querystring values. Specifically here:
Based on the signature generation documentation, it's important for the uri and querystrings to be handled separately for canonicalization. In order for valid signatures to be generated, I needed to change the above to something along the lines of the following where querystrings are provided to the request as a QueryParameterBag:
const query = {};
for (const qs of request.querystring.split('&')) {
const pieces = qs.split('=');
query[pieces[0]] = pieces[1];
}
// build the request to sign
const req = new HttpRequest({
hostname,
path: request.uri,
query: query,
body: (request.body && request.body.data) ? Buffer.from(request.body.data, request.body.encoding) : undefined,
method: request.method,
});
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 7
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aws-samples/aws-lambda-function-url-secured
-
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
-
Difficulty 3/5 1-2 days Newbie friendliness 25/100
aws-samples/aws-lambda-function-url-secured#9 · 1 comment ·
All issues in aws-samples/aws-lambda-function-url-secured
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
calcite-components needs triage refactor
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Esri/calcite-design-system#15203 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
danielmiessler/LifeOS#2218 ·