René's URL Explorer Experiment


Title: fix(otp): reserve a verification attempt atomically before comparing the code by waleedlatif1 · Pull Request #9774 · simstudioai/sim · GitHub

Open Graph Title: fix(otp): reserve a verification attempt atomically before comparing the code by waleedlatif1 · Pull Request #9774 · simstudioai/sim

X Title: fix(otp): reserve a verification attempt atomically before comparing the code by waleedlatif1 · Pull Request #9774 · simstudioai/sim

Description: Summary Chat and public file OTP verify read the attempt count, compared the guess, then incremented. Concurrent submissions all passed the limit check on the same stale count, so every in-flight guess got compared and the 5-attempt limit didn't hold under concurrency New reserveOTPAttempt atomically spends one attempt and returns the stored code; callers compare only after reserving, so at most MAX_OTP_ATTEMPTS guesses are ever checked against a code regardless of concurrency Redis: Lua script (replaces the increment script), keeps the TTL, deletes the key on the last attempt Postgres: one conditional UPDATE ... RETURNING (row lock + re-check replaces the optimistic retry loop); attempt parse uses a regex substring so other verification rows can never fail a cast Chat verify now uses safeCompare like the file path Removes incrementOTPAttempts and the stale-read lockout branch; user-facing responses unchanged (4 wrong → invalid, 5th wrong → 429, correct on 5th still works) No PUT rate limiter added: with the atomic reservation, guesses per code are capped at 5 and codes issued are already capped by the POST email/resource limits, so a verify throttle adds failure modes without tightening the bound Type of Change Bug fix (security) Testing New app/api/chat/[identifier]/otp/route.integration.ts drives the real PUT handler against real Postgres and Redis Red on pre-fix code: 30 concurrent wrong guesses got 30 comparisons on Postgres and 10 on Redis; green after (exactly 5, 1 lockout, correct code then rejected) Mutation-checked each guard (lock-before-compare on both backends, dropped expiry guard, dropped TTL); each turns its test red content-sharing.integration.ts (file share OTP + policy-change race) passes with the spy moved to the new primitive route.test.ts updated; removed two mock-restating brute-force tests and a DB-expiry test now owned by the integration suite bun run lint, check:test-patterns, check:comment-hygiene, check:utils, check:boundaries, check:source-conventions; type-check and full audits in CI 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 Chat and public file OTP verify read the attempt count, compared the guess, then incremented. Concurrent submissions all passed the limit check on the same stale count, so every in-flight ...

X Description: Summary Chat and public file OTP verify read the attempt count, compared the guess, then incremented. Concurrent submissions all passed the limit check on the same stale count, so every in-flight ...

Opengraph URL: https://github.com/simstudioai/sim/pull/9774

X: @github

direct link

Domain: github.com

