Title: fix(otp): make a correct code single-use and never compare a code without expiry by waleedlatif1 · Pull Request #9789 · simstudioai/sim · GitHub
Open Graph Title: fix(otp): make a correct code single-use and never compare a code without expiry by waleedlatif1 · Pull Request #9789 · simstudioai/sim
X Title: fix(otp): make a correct code single-use and never compare a code without expiry by waleedlatif1 · Pull Request #9789 · simstudioai/sim
Description: Summary Follow-up to #9774 from release-PR review. A correct OTP verification deleted the code unconditionally after the attempt reservation, so concurrent correct submissions could each get a session, and a slow success could delete a newer code requested meanwhile Success now requires a conditional consume: delete only while the stored code is still the one that was compared (Redis Lua / DELETE ... RETURNING). Exactly one correct submission wins; a newer code survives Reservations no longer delete on the last attempt (this was a separate statement on Postgres, which is what let two requests win). A code with every attempt spent stops reserving, and the final wrong guess consumes it Redis reservation checks the remaining lifetime first, so a key left without an expiry by the old increment script is never compared, even on its last attempt Both Lua scripts parse code:attempts strictly, matching the Postgres path; shared SQL expressions for the stored code and attempt count Attempt cap and reserve-before-compare unchanged; safeCompare still does the comparison Type of Change Bug fix (security hardening) Testing route.integration.ts (real Postgres + Redis): new cases for concurrent correct submissions (exactly one 200 + cookie) and a Redis code with no expiry (rejected, key removed); both fail on the previous code. Reporting success without the conditional consume turns the single-use case red on both backends. Existing concurrency/lockout/expiry/authorization cases pass, 3 consecutive runs content-sharing.integration.ts (file-share OTP) passes route.test.ts, bun run lint, bun run check:audits (only a docs artifact that is generated in CI fails locally) Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing (new tests pass the test-audit authoring gate) No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA) 🤖 Generated with Claude Code
Open Graph Description: Summary Follow-up to #9774 from release-PR review. A correct OTP verification deleted the code unconditionally after the attempt reservation, so concurrent correct submissions could each get a ses...
X Description: Summary Follow-up to #9774 from release-PR review. A correct OTP verification deleted the code unconditionally after the attempt reservation, so concurrent correct submissions could each get a ses...
Opengraph URL: https://github.com/simstudioai/sim/pull/9789
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:3e891d6e-8543-c9d2-d3d2-8eea0e1eae00 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | AE6A:E4B58:13A17A:1B105B:6AFB8AD5 |
| html-safe-nonce | 913620eb58a8854f07889b83d516cc8c06bdef8d0e8c0333b90765bc0cf3c980 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRTZBOkU0QjU4OjEzQTE3QToxQjEwNUI6NkFGQjhBRDUiLCJ2aXNpdG9yX2lkIjoiODcyNzgzMjcyNjUxNTQ1MjYyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 51b048454bf2cf0684d2f26c80b67255749293f4d08d6726e1d8169af1f043fa |
| hovercard-subject-tag | pull_request:5206106634 |
| 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/9789/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 Follow-up to #9774 from release-PR review. A correct OTP verification deleted the code unconditionally after the attempt reservation, so concurrent correct submissions could each get a ses... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9694464143465782ecae2a97650b2a2b0708d5c31c74f41ee86da57e315e2735 |
| 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 | 05d967182208691fc7f2e6af52e82fa7fabf6bd5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width