mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2324] [Issue]: TTS speak() buffers the entire provider response into memory before enforcing the 20MB cap #1151
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1151
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Romuromylus on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2324
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Low — Unbounded buffering / DoS. TTS
speak()reads the entire provider response body into memory withresponse.bytes().awaitbefore the 20 MB cap is checked, so the cap cannot prevent a memory blow-up. A misbehaving/hostile TTS endpoint can stream a multi-GB body (within the up-to-30-minute request timeout) and OOM the process before the limit fires.Expected behavior
The body should be streamed with a running byte counter and aborted once
MAX_TTS_AUDIO_BYTES(20 MB) is exceeded, and/or aContent-Lengthpre-check applied before downloading — mirroring the established pattern incustom_tools.rs.Actual behavior
src-tauri/src/commands/storage/integrations/tts.rs:425-447:The whole body is buffered first; the cap at line 445 runs after. There is no
Content-Lengthpre-check and no streaming counter. The request timeout is configurable up to 30 minutes (MAX_TTS_REQUEST_TIMEOUT_MS = 30 * 60_000). The codebase already does this correctly elsewhere:custom_tools.rs:287-300has acontent_length()pre-check plus a.chunk()loop with a running counter; the TTS path has neither.Steps to reproduce
tts/speak.Impact area
Environment
b0e5561dLogs, screenshots, or video
Static source audit; cited to file:line above.
Regression notes
Found via static audit of the refactor branch; not verified against main. TTS config comes from stored app-settings (not the per-request body), so exploitation requires a hostile/broken user-chosen endpoint (desktop) or a post-auth config write (server), hence low.
Additional context
Suggested fix: add a
response.content_length()pre-check before download and replacebytes().awaitwith a.chunk()loop carrying a running counter that aborts onceMAX_TTS_AUDIO_BYTESis exceeded, mirroringcustom_tools.rs. (images/providers.rs:474shares the same weakness and could be fixed alongside.)Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@Romuromylus commented on GitHub (Jun 6, 2026):
Fixed by #2401, merged into
refactor.