René's URL Explorer Experiment


Title: fix(security): meter and throttle the deployed-chat TTS relay by waleedlatif1 · Pull Request #6212 · simstudioai/sim · GitHub

Open Graph Title: fix(security): meter and throttle the deployed-chat TTS relay by waleedlatif1 · Pull Request #6212 · simstudioai/sim

X Title: fix(security): meter and throttle the deployed-chat TTS relay by waleedlatif1 · Pull Request #6212 · simstudioai/sim

Description: Summary POST /api/proxy/tts/stream treated "a live public chat exists" as authorization to spend the platform ElevenLabs key. A public chat id is handed to every visitor, so any anonymous caller could synthesize speech with no length cap, no rate limit and no usage accounting. Resolve the chat's workspace and bill synthesized characters to that payer via a new voice-output usage source, so spend is attributable and counts against the plan's usage limit (402 once exceeded). Throttle per IP before any database work, and per chat afterwards — bounding both one caller hammering many chats and many callers hammering one chat. Cap text at 2000 characters, cap the request body at 16 KB, and allowlist voiceId/modelId so the caller can no longer pick an unbounded charge, a premium/cloned voice, or the billing model. Drop Access-Control-Allow-Origin: *, which let any third-party page read the audio. Deployed chat and the Office embed are same-origin. Extract the chat auth + payer lookup that TTS and STT had both grown into resolveDeployedChatCaller, and filter chat.archivedAt there — an archived chat could previously still authorize spend against its former owner's workspace, on both routes. Notes for review Pricing: TTS_COST_PER_1K_CHARS = 0.05 is ElevenLabs' published Flash/Turbo API rate. Please confirm against our actual contract — if we're on a negotiated rate this constant needs updating. It's the vendor cost; getCostMultiplier() applies markup, matching the STT precedent. The per-IP bucket only filters naive floods — getClientIp trusts the leftmost X-Forwarded-For, which the caller controls. The per-chat bucket is the load-bearing control. Metering writes one usage_log row per synthesized sentence, so a long answer produces ~10-30 rows. Accurate, but noisier than STT's one-row-per-session. The residual risk after this change is that an attacker burns a specific customer's usage budget rather than the platform's. A per-chat period character budget would bound that; not included here. The chat.archivedAt filter is not covered by a test — the db chain mock does not evaluate WHERE clauses, so an assertion there could not fail. Type of Change Bug fix Testing 13 route tests covering the length cap, voice/model allowlists, body cap, both rate-limit buckets, workspace attribution, the usage-limit 402, and unique sourceReference per call. Each guard was verified to fail when its fix is reverted. Full sweep: 811 tests across billing/contracts/chat/rate-limiter, typecheck clean on apps/sim and packages/db, check:migrations clean, no drizzle schema drift. Not live-tested against ElevenLabs. 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/proxy/tts/stream treated "a live public chat exists" as authorization to spend the platform ElevenLabs key. A public chat id is handed to every visitor, so any anonymou...

