Title: fix(realtime): stop read-only members persisting block positions by waleedlatif1 · Pull Request #6174 · simstudioai/sim · GitHub
Open Graph Title: fix(realtime): stop read-only members persisting block positions by waleedlatif1 · Pull Request #6174 · simstudioai/sim
X Title: fix(realtime): stop read-only members persisting block positions by waleedlatif1 · Pull Request #6174 · simstudioai/sim
Description: Summary The socket operation ACL granted the read role block.updatePosition and blocks.batchUpdatePositions, on the premise (stated in the comment) that they were ephemeral cursor sync. They are not — both are followed by persistWorkflowOperation, which UPDATEs workflow_blocks.positionX/positionY and bumps workflow.updatedAt. So a member holding only read on a workspace could permanently rewrite the on-canvas coordinates of every block of every workflow in it: a write across the read/write boundary, with no UI affordance to undo beyond manual re-layout. The batch form does it for every block in one call and does not even require the commit flag. The premise was wrong twice over: live cursors ride their own cursor-update event (handlers/presence.ts), and the smooth-drag broadcast is the uncommitted position path, which returns before persisting and never consults the role table at all. So read needs no grant — it is now []. Client-side this changes nothing for legitimate users: nodesDraggable and onNodeDrag/onNodeDragStop are already gated on canEdit, so a read-only member never emits these through the UI. Reaching the hole required a hand-crafted socket frame. Type of Change Bug fix (security — privilege escalation / integrity) Testing New handlers/operations.test.ts drives the real handler and the real permission middleware (only the DB and the workspace authorizer are mocked) and asserts on persistWorkflowOperation, since that is what actually writes the row: a read member is refused for both the committed single and the batch form, and a write member still persists both (positive control). A third case pins the no-regression edge: an uncommitted position update from a read member still relays and still does not persist, so tightening the ACL did not turn the ungated smooth-drag broadcast into an error. Existing permissions.test.ts cases that encoded the vulnerable behaviour ("should allow batch-update-positions operation for read role") are inverted, and the blanket case now asserts the read role holds no operation at all. Verified the suite actually catches this: restoring the two grants fails 8 tests, including the two that assert the database write is blocked. 273 tests pass; tsc, lint, and all 12 CI audit scripts green locally. Notes for review Considered and deliberately not done: gating persistWorkflowOperation itself on permissionSatisfies(role, 'write') as belt-and-braces. Every persist call in operations.ts is already downstream of the single permission gate (the only bypass, the uncommitted position path, returns before persisting), and subblocks.ts / variables.ts carry their own gates — so the runtime check would be pure redundancy, at the cost of an extra failure mode that surfaces to clients as a retryable persistence error. The invariant is instead pinned by the test asserting read grants nothing. Residual, out of scope and lower severity: a read-only member can still broadcast uncommitted position frames (phantom moves other collaborators see, which nothing persists and a refresh clears). That path is intentionally ungated for drag latency. Happy to close it in a follow-up if you'd like — it needs a synchronous check on the hot path rather than the existing async one. 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 The socket operation ACL granted the read role block.updatePosition and blocks.batchUpdatePositions, on the premise (stated in the comment) that they were ephemeral cursor sync. They are n...
X Description: Summary The socket operation ACL granted the read role block.updatePosition and blocks.batchUpdatePositions, on the premise (stated in the comment) that they were ephemeral cursor sync. They are n...
Opengraph URL: https://github.com/simstudioai/sim/pull/6174
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:f772abd4-16bc-6a4a-a8fd-662a89d90b9c |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D3E6:283A10:57DEEA:7D5F9F:6AFB4313 |
| html-safe-nonce | 726b093b64671acb666915187fcd304da0a166264350816710d941a8fc653cb3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEM0U2OjI4M0ExMDo1N0RFRUE6N0Q1RjlGOjZBRkI0MzEzIiwidmlzaXRvcl9pZCI6IjM5OTUwODA2MTIzMzAwMjk4NDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 01ce93bdf8d69a9935f0bc0bf0c6cf1536e397653bc1a393983832f775b3a4ab |
| hovercard-subject-tag | pull_request:4186061157 |
| 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/6174/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 The socket operation ACL granted the read role block.updatePosition and blocks.batchUpdatePositions, on the premise (stated in the comment) that they were ephemeral cursor sync. They are n... |
| 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