Repository navigation
fix(security): bind the CastingWords webhook to our stored order, keep the API key away from Mux (sec-167) - #44
Merged
Conversation
skill-api returns the bare partner-uploads object URL as publicUrl, and the Sanity videoResource webhook hands it to Mux and CastingWords, which fetched it without credentials because the prefix was publicly readable. presignUploadGet signs a short-lived GET for an object in the app's upload bucket and folder at the moment of the call: inside createMuxAsset (6h) and the CastingWords order (24h). originalMediaUrl stays unsigned and Mux errors are redacted. Same change as skillrecordings/products#1921.
…p the API key away from Mux (sec-167) Same change as skillrecordings/products#1922: a parameterized lookup that only matches the video resource holding the exact order and audiofile pair we stored when ordering (404 otherwise, before any CastingWords call or write), and captions handed to Mux as a presigned GET on our own S3 object instead of the CastingWords SRT URL carrying our API key.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…captions (sec-167 review)
This branch was successfully deployed
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.
Stacked on #43 (base
worker/sec165-scriptkit); merge #43 first. Same change as skillrecordings/products#1922.Why (sec-20261125-167, high)
castingwordsWebhookReceiverinskill-lessonserves/api/webhooks/castingwordson scriptkit. It authenticates nothing, andwriteTranscriptToVideoResource:*[_type == "videoResource" && castingwords.orderId == "${order}"][0]from the postedorder, so a crafted value selects any videoResource, which then gets patched.audiofileisn't tied to that order, so a forged call can write video A's transcript and captions onto video B.createTrack({url: srtUrl}), wheresrtUrlis the CastingWords SRT URL withapi_key=<CASTINGWORDS_API_TOKEN>in its query. Every caption track created this way stored our key on Mux's side.What
*[_type == "videoResource" && castingwords.orderId == $order && castingwords.audioFileId in [$audiofile, $audiofileNumber]][0], with parameters. Only the resource holding the exact pair we stored from our own order response (updateVideoResourceWithTranscriptOrderId) matches.storeCaptionForMuxputs it atpartner-uploads/captions/<videoResourceId>/<audiofile>.srtwith the upload key. That key has PutObject, and GetObject since sec-165. Mux gets a 6h presigned GET for it. If the bucket isn't configured, no track is created and a warning is logged, rather than falling back to the keyed URL. Mux errors are redacted.getSRTTextnow returns{srt}only, so the keyed URL never leaves the request.audiofileis URL-encoded in both CastingWords fetches.Tests
lib/castingwords-webhook.test.ts(4):orderandaudiofileas parameters, and an injection string isn't interpolated.castingwords.comand no token.All 4 fail on #43's head. skill-lesson
lib/is 27/27. tsc shows no errors in the changed files. prettier is clean.After deploy
The secret cell rotates
CASTINGWORDS_API_TOKENand sets the new value on epic-web, total-typescript-turbo and scriptkit. Rotating before this ships would just leak the new key into the next caption track.