Skip to content

fix(security): sign upload URLs for Mux and CastingWords (sec-165) - #43

Merged
shitratgit[bot] merged 1 commit into
mainfrom
worker/sec165-scriptkit
Nov 26, 2026
Merged

shitratgit[bot] merged 1 commit into
mainfrom
worker/sec165-scriptkit

Conversation

@shitratgit

@shitratgit shitratgit Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Why

skill-api's getSignedUrlForVideoFile, and apps/scriptkit/src/pages/api/aws/sign-s3.ts, return publicUrl: signedUrl.split('?').shift(), the bare object URL in partner-uploads, and Sanity stores it as originalMediaUrl. The Sanity videoResource webhook (/api/webhooks/sanity/videoResource/created into skill-lesson's sanityVideoResourceWebhook) 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:GetObject on partner-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.ts and castingwords.ts are byte-identical to products' main.

What

  • presignUploadGet(url), new in packages/skill-lesson/lib/upload-media-url.ts:
    • Signs an unsigned object URL in the app's AWS_VIDEO_UPLOAD_BUCKET under its upload folder.
    • Any other URL passes through unchanged.
    • Refuses an already signed URL, plain http, credentials in the URL, .., another bucket or another folder.
    • Warns when an upload-bucket S3 URL goes out unsigned.
  • createMuxAsset signs (6h TTL) at the Video.Assets.create call, and redacts Mux errors.
  • CastingWords orderTranscript signs with a 24h TTL, because it's a human service and may fetch later.
  • originalMediaUrl stays unsigned in Sanity: no migration, no credential stored.
  • Test config: skill-lesson's jest config maps uuid to 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) and lib/upload-presigned-callers.test.ts (4). 23/23 pass.
  • Red on main: with main's mux.ts and castingwords.ts, "hands Mux a presigned GET" and "orders with a presigned GET valid for a day" fail.
  • skill-lesson tsc --noEmit: none of the existing errors are in the changed files.
  • prettier is clean.

Note: the lockfile is v9, while packageManager says pnpm 8.9.0. pnpm 9 installs it as-is. This PR doesn't touch the lockfile.

Deploy

  1. Bastion reviews. Switchboard approves at a pinned head.
  2. Merge and deploy scriptkit. Proof: a scriptkit upload reaches Mux, or this PR's tests if no editor uploads.
  3. Once this, products#1921 and course-builder#1280 have shipped and one real upload has gone through on a products site, the secret cell closes public read on partner-uploads/*.

Rollback: revert this PR. Public read stays open until step 3.

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.
@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
scriptkit Ready Ready Preview Nov 26, 2026 4:53am UTC

@shitratgit
shitratgit Bot marked this pull request as ready for review November 26, 2026 05:42
@shitratgit
shitratgit Bot merged commit d748ec5 into main Nov 26, 2026
4 of 5 checks passed
shitratgit Bot added a commit that referenced this pull request Nov 26, 2026

This branch was successfully deployed

1 active deployment
Preview — 72cf73b5 Deployed Nov 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants