Security
SonicFrame treats everything that comes from outside as untrusted, works under a strict Content-Security-Policy, and brings no dependencies into your app.
No HTML is ever parsed
Labels and values go into attributes, text goes in
through textContent (with control and
direction-changing characters removed, and a length
cap), and icons are built element by element. Nothing
uses innerHTML, eval or the
browser's DOMParser: a podcast feed is read
by SonicFrame's own small XML reader, as text only. So a
page that requires Trusted Types (require-trusted-types-for 'script', even with trusted-types 'none') keeps
working.
A strict Content-Security-Policy
Styles are set through the CSSOM, never as inline style
attributes, and no blob workers start, so a policy
without 'unsafe-inline' keeps working:
Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self'; media-src 'self'
A page that records plays
the recording from a blob: address, so it
adds media-src 'self' blob:; one that sends
recordings with upload lists that address
in connect-src.
Colors cannot fetch
A color only ever reaches a property that accepts
nothing but a color (the canvas,
background-color, color,
border), so a color from a user or a
database can never make the page fetch an address.
Variables are resolved in linear time, at most eight
levels deep.
Limits on everything from outside
-
Peaks files: 2 MB and 20,000 values
(
loadPeaks, up to 64 MB and 1,000,000); waveform files: 8 MB by default, folded pastmaxPeaks; files that do not match their header are refused. Decoding a sound: 50 MiB by default, up to 256 MiB. -
Reading a sound in pieces
(
decode.stream): 1 GiB and 10 hours by default (your code may raise them up to 4 GiB and 24 hours). The file's own bytes are read by our code, each read inside what arrived: tags, boxes, pages and frames have their own caps (a frame of at most 16 MiB, an MP4 index of at most 64 MiB and 16,777,216 frames), the search for the first frame gives up after 64 KiB, and damaged bytes are skipped or refused, never read in a loop. No worker, noblob:address, and nothing new for your Content-Security-Policy. - Captions and tooltips: text only, capped.
-
Playlists: 1000 tracks, 512 KB of JSON or M3U (your
code may raise them up to 10,000 and 5 MB), names of
120 characters. Podcast feeds: 5 MB, with no entity
declarations and the nesting, elements, attributes
and names of the XML capped at the defaults the most
used XML readers settled on (see
Playlist); your code
may raise each up to a fixed most (past it, the
option is refused with a
RangeError), and a tag may only lower it. -
The lock screen and the media keys: words in one
line of 120 characters, at most eight pictures from
web, relative or
blob:addresses. - Recording: the microphone only after a press, never sent to the speakers, let go on stop, cancel and destroy; a recording capped at 100 MiB and 300 seconds by default (your code may raise them up to 1 GiB and 6 hours). An upload goes only to a web or relative address, with header names checked and values kept to one line, every text capped, and the server's answer kept to 64 KiB; the app's icons are taken only as path data.
- Marks, regions, analysis windows, FFT sizes, live frequency bands, spectrogram size and audio length, clip length, size, resolution and bitrate, and the decode download (streamed and capped).
- Tag attributes: unknown names fall back, text stays text, font addresses only when http(s) or relative.
-
Numbers in options: anything that is not a finite
number (
NaN,Infinity, a number written as text) takes the option's default, and a number with a range is kept inside it.
Addresses from outside go through
safeUrl(url, schemes?), which your page can
use too. It gives the address back when it is relative
or has one of the schemes (http and https
by default), and null when it has another
scheme, starts with //, holds a backslash,
a space or a control character, or is empty or longer
than 2048 characters.
import { safeUrl } from 'sonicframe';
link.href = safeUrl(fromDatabase) ?? '#';
Players on pages other people write
On a CMS, the people who write the pages can place
players with the tags, and anything they type (a title,
a label, a playlist's links) is shown as text. A
playlist's own links are hidden and inert while the
playlist stands, so a link it refused
(javascript:) cannot be clicked or focused
even when the page's CSS shows hidden elements. Your
HTML filter decides which tags an author may write:
SONIC_TAGS lists them, and
On a CMS or WordPress gives the
filter ready to paste.
The flaws known in other audio players, and what keeps each out of SonicFrame (each is guarded by a test that puts XSS payloads through every view):
| The flaw | In SonicFrame |
|---|---|
| A title read from the sound file shown as HTML in a playlist (CVE-2017-6814, WordPress's own playlist). | Every name, from a file, a list, a feed or a tag, goes in as text; there is no template that builds HTML. |
| A shortcode's attribute written into the page unescaped, so a contributor runs a script (CVE-2022-4699, CVE-2024-11881, CVE-2025-7963). | A tag's attributes are read as text and words it knows; a plugin that writes the tag escapes them on the server (see On a CMS or WordPress). |
A shortcode's src taken as
it came (CVE-2026-1909).
|
Every address goes through
safeUrl: only http, https
or relative.
|
| A plugin part that runs script from its address (CVE-2016-4567, a Flash part). |
No Flash, no frames, no code read from
text: no eval, and it works
under Trusted Types.
|
Never silences your page
Live frequency refuses media it cannot read without
muting (another origin without CORS) with an
error, and the shared audio context is
never closed nor disconnected.
What stays in the browser
Nothing, unless the app asks. With the player's
remember, the page's
localStorage (or the storage the app gives)
holds, under sonicframe:<key>, the
volume, the mute, the speed and the position of the last
sounds, each by its address or the name the app gave.
Nothing leaves the browser.
player.forget() clears it. What is read
back is checked like any input from outside: a value out
of place is left out, and a storage that fails leaves
the player playing without remembering.
No dependencies
The published package has no runtime dependencies and no install scripts, and holds only the built files, the readme, the changelog and the license.
The only text in it that looks like an address is the
SVG namespace, http://www.w3.org/2000/svg,
which browsers require to create the icons. It is a
name, never fetched.
Reporting a problem
Found a vulnerability? Report it privately on GitHub, rather than in a public issue: on the repository's Security tab, press Report a vulnerability. Only the author sees it. SECURITY.md says what to include and which versions get fixes.