Title: fix(files): authorize presigned upload contexts per type by waleedlatif1 · Pull Request #6175 · simstudioai/sim · GitHub
Open Graph Title: fix(files): authorize presigned upload contexts per type by waleedlatif1 · Pull Request #6175 · simstudioai/sim
X Title: fix(files): authorize presigned upload contexts per type by waleedlatif1 · Pull Request #6175 · simstudioai/sim
Description: Summary POST /api/files/presigned/batch validated its type param against the shared 7-value upload enum but only authorized knowledge-base, so any authenticated user could mint an S3 presigned PUT into workspace-logos/, profile-pictures/, execution/, mothership/, chat/ and copilot/ — objects then served unauthenticated from the app origin with a one-year public cache Batch presign now accepts knowledge-base only (its sole client and its sole authorizable context) and always requires a workspaceId the caller has write/admin on before any URL is minted POST /api/files/presigned had the same class of gap for chat: no authorization predicate, no content-type restriction, no client. Dropped it — every remaining context there has a per-context predicate (copilot self-scoped + type-restricted, profile-pictures self-scoped + image-only, mothership/execution workspace write, workspace-logos workspace admin, knowledge-base workspace write) Both allowlists moved into lib/api/contracts/storage-transfer.ts so the enum that is enforced and the one that is documented can't drift apart again — that drift was the root cause Type of Change Bug fix (security) Testing New app/api/files/presigned/batch/route.test.ts: 401 unauthenticated, 400 for each of the six refused contexts with no URL minted, 400 missing workspaceId, 403 for read/no access, authz enforced ahead of the local-storage fallback, file-type rejection before minting, and the authorized happy path Added a regression test on the single route asserting type=chat is rejected without minting Verified both suites go red when the fix is reverted (6 batch failures, 1 single-route failure) app/api/files + lib/uploads: 449 tests passing; tsc -p apps/sim clean; bun run check:api-validation passed Not included Per-user upload quota / billing attribution for presign issuance. With authorization restored, only workspace members with write access can mint these URLs, so metering is a separate billing feature rather than part of this fix. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Open Graph Description: Summary POST /api/files/presigned/batch validated its type param against the shared 7-value upload enum but only authorized knowledge-base, so any authenticated user could mint an S3 presigned PUT...
X Description: Summary POST /api/files/presigned/batch validated its type param against the shared 7-value upload enum but only authorized knowledge-base, so any authenticated user could mint an S3 presigned PUT...
Opengraph URL: https://github.com/simstudioai/sim/pull/6175
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:2e192fa7-0ba3-7b67-2555-94e7b9152278 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DCF2:29C55F:717C09:9C115C:6AFB4328 |
| html-safe-nonce | 5d6e97a2f5abe3874e9cc8aabb0b9d772aac58f373956a032098965a49e3720d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0YyOjI5QzU1Rjo3MTdDMDk6OUMxMTVDOjZBRkI0MzI4IiwidmlzaXRvcl9pZCI6IjUyNTY4MTg5OTYwMzE0NzI0MjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ed1aaa41f6b8c1d4f2b6e83da79c756603f3ef076bba1d7d2282de87c1eba08c |
| hovercard-subject-tag | pull_request:4186082796 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6175/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary POST /api/files/presigned/batch validated its type param against the shared 7-value upload enum but only authorized knowledge-base, so any authenticated user could mint an S3 presigned PUT... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | d849b928f455c800985398e7f1b659425adb312a5fa14fba5d9a14e62e9fe5dd |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a6c2f87cbcb6414452377b4967858ed6a66f1109 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width