Commit 7b236fd
committed
fix(security): correct TTS metering, pricing and body cap
Follow-up review of the previous commit found five defects in it:
- Usage rows collided. `usage_log.event_key` is unique and inserts are
conflict-do-nothing, and the key is derived from the entry's stable
fields. With no explicit sourceReference, two synthesis calls of equal
character count in the same workspace produced the same key, so every
repeat length went unbilled — defeating the metering this change is
for. Each call now carries a unique sourceReference.
- Priced at $0.10 per 1k characters, twice the published ElevenLabs
Flash/Turbo rate of $0.05, which would have overcharged customers 2x.
- No body cap, so an anonymous caller could make the route buffer up to
the shared 50 MB default before validation. Now 16 KB, as the STT
sibling does.
- Threshold settlement ran per sentence: several queries and a possible
Stripe call on a realtime path. The workflow execution that produced
the text already settles the payer.
- The per-IP bucket was described as preventing database amplification.
getClientIp trusts the leftmost X-Forwarded-For, so an attacker rotates
past it; the comment now says the per-chat bucket is load-bearing.1 parent 00e2320 commit 7b236fd
2 files changed
Lines changed: 66 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
143 | 151 | | |
144 | 152 | | |
145 | 153 | | |
| |||
203 | 211 | | |
204 | 212 | | |
205 | 213 | | |
206 | | - | |
207 | | - | |
208 | | - | |
209 | | - | |
210 | | - | |
| 214 | + | |
211 | 215 | | |
212 | 216 | | |
213 | 217 | | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
214 | 241 | | |
215 | 242 | | |
216 | 243 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | | - | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
| |||
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
51 | 57 | | |
52 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
53 | 67 | | |
54 | 68 | | |
55 | 69 | | |
| |||
132 | 146 | | |
133 | 147 | | |
134 | 148 | | |
| 149 | + | |
135 | 150 | | |
136 | 151 | | |
137 | 152 | | |
| |||
224 | 239 | | |
225 | 240 | | |
226 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
227 | 253 | | |
228 | 254 | | |
229 | 255 | | |
| |||
237 | 263 | | |
238 | 264 | | |
239 | 265 | | |
| 266 | + | |
240 | 267 | | |
241 | 268 | | |
242 | 269 | | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | 270 | | |
247 | 271 | | |
248 | 272 | | |
| |||
0 commit comments