X Description: Summary POST /api/proxy/tts/stream treated "a live public chat exists" as authorization to spend the platform ElevenLabs key. A public chat id is handed to every visitor, so any ...

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

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:f0e56173-8e18-157d-6e58-0f009123f20e
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id9E50:22FE8E:A10703:E45E21:6AFB5360
html-safe-nonceff08e74869148a5a4d7e082239f5d54cd38b89aa7f2b71b5eb1c4b44fc6e9623
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTUwOjIyRkU4RTpBMTA3MDM6RTQ1RTIxOjZBRkI1MzYwIiwidmlzaXRvcl9pZCI6IjM0NTgxOTM2MTk5NzI0Nzc3OTIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac926b53642e5d9c6d21d3d323c147359887e395d94a6f6bb97e6bbf5f118f4273
hovercard-subject-tagpull_request:4196845232
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/6212/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 POST /api/proxy/tts/stream treated "a live public chat exists" as authorization to spend the platform ElevenLabs key. A public chat id is handed to every visitor, so any anonymou...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1
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
releasecbf66c024bb6d10e6955baa7413c54cf13a201bb
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/simstudioai/sim/pull/6212/files#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsimstudioai%2Fsim%2Fpull%2F6212%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%2F6212%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/6212/files
Reloadhttps://github.com/simstudioai/sim/pull/6212/files
Reloadhttps://github.com/simstudioai/sim/pull/6212/files
simstudioaihttps://github.com/simstudioai
simhttps://github.com/simstudioai/sim
Codehttps://github.com/simstudioai/sim
Issues129 (129)https://github.com/simstudioai/sim/issues
Pull requests197 (197)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/tts-proxy-auth-abusehttps://github.com/simstudioai/sim/tree/fix/tts-proxy-auth-abuse
Conversation 21 https://github.com/simstudioai/sim/pull/6212
Commits 6 https://github.com/simstudioai/sim/pull/6212/commits
Checks 27 https://github.com/simstudioai/sim/pull/6212/checks
Files changed https://github.com/simstudioai/sim/pull/6212/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6212/files
fix(security): meter and throttle the deployed-chat TTS relay https://github.com/simstudioai/sim/pull/6212/files#top
Show all changes 6 commits https://github.com/simstudioai/sim/pull/6212/files
12870b9 fix(security): meter and throttle the deployed-chat TTS relay waleedlatif1 Aug 3, 2026 https://github.com/simstudioai/sim/pull/6212/commits/12870b91a1411efeeb3ea6ed5dec2d737ea9ef5f
9d9bf5f fix(security): correct TTS metering, pricing and body cap waleedlatif1 Aug 3, 2026 https://github.com/simstudioai/sim/pull/6212/commits/9d9bf5ff89f0f4b604bba25a5b96ccf90e75d052
e868a5d refactor(chat): share the deployed-chat auth gate across voice routes waleedlatif1 Aug 3, 2026 https://github.com/simstudioai/sim/pull/6212/commits/e868a5d40d4122424b4ff9d837c8ebcf28c7dcd4
93d97f0 fix(security): fail closed when voice-output usage cannot be recorded waleedlatif1 Aug 3, 2026 https://github.com/simstudioai/sim/pull/6212/commits/93d97f01f76f94a26c11f13334aa1a69c2d37903
d1360c5 fix(chat): split long TTS text so the relay cap cannot drop audio waleedlatif1 Aug 3, 2026 https://github.com/simstudioai/sim/pull/6212/commits/d1360c5d2d957cc241d02bb836cc9fc63332731d
2ad92d7 fix(security): release the vendor stream when metering rejects the re… waleedlatif1 Aug 3, 2026 https://github.com/simstudioai/sim/pull/6212/commits/2ad92d793ad6b2dd3165f147911b78b9f982d17b
Clear filters https://github.com/simstudioai/sim/pull/6212/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6212/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6212/files
chat.tsx https://github.com/simstudioai/sim/pull/6212/files#diff-fae318707f9a158c797e4f84f75bff8d0db61f29ba25ca13b69398045f6cd56a
use-audio-streaming.test.ts https://github.com/simstudioai/sim/pull/6212/files#diff-80490b11184df9d6e523dc185acd6a41150a029673d32b4b136302ac2520aedd
use-audio-streaming.ts https://github.com/simstudioai/sim/pull/6212/files#diff-da53156ee5aeb71d76598a82d5d0ed488d192b0e8cd0d18a0d4df2ef79eb4efa
route.test.ts https://github.com/simstudioai/sim/pull/6212/files#diff-33651d1f8893776e08caf6e6c6b323bdf798878e94f8f807e948149f1526d23e
route.ts https://github.com/simstudioai/sim/pull/6212/files#diff-83c079cc46780e0cc09b537eef9203baa421f3cff8e74b6277293997ec3f2051
route.ts https://github.com/simstudioai/sim/pull/6212/files#diff-ccc69fabd0836100fb492649dc1fa5f9cc064e8803d32c5f4f39d79531f08ec2
source-labels.ts https://github.com/simstudioai/sim/pull/6212/files#diff-733aed03e23dc3a1b4d4c2d01c9f791638e6ab0902203c642a9ef0ac61200e3f
tts-stream.ts https://github.com/simstudioai/sim/pull/6212/files#diff-fdc13d345ed0464bdbe259fb3237d805c14a8632702590023a941af668a04a88
user.ts https://github.com/simstudioai/sim/pull/6212/files#diff-095f7a2d1473a6ce47da4b69d1c8ded6cf538a9c9a9f8d2957dc5539d16b827c
usage-log.ts https://github.com/simstudioai/sim/pull/6212/files#diff-61e17bbb06140b8753417feb8b60df7a9170f3216b76d314f14d5210cb9e8431
deployed-chat-caller.ts https://github.com/simstudioai/sim/pull/6212/files#diff-d13fa029bfc1a0f90563f41794f0d5c476201839a5bc49d20094343db5fe132e
route-helpers.ts https://github.com/simstudioai/sim/pull/6212/files#diff-c0645b76bcee0874af772d08c3c6b6078c94b86d2eb26c0370e35b2d26240c18
0281_fixed_madame_web.sql https://github.com/simstudioai/sim/pull/6212/files#diff-dc49bd4964b49db1537842fd40cb48d9a658b164e7c67feffbbcd2de59367ffd
0281_snapshot.json https://github.com/simstudioai/sim/pull/6212/files#diff-ae1c6f33b23acf796feb7a1a9b5a5b85b2dd673bf88826ed87ab9305eac6ac1a
_journal.json https://github.com/simstudioai/sim/pull/6212/files#diff-37150cc65ad16ee6fbc5fa318fc096be7730e16d63eaf863e3df5521b7030649
schema.ts https://github.com/simstudioai/sim/pull/6212/files#diff-9a959e2ce3cb4c86957bbae021d06eae364f7b0cb18964f5873bab53220af928
apps/sim/app/(interfaces)/chat/[identifier]/chat.tsxhttps://github.com/simstudioai/sim/pull/6212/files#diff-fae318707f9a158c797e4f84f75bff8d0db61f29ba25ca13b69398045f6cd56a
View file https://github.com/simstudioai/sim/blob/2ad92d793ad6b2dd3165f147911b78b9f982d17b/apps/sim/app/(interfaces)/chat/%5Bidentifier%5D/chat.tsx
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6212/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6212/files#diff-fae318707f9a158c797e4f84f75bff8d0db61f29ba25ca13b69398045f6cd56a
https://github.com/simstudioai/sim/pull/6212/files#diff-fae318707f9a158c797e4f84f75bff8d0db61f29ba25ca13b69398045f6cd56a
https://github.com/simstudioai/sim/pull/6212/files#diff-fae318707f9a158c797e4f84f75bff8d0db61f29ba25ca13b69398045f6cd56a
https://github.com/simstudioai/sim/pull/6212/files#diff-fae318707f9a158c797e4f84f75bff8d0db61f29ba25ca13b69398045f6cd56a
apps/sim/app/(interfaces)/chat/hooks/use-audio-streaming.test.tshttps://github.com/simstudioai/sim/pull/6212/files#diff-80490b11184df9d6e523dc185acd6a41150a029673d32b4b136302ac2520aedd
View file https://github.com/simstudioai/sim/blob/2ad92d793ad6b2dd3165f147911b78b9f982d17b/apps/sim/app/(interfaces)/chat/hooks/use-audio-streaming.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6212/{{ revealButtonHref }}
apps/sim/app/(interfaces)/chat/hooks/use-audio-streaming.tshttps://github.com/simstudioai/sim/pull/6212/files#diff-da53156ee5aeb71d76598a82d5d0ed488d192b0e8cd0d18a0d4df2ef79eb4efa
View file https://github.com/simstudioai/sim/blob/2ad92d793ad6b2dd3165f147911b78b9f982d17b/apps/sim/app/(interfaces)/chat/hooks/use-audio-streaming.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/simstudioai/sim/pull/6212/{{ revealButtonHref }}
https://github.com/simstudioai/sim/pull/6212/files#diff-da53156ee5aeb71d76598a82d5d0ed488d192b0e8cd0d18a0d4df2ef79eb4efa
https://github.com/simstudioai/sim/pull/6212/files#diff-da53156ee5aeb71d76598a82d5d0ed488d192b0e8cd0d18a0d4df2ef79eb4efa
https://github.com/simstudioai/sim/pull/6212/files#diff-da53156ee5aeb71d76598a82d5d0ed488d192b0e8cd0d18a0d4df2ef79eb4efa
https://github.com/simstudioai/sim/pull/6212/files#diff-da53156ee5aeb71d76598a82d5d0ed488d192b0e8cd0d18a0d4df2ef79eb4efa
https://github.com/simstudioai/sim/pull/6212/files#diff-da53156ee5aeb71d76598a82d5d0ed488d192b0e8cd0d18a0d4df2ef79eb4efa
https://github.com/simstudioai/sim/pull/6212/files#diff-da53156ee5aeb71d76598a82d5d0ed488d192b0e8cd0d18a0d4df2ef79eb4efa
Please reload this pagehttps://github.com/simstudioai/sim/pull/6212/files
Please reload this pagehttps://github.com/simstudioai/sim/pull/6212/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.