Repository navigation
fix(security): sign upload URLs for Mux and CastingWords (sec-165) - #43
Merged
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Why
skill-api'sgetSignedUrlForVideoFile, andapps/scriptkit/src/pages/api/aws/sign-s3.ts, returnpublicUrl: signedUrl.split('?').shift(), the bare object URL inpartner-uploads, and Sanity stores it asoriginalMediaUrl. The Sanity videoResource webhook (/api/webhooks/sanity/videoResource/createdintoskill-lesson'ssanityVideoResourceWebhook) hands that URL to Mux and CastingWords. They fetch it without credentials, which only works because the prefix is publicly readable (sec-165).The prefix is about to stop serving publicly. The upload key already has
s3:GetObjectonpartner-uploads/*. This PR makes both fetchers use a signed GET first.This is the same change as skillrecordings/products#1921. scriptkit's
skill-lesson/lib/mux.tsandcastingwords.tsare byte-identical to products' main.What
presignUploadGet(url), new inpackages/skill-lesson/lib/upload-media-url.ts:AWS_VIDEO_UPLOAD_BUCKETunder its upload folder..., another bucket or another folder.createMuxAssetsigns (6h TTL) at theVideo.Assets.createcall, and redacts Mux errors.orderTranscriptsigns with a 24h TTL, because it's a human service and may fetch later.originalMediaUrlstays unsigned in Sanity: no migration, no credential stored.skill-lesson's jest config mapsuuidto its CommonJS build. The jest 27 node environment otherwise loads uuid's ESM browser build when a test imports@aws-sdk/client-s3.Tests
lib/upload-media-url.test.ts(19, with real offline SigV4) andlib/upload-presigned-callers.test.ts(4). 23/23 pass.mux.tsandcastingwords.ts, "hands Mux a presigned GET" and "orders with a presigned GET valid for a day" fail.skill-lessontsc --noEmit: none of the existing errors are in the changed files.Note: the lockfile is v9, while
packageManagersays pnpm 8.9.0. pnpm 9 installs it as-is. This PR doesn't touch the lockfile.Deploy
partner-uploads/*.Rollback: revert this PR. Public read stays open until step 3.