fix: add diagnostic logging for Hawk query string ordering#262
Merged
fix: add diagnostic logging for Hawk query string ordering#262
Conversation
Log the reconstructed query string parameter order and full server URL on MAC mismatch to diagnose storage/prefs 401 failures. Hypothesis: API Gateway REST API v1 reorders query params alphabetically in the event dict, causing Hawk MAC verification to fail when the client's original param order differs (e.g. newer,full,limit → full,limit,newer).
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
Diff for stage: DefaultStageDiff for stack: GitHubOidcStack - 0 to add, 1 to update, 0 to destroy 🟡DetailsResources
[~] Custom::AWSCDKOpenIdConnectProvider GitHubOidcProvider7EBF861F
├─ [~] CodeHash
│ ├─ [-] 62fa02efcaa700e1c247e1d3cc2aa0cd07a0808a9a3e3d2230e51f57a02233fb
│ └─ [+] d75c48c9f82cde63e9bf414df335e84e8ac24f11eb34889be255b702aec71e50
└─ [~] RejectUnauthorized
[~] AWS::Lambda::Function CustomAWSCDKOpenIdConnectProviderCustomResourceProviderHandlerF2C543E0
├─ [~] Code
│ └─ [~] .S3Key:
│ ├─ [-] 62fa02efcaa700e1c247e1d3cc2aa0cd07a0808a9a3e3d2230e51f57a02233fb.zip
│ └─ [+] d75c48c9f82cde63e9bf414df335e84e8ac24f11eb34889be255b702aec71e50.zip
└─ [~] Metadata
└─ [~] .aws:asset:path:
├─ [-] asset.62fa02efcaa700e1c247e1d3cc2aa0cd07a0808a9a3e3d2230e51f57a02233fb
└─ [+] asset.d75c48c9f82cde63e9bf414df335e84e8ac24f11eb34889be255b702aec71e50
Diff for stack: Service-prod - 0 to add, 0 to update, 0 to destroy ✅DetailsResources
[~] AWS::Lambda::Function AuthApiHandlerED50ACFA
├─ [~] Code
│ └─ [~] .S3Key:
│ ├─ [-] ecd5fbf25a5e0425e7c7ddd001835de68f1cb7b7e2943adf0d7ea190efe9dbc9.zip
│ └─ [+] 3f1fc4e35179c6e033b76937a0d25db8f3170704e4ff47ece2f2d3603615ba03.zip
└─ [~] Metadata
└─ [~] .aws:asset:path:
├─ [-] asset.ecd5fbf25a5e0425e7c7ddd001835de68f1cb7b7e2943adf0d7ea190efe9dbc9
└─ [+] asset.3f1fc4e35179c6e033b76937a0d25db8f3170704e4ff47ece2f2d3603615ba03
[~] AWS::Lambda::Function TokenApiHandler2E66DB25
├─ [~] Code
│ └─ [~] .S3Key:
│ ├─ [-] ecd5fbf25a5e0425e7c7ddd001835de68f1cb7b7e2943adf0d7ea190efe9dbc9.zip
│ └─ [+] 3f1fc4e35179c6e033b76937a0d25db8f3170704e4ff47ece2f2d3603615ba03.zip
└─ [~] Metadata
└─ [~] .aws:asset:path:
├─ [-] asset.ecd5fbf25a5e0425e7c7ddd001835de68f1cb7b7e2943adf0d7ea190efe9dbc9
└─ [+] asset.3f1fc4e35179c6e033b76937a0d25db8f3170704e4ff47ece2f2d3603615ba03
[~] AWS::Lambda::Function ProfileApiHandler9B65A298
├─ [~] Code
│ └─ [~] .S3Key:
│ ├─ [-] ecd5fbf25a5e0425e7c7ddd001835de68f1cb7b7e2943adf0d7ea190efe9dbc9.zip
│ └─ [+] 3f1fc4e35179c6e033b76937a0d25db8f3170704e4ff47ece2f2d3603615ba03.zip
└─ [~] Metadata
└─ [~] .aws:asset:path:
├─ [-] asset.ecd5fbf25a5e0425e7c7ddd001835de68f1cb7b7e2943adf0d7ea190efe9dbc9
└─ [+] asset.3f1fc4e35179c6e033b76937a0d25db8f3170704e4ff47ece2f2d3603615ba03
[~] AWS::Lambda::Function ApiHandler5E7490E8
├─ [~] Code
│ └─ [~] .S3Key:
│ ├─ [-] ecd5fbf25a5e0425e7c7ddd001835de68f1cb7b7e2943adf0d7ea190efe9dbc9.zip
│ └─ [+] 3f1fc4e35179c6e033b76937a0d25db8f3170704e4ff47ece2f2d3603615ba03.zip
└─ [~] Metadata
└─ [~] .aws:asset:path:
├─ [-] asset.ecd5fbf25a5e0425e7c7ddd001835de68f1cb7b7e2943adf0d7ea190efe9dbc9
└─ [+] asset.3f1fc4e35179c6e033b76937a0d25db8f3170704e4ff47ece2f2d3603615ba03
No Changes for stack: Monitoring-prod ✅ Generated for commit e1bcf93 at 2026-03-02T23:04:50.990Z |
layertwo
added a commit
that referenced
this pull request
Mar 3, 2026
API Gateway REST API v1 alphabetizes query parameters in the event dict, breaking Hawk MAC verification when the client's original parameter order differs (e.g. newer,full,limit → full,limit,newer). Fix: before calling mohawk.Receiver, pre-compute the Hawk MAC for each permutation of query parameters to find the client's original ordering. Only call mohawk once with the correct URL, preserving nonce replay protection. Removes diagnostic logging from PR #262.
4 tasks
layertwo
added a commit
that referenced
this pull request
Mar 3, 2026
API Gateway REST API v1 alphabetizes query parameters in the event dict, breaking Hawk MAC verification when the client's original parameter order differs (e.g. newer,full,limit → full,limit,newer). Fix: before calling mohawk.Receiver, pre-compute the Hawk MAC for each permutation of query parameters to find the client's original ordering. Only call mohawk once with the correct URL, preserving nonce replay protection. Removes diagnostic logging from PR #262.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GET /storage/prefs?newer=...&full=1&limit=1000Context
Storage sync fails with 401 on the
prefscollection but succeeds forclients,meta/global,crypto/keys, etc. All use the same Hawk token.Hypothesis:
extract_hawk_request_paramsreconstructs the query string fromevent.query_string_parameters(a dict), which loses the original parameter ordering from the HTTP request. API Gateway REST API v1 may serialize dict keys alphabetically:clients?full=1&limit=1000full,limitfull,limitprefs?newer=...&full=1&limit=1000newer,full,limitfull,limit,newerWhat to look for in CloudWatch
"Hawk query string reconstruction"— checkparam_key_orderon prefs requests"HAWK MAC mismatch"— confirms which URL mohawk tried to verifyTest plan
param_key_orderrawQueryString, or alternative)