react-profiling0
react-import-mapreact,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-controllerpull_requests
route-actionfiles
fetch-noncev2:21acd84a-700f-854e-4006-90887cf94078
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idB1C4:BD772:1B46314:250ABEC:6AFB90C3
html-safe-nonce95ee40cfa82a8d1f9c5f5b37b2cc52023fa740feb49eb196f29a586f4bc6bd67
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUM0OkJENzcyOjFCNDYzMTQ6MjUwQUJFQzo2QUZCOTBDMyIsInZpc2l0b3JfaWQiOiI5MDM1MjY1NTQwNjcwMzI5MDI3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac86c93262ad436c1d078b0bfcf5581cea27f6ce56dea253a7d6adffe9285a24d5
hovercard-subject-tagpull_request:5205314367
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/9774/files
twitter:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/40672544?s=400&v=4
og:image:altSummary Chat and public file OTP verify read the attempt count, compared the guess, then incremented. Concurrent submissions all passed the limit check on the same stale count, so every in-flight ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4f01efe06174a5ba6342fd58e42d02295e0675bedbb465d6bef2dbaec8e46556
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/simstudioai/sim git https://github.com/simstudioai/sim.git
octolytics-dimension-user_id199344406
octolytics-dimension-user_loginsimstudioai
octolytics-dimension-repository_id912559512
octolytics-dimension-repository_nwosimstudioai/sim
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id912559512
octolytics-dimension-repository_network_root_nwosimstudioai/sim
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasea52db8866b6543b4e83730cd6a6b1360f1a9e4dc
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/9774/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F9774%2Ffiles
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F9774%2Ffiles
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=simstudioai%2Fsim
Reloadhttps://github.com/simstudioai/sim/pull/9774/files
Reloadhttps://github.com/simstudioai/sim/pull/9774/files
Reloadhttps://github.com/simstudioai/sim/pull/9774/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests198 (198)https://github.com/simstudioai/sim/pulls
Actionshttps://github.com/simstudioai/sim/actions
Projectshttps://github.com/simstudioai/sim/projects
Security and qualityhttps://github.com/simstudioai/sim/security
Insightshttps://github.com/simstudioai/sim/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fsimstudioai%2Fsim%2Fissues%2Fnew%2Fchoose
waleedlatif1https://github.com/waleedlatif1
staginghttps://github.com/simstudioai/sim/tree/staging
fix/otp-verify-atomic-attemptshttps://github.com/simstudioai/sim/tree/fix/otp-verify-atomic-attempts
Conversation 24 https://github.com/simstudioai/sim/pull/9774
Commits 4 https://github.com/simstudioai/sim/pull/9774/commits
Checks 81 https://github.com/simstudioai/sim/pull/9774/checks
Files changed https://github.com/simstudioai/sim/pull/9774/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9774/files
fix(otp): reserve a verification attempt atomically before comparing the code https://github.com/simstudioai/sim/pull/9774/files#top
Show all changes 4 commits https://github.com/simstudioai/sim/pull/9774/files
5daef70 fix(otp): reserve a verification attempt atomically before comparing … waleedlatif1 Nov 7, 2026 https://github.com/simstudioai/sim/pull/9774/commits/5daef703ae7533e4d80a4ae7981e183a473eaa0e
9615cb6 improvement(otp): centralize compare-and-consume in verifyOTP, tighte… waleedlatif1 Nov 7, 2026 https://github.com/simstudioai/sim/pull/9774/commits/9615cb65907d26b349539935104a8d479ccb2ee7
5c7a2ba fix(otp): keep sub-second code lifetimes and drop unused deleteOTP ex… waleedlatif1 Nov 7, 2026 https://github.com/simstudioai/sim/pull/9774/commits/5c7a2badebf9795884970b174683b96a3402f403
5a003bb test(otp): prove rejected verify requests never spend the code agains… waleedlatif1 Nov 7, 2026 https://github.com/simstudioai/sim/pull/9774/commits/5a003bba90b367215bf12aa49beb6611fedf389f
Clear filters https://github.com/simstudioai/sim/pull/9774/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9774/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9774/files
route.integration.ts https://github.com/simstudioai/sim/pull/9774/files#diff-c22fe4596b21f2eda0fb0adcced972aeb84adedb03cf168e0b746d2cc2648db5
route.test.ts https://github.com/simstudioai/sim/pull/9774/files#diff-426f0cc11fcb02d3b9ab0d35eaa6decce992f6cd5242e6d19a74df4a2029cf79
route.ts https://github.com/simstudioai/sim/pull/9774/files#diff-a13d9967f4a5ea9e418cd26f50714ea88964dd7a294e6781327e9a57fc4a5c36
otp.ts https://github.com/simstudioai/sim/pull/9774/files#diff-01e8b7bcdb38e55e7190dee29cc6b722cdb479541a2cc02ce34139f55de01270
content-sharing.integration.ts https://github.com/simstudioai/sim/pull/9774/files#diff-246a1d9cc5d6365f46fac496407977a11971d39e827252e64b7f475b020aa4fa
credentials.ts https://github.com/simstudioai/sim/pull/9774/files#diff-4dd76c8ca98cf5952e6a9e55e619898764a7eb3e2e059eb003301ecc865fe62e
apps/sim/app/api/chat/[identifier]/otp/route.integration.tshttps://github.com/simstudioai/sim/pull/9774/files#diff-c22fe4596b21f2eda0fb0adcced972aeb84adedb03cf168e0b746d2cc2648db5
View file https://github.com/simstudioai/sim/blob/5a003bba90b367215bf12aa49beb6611fedf389f/apps/sim/app/api/chat/%5Bidentifier%5D/otp/route.integration.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9774/{{ revealButtonHref }}
Please reload this pagehttps://github.com/simstudioai/sim/pull/9774/files
apps/sim/app/api/chat/[identifier]/otp/route.test.tshttps://github.com/simstudioai/sim/pull/9774/files#diff-426f0cc11fcb02d3b9ab0d35eaa6decce992f6cd5242e6d19a74df4a2029cf79
View file https://github.com/simstudioai/sim/blob/5a003bba90b367215bf12aa49beb6611fedf389f/apps/sim/app/api/chat/%5Bidentifier%5D/otp/route.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/9774/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/9774/files#diff-426f0cc11fcb02d3b9ab0d35eaa6decce992f6cd5242e6d19a74df4a2029cf79
https://github.com/simstudioai/sim/pull/9774/files#diff-426f0cc11fcb02d3b9ab0d35eaa6decce992f6cd5242e6d19a74df4a2029cf79
https://github.com/simstudioai/sim/pull/9774/files#diff-426f0cc11fcb02d3b9ab0d35eaa6decce992f6cd5242e6d19a74df4a2029cf79
https://github.com/simstudioai/sim/pull/9774/files#diff-426f0cc11fcb02d3b9ab0d35eaa6decce992f6cd5242e6d19a74df4a2029cf79
https://github.com/simstudioai/sim/pull/9774/files#diff-426f0cc11fcb02d3b9ab0d35eaa6decce992f6cd5242e6d19a74df4a2029cf79
https://github.com/simstudioai/sim/pull/9774/files#diff-426f0cc11fcb02d3b9ab0d35eaa6decce992f6cd5242e6d19a74df4a2029cf79
https://github.com/simstudioai/sim/pull/9774/files#diff-426f0cc11fcb02d3b9ab0d35eaa6decce992f6cd5242e6d19a74df4a2029cf79
https://github.com/simstudioai/sim/pull/9774/files#diff-426f0cc11fcb02d3b9ab0d35eaa6decce992f6cd5242e6d19a74df4a2029cf79
https://github.com/simstudioai/sim/pull/9774/files#diff-426f0cc11fcb02d3b9ab0d35eaa6decce992f6cd5242e6d19a74df4a2029cf79
Please reload this pagehttps://github.com/simstudioai/sim/pull/9774/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/9774/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.