fix: apply signature-verification middleware to POST /api/tokens [AIS-297]#11118
Draft
ryunsong-contentful wants to merge 1 commit into
Draft
fix: apply signature-verification middleware to POST /api/tokens [AIS-297]#11118ryunsong-contentful wants to merge 1 commit into
ryunsong-contentful wants to merge 1 commit into
Conversation
Wiz Scan Summary
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension. |
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.
AIS-297 / AIS-299
What's happening here
The Contentful request-signature-verification middleware is meant to be mounted on
/api/messages,/api/spaces/*,/api/events, and/api/tokens:The last entry is
'api/tokens'— missing the leading/. Express path-matching requires an exact match against the route path ('/api/tokens'), so this entry silently never matched anything.POST /api/tokens(wired up a few lines below viaapp.post('/api/tokens', authToken.post)) has been running with no signature verification at all — any caller could hit it without a valid Contentful app signature.This closes AIS-297/AIS-299 (duplicate tickets for the same finding, from the Cypress SAST sweep).
Fix
One-character fix:
'api/tokens'→'/api/tokens'. No other route in the array had this typo (checked/api/messages,/api/spaces/*,/api/events— all correctly prefixed already).Test plan
app.ts's route-to-middleware wiring (the app's tests are unit tests against individual controllers/middleware in isolation — there's nosupertest-style HTTP integration test harness here), so I'm not introducing one for a one-line fix; flagging that as a gap rather than pretending coverage existsPOST /api/tokenswithout a valid Contentful signature now returns the same rejection the other protected routes already returnPOST /api/tokenswith a valid signature still succeeds (no regression to the legitimate OAuth token flow)Generated with Claude Code