mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2325] [Issue]: Spotify percent_decode_component panics on '%' followed by a multi-byte UTF-8 char (non-char-boundary slice) #1152
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#1152
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/2325
Originally assigned to: @Xelvanis on GitHub.
Summary
Severity: Low — Crash (feature-level DoS). Spotify's
percent_decode_componentslices a&strat a byte index that can land inside a multi-byte UTF-8 character, so a query value containing%immediately followed by a multi-byte char panics ("byte index is not a char boundary"). Reachable from the loopback OAuth callback server and from a user-pasted callback URL.Expected behavior
Percent-decoding should never panic on arbitrary input. A malformed
%-sequence should fall through to literal handling, not crash the callback task / connect command.Actual behavior
src-tauri/src/commands/storage/integrations/spotify_callback.rs:119-120(duplicated atspotify.rs:3083-3084):The guard
index + 2 < bytes.len()passes, but&value[index + 1..index + 3]can fall inside a 3-byte UTF-8 sequence — there is nois_char_boundarycheck. Verified empirically: input"%\u{2026}x"(bytes25 E2 80 A6 78) panics with "end byte index 3 is not a char boundary; it is inside '…'".Two reachable entry points: (1) the loopback callback server bound to
127.0.0.1:8754(start_callback_listener→handle_callback_request→parse_query→percent_decode_component); (2) the IPC connect/exchange path (spotify.rs:2977) parsing a user-pastedcallbackUrl. Default unwind (nopanic="abort"inCargo.toml), so the panic kills the spawned callback task / rejects the command promise rather than aborting the whole process — a feature-level DoS (OAuth completion silently fails until the flow is restarted).Steps to reproduce
%followed by a multibyte UTF-8 char, orGET http://127.0.0.1:8754/spotify/callback?code=%…with a raw%+ multibyte char (bytes25 E2 80 A6) in a value.percent_decode_componentpanics; the OAuth task/command dies.Impact area
Environment
b0e5561dLogs, screenshots, or video
Reproduced panic message:
end byte index 3 is not a char boundary; it is inside '…'.Regression notes
Found via static audit of the refactor branch; not verified against main. Single non-core integration, no data loss, no whole-process crash; realistic path-(1) trigger needs a local process hitting the loopback port during the ~10-min auth window, hence low — but a clean, trivially-fixable crash bug.
Additional context
Suggested fix: decode hex from the two raw bytes (
bytes[index+1],bytes[index+2]) instead of slicing the&str, or add avalue.is_char_boundary(index + 3)guard before slicing (falling through to the literal-%branch otherwise). Apply to both copies and consider deduplicating the two identicalpercent_decode_componentimplementations.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: