Repository navigation
fix(security): bind the CastingWords webhook to our stored order, keep the API key away from Mux (sec-167) - #1922
Merged
Merged
Conversation
…ec-165) The upload flow strips the signature off the presigned PUT and stores the bare partner-uploads object URL, which Mux, Deepgram, CastingWords and an external deepgram-wrangler worker then fetched without credentials. That only worked because the prefix was publicly readable. presignUploadGet (skill-lesson) signs a short-lived GET for an object in the app's upload bucket and folder at the moment of the service call: inside createMuxAsset, the CastingWords order (24h, a human service), and epic-web's Deepgram provider. originalMediaUrl stays unsigned; replies and errors are redacted, so no signed URL is stored or returned in step output. epic-web's tip flow ordered transcripts through deepgram-wrangler on an account we cannot audit, with the URL in its query string. It now orders Deepgram directly like process-video-resource, and our Deepgram webhook emits the transcript-created event the tip flow waits for.
…gned (sec-166) /api/webhooks/deepgram/transcript trusted the videoResourceId query and wrote any posted transcript to Sanity, set the video ready, and emitted SRT events that put captions on the Mux asset. With sec-165 it also emits the tip transcript event, so a forged call could drive the tip flow too. The provider now signs the callback URL: an HMAC-SHA256 (NEXTAUTH_SECRET) over a label, the videoResourceId and a 24h expiry, the same shape as course-builder's transcription callback (sec-059). The webhook refuses a missing, forged, expired or other-resource signature with 401 before it reads anything. The existing skip-if-transcript-exists check keeps a valid callback one-shot.
…p the API key away from Mux (sec-167) castingwordsWebhookReceiver is unauthenticated. writeTranscriptToVideoResource interpolated the posted order into a GROQ query, so a crafted value selected any videoResource, and the posted audiofile was not tied to that order, so a forged call could write one video's transcript and captions onto another. It also handed Mux the CastingWords SRT URL, whose query carries our API key, as the caption track source. The lookup is now parameterized and matches only the video resource holding the exact order and audiofile pair stored from our own order response; an unmatched pair returns 404 before any CastingWords call or write. The SRT is fetched server-side, stored under the upload folder, and Mux gets a 6h presigned GET for it. getSRTText no longer returns the keyed URL.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
3 Skipped Deployments
|
…ilt it as a route)
…captions (sec-167 review)
shitratgit Bot
added a commit
to skillrecordings/scriptkit
that referenced
this pull request
Nov 26, 2026
…p the API key away from Mux (sec-167) (#44) * fix(security): sign upload URLs for Mux and CastingWords (sec-165) 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. * fix(security): bind the CastingWords webhook to our stored order, keep 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. * fix(skill-lesson): refuse a CastingWords error page as transcript or captions (sec-167 review) --------- Co-authored-by: shitratgit[bot] <286405550+shitratgit[bot]@users.noreply.github.com>
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 #1921 (base
worker/sec165-products); merge #1921 first.Why (sec-20261125-167, high)
castingwordsWebhookReceiverinskill-lessonserves/api/webhooks/castingwordson epic-web, epic-react and total-typescript. 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 #1921's head. skill-lesson
lib/is 27/27. tsc shows no errors in the changed files (theconvertkit.tserrors already exist). prettier is clean.After deploy
The secret cell rotates
CASTINGWORDS_API_TOKENand sets the new value on epic-web, total-typescript-turbo and scriptkit. scriptkit gets the same change in its own repo. Rotating before this ships would just leak the new key into the next caption track.