Files
jellytau/architecture/09-security.html
T

378 lines
30 KiB
HTML

<!DOCTYPE HTML>
<html lang="en" class="navy" dir="ltr">
<head>
<!-- Book generated using mdBook -->
<meta charset="UTF-8">
<title>Security - JellyTau Documentation</title>
<!-- Custom HTML head -->
<meta name="description" content="Requirements, traceability, and architecture for the JellyTau Jellyfin client.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#ffffff">
<link rel="icon" href="../favicon.svg">
<link rel="shortcut icon" href="../favicon.png">
<link rel="stylesheet" href="../css/variables.css">
<link rel="stylesheet" href="../css/general.css">
<link rel="stylesheet" href="../css/chrome.css">
<link rel="stylesheet" href="../css/print.css" media="print">
<!-- Fonts -->
<link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
<link rel="stylesheet" href="../fonts/fonts.css">
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="../highlight.css">
<link rel="stylesheet" href="../tomorrow-night.css">
<link rel="stylesheet" href="../ayu-highlight.css">
<!-- Custom theme stylesheets -->
</head>
<body class="sidebar-visible no-js">
<div id="body-container">
<!-- Provide site root to javascript -->
<script>
var path_to_root = "../";
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "navy";
</script>
<!-- Work around some values being stored in localStorage wrapped in quotes -->
<script>
try {
var theme = localStorage.getItem('mdbook-theme');
var sidebar = localStorage.getItem('mdbook-sidebar');
if (theme.startsWith('"') && theme.endsWith('"')) {
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
}
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
}
} catch (e) { }
</script>
<!-- Set the theme before any content is loaded, prevents flash -->
<script>
var theme;
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
if (theme === null || theme === undefined) { theme = default_theme; }
var html = document.querySelector('html');
html.classList.remove('navy')
html.classList.add(theme);
var body = document.querySelector('body');
body.classList.remove('no-js')
body.classList.add('js');
</script>
<input type="checkbox" id="sidebar-toggle-anchor" class="hidden">
<!-- Hide / unhide sidebar before it is displayed -->
<script>
var body = document.querySelector('body');
var sidebar = null;
var sidebar_toggle = document.getElementById("sidebar-toggle-anchor");
if (document.body.clientWidth >= 1080) {
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
sidebar = sidebar || 'visible';
} else {
sidebar = 'hidden';
}
sidebar_toggle.checked = sidebar === 'visible';
body.classList.remove('sidebar-visible');
body.classList.add("sidebar-" + sidebar);
</script>
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
<div class="sidebar-scrollbox">
<ol class="chapter"><li class="chapter-item expanded affix "><a href="../index.html">Introduction</a></li><li class="chapter-item expanded affix "><li class="part-title">Requirements & Traceability</li><li class="chapter-item expanded "><a href="../requirements.html"><strong aria-hidden="true">1.</strong> Requirements Specification</a></li><li class="chapter-item expanded "><a href="../traceability.html"><strong aria-hidden="true">2.</strong> Traceability Matrix</a></li><li class="chapter-item expanded "><a href="../traceability-ci.html"><strong aria-hidden="true">3.</strong> Traceability CI</a></li><li class="chapter-item expanded "><a href="../traces-quick-ref.html"><strong aria-hidden="true">4.</strong> Traces Quick Reference</a></li><li class="chapter-item expanded affix "><li class="part-title">Architecture</li><li class="chapter-item expanded "><a href="../architecture/index.html"><strong aria-hidden="true">5.</strong> Overview</a><a class="toggle"><div></div></a></li><li><ol class="section"><li class="chapter-item "><a href="../architecture/01-rust-backend.html"><strong aria-hidden="true">5.1.</strong> Rust Backend</a></li><li class="chapter-item "><a href="../architecture/02-svelte-frontend.html"><strong aria-hidden="true">5.2.</strong> Svelte Frontend</a></li><li class="chapter-item "><a href="../architecture/03-data-flow.html"><strong aria-hidden="true">5.3.</strong> Data Flow</a></li><li class="chapter-item "><a href="../architecture/04-type-sync-and-threading.html"><strong aria-hidden="true">5.4.</strong> Type Sync & Threading</a></li><li class="chapter-item "><a href="../architecture/05-platform-backends.html"><strong aria-hidden="true">5.5.</strong> Platform Backends</a></li><li class="chapter-item "><a href="../architecture/06-downloads-and-offline.html"><strong aria-hidden="true">5.6.</strong> Downloads & Offline</a></li><li class="chapter-item "><a href="../architecture/07-connectivity.html"><strong aria-hidden="true">5.7.</strong> Connectivity</a></li><li class="chapter-item "><a href="../architecture/08-database-design.html"><strong aria-hidden="true">5.8.</strong> Database Design</a></li><li class="chapter-item expanded "><a href="../architecture/09-security.html" class="active"><strong aria-hidden="true">5.9.</strong> Security</a></li></ol></li><li class="chapter-item expanded "><li class="part-title">UX</li><li class="chapter-item expanded "><a href="../ux-flows.html"><strong aria-hidden="true">6.</strong> UX Flows</a></li><li class="chapter-item expanded affix "><li class="part-title">Specs — Pending Work</li><li class="chapter-item expanded "><a href="../specs/index.html"><strong aria-hidden="true">7.</strong> Specs Index</a></li><li class="chapter-item expanded "><a href="../specs/SPEC-TEMPLATE.html"><strong aria-hidden="true">8.</strong> Spec Template</a></li><li class="chapter-item expanded "><a href="../specs/SPEC-REVIEW-CHECKLIST.html"><strong aria-hidden="true">9.</strong> Spec Review Checklist</a></li><li class="chapter-item expanded "><a href="../specs/playback-backend-unification.html"><strong aria-hidden="true">10.</strong> Playback Backend Unification</a></li><li class="chapter-item expanded "><a href="../specs/linux-native-video-spike.html"><strong aria-hidden="true">11.</strong> Linux Native Video Spike</a></li><li class="chapter-item expanded "><a href="../specs/backend-owned-stream-selection.html"><strong aria-hidden="true">12.</strong> Backend-Owned Stream Selection</a></li><li class="chapter-item expanded "><a href="../specs/player-facade-enforcement.html"><strong aria-hidden="true">13.</strong> Player Facade Enforcement</a></li><li class="chapter-item expanded "><a href="../specs/windows-native-audio-backend.html"><strong aria-hidden="true">14.</strong> Windows Native Audio Backend</a></li><li class="chapter-item expanded "><a href="../specs/libmpv2-migration.html"><strong aria-hidden="true">15.</strong> libmpv2 Migration</a></li><li class="chapter-item expanded "><a href="../specs/read-through-media-cache.html"><strong aria-hidden="true">16.</strong> Read-Through Media Cache</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search.html"><strong aria-hidden="true">17.</strong> Scoped Search</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search-boundary.html"><strong aria-hidden="true">18.</strong> Scoped Search Boundary</a></li><li class="chapter-item expanded "><a href="../specs/scoped-search-boundary-implementation.html"><strong aria-hidden="true">19.</strong> Scoped Search Boundary — Implementation</a></li><li class="chapter-item expanded "><a href="../specs/frontend-domain-model.html"><strong aria-hidden="true">20.</strong> Frontend Domain Model</a></li><li class="chapter-item expanded "><a href="../specs/build-provenance.html"><strong aria-hidden="true">21.</strong> Build Provenance</a></li><li class="chapter-item expanded affix "><li class="part-title">Build & Release</li><li class="chapter-item expanded "><a href="../build/build-release.html"><strong aria-hidden="true">22.</strong> Build & Release</a></li><li class="chapter-item expanded "><a href="../release-checklist.html"><strong aria-hidden="true">23.</strong> Release Checklist</a></li><li class="chapter-item expanded "><a href="../build/build-desktop-packages.html"><strong aria-hidden="true">24.</strong> Desktop Packaging</a></li><li class="chapter-item expanded "><a href="../build/build-windows.html"><strong aria-hidden="true">25.</strong> Windows Build</a></li><li class="chapter-item expanded "><a href="../defect-windows.html"><strong aria-hidden="true">26.</strong> Defect Windows</a></li><li class="chapter-item expanded "><a href="../build/docker.html"><strong aria-hidden="true">27.</strong> Docker</a></li><li class="chapter-item expanded "><a href="../build/build-builder-image.html"><strong aria-hidden="true">28.</strong> Builder Image</a></li><li class="chapter-item expanded affix "><li class="spacer"></li><li class="chapter-item expanded affix "><a href="../api-redirect.html">Rust API Reference (rustdoc)</a></li></ol>
</div>
<div id="sidebar-resize-handle" class="sidebar-resize-handle">
<div class="sidebar-resize-indicator"></div>
</div>
</nav>
<!-- Track and set sidebar scroll position -->
<script>
var sidebarScrollbox = document.querySelector('#sidebar .sidebar-scrollbox');
sidebarScrollbox.addEventListener('click', function(e) {
if (e.target.tagName === 'A') {
sessionStorage.setItem('sidebar-scroll', sidebarScrollbox.scrollTop);
}
}, { passive: true });
var sidebarScrollTop = sessionStorage.getItem('sidebar-scroll');
sessionStorage.removeItem('sidebar-scroll');
if (sidebarScrollTop) {
// preserve sidebar scroll position when navigating via links within sidebar
sidebarScrollbox.scrollTop = sidebarScrollTop;
} else {
// scroll sidebar to current active section when navigating via "next/previous chapter" buttons
var activeSection = document.querySelector('#sidebar .active');
if (activeSection) {
activeSection.scrollIntoView({ block: 'center' });
}
}
</script>
<div id="page-wrapper" class="page-wrapper">
<div class="page">
<div id="menu-bar-hover-placeholder"></div>
<div id="menu-bar" class="menu-bar sticky">
<div class="left-buttons">
<label id="sidebar-toggle" class="icon-button" for="sidebar-toggle-anchor" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
<i class="fa fa-bars"></i>
</label>
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
<i class="fa fa-paint-brush"></i>
</button>
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
<li role="none"><button role="menuitem" class="theme" id="light">Light</button></li>
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
</ul>
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
<i class="fa fa-search"></i>
</button>
</div>
<h1 class="menu-title">JellyTau Documentation</h1>
<div class="right-buttons">
<a href="../print.html" title="Print this book" aria-label="Print this book">
<i id="print-button" class="fa fa-print"></i>
</a>
<a href="https://gitea.tourolle.paris/dtourolle/jellytau" title="Git repository" aria-label="Git repository">
<i id="git-repository-button" class="fa fa-github"></i>
</a>
<a href="https://gitea.tourolle.paris/dtourolle/jellytau/_edit/master/docs/../docs/architecture/09-security.md" title="Suggest an edit" aria-label="Suggest an edit">
<i id="git-edit-button" class="fa fa-edit"></i>
</a>
</div>
</div>
<div id="search-wrapper" class="hidden">
<form id="searchbar-outer" class="searchbar-outer">
<input type="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
</form>
<div id="searchresults-outer" class="searchresults-outer hidden">
<div id="searchresults-header" class="searchresults-header"></div>
<ul id="searchresults">
</ul>
</div>
</div>
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
<script>
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
});
</script>
<div id="content" class="content">
<main>
<h1 id="security"><a class="header" href="#security">Security</a></h1>
<h2 id="authentication-token-storage"><a class="header" href="#authentication-token-storage">Authentication Token Storage</a></h2>
<p>Access tokens are <strong>not</strong> stored in the SQLite database. Instead, they are stored using platform-native secure storage:</p>
<pre><code class="language-mermaid">flowchart TB
LoginSuccess["Login Success"]
KeyringCheck{"System Keyring&lt;br/&gt;Available?"}
OSCredential["Store in OS Credential Manager&lt;br/&gt;- Linux: libsecret/GNOME Keyring&lt;br/&gt;- macOS: Keychain&lt;br/&gt;- Windows: Credential Manager&lt;br/&gt;- Android: EncryptedSharedPrefs"]
EncryptedFallback["Encrypted File Fallback&lt;br/&gt;(AES-256-GCM)"]
LoginSuccess --&gt; KeyringCheck
KeyringCheck --&gt;|"Yes"| OSCredential
KeyringCheck --&gt;|"No"| EncryptedFallback
</code></pre>
<p><strong>Key Format:</strong></p>
<pre><code>jellytau::{server_id}::{user_id}::access_token
</code></pre>
<p><strong>Rationale:</strong></p>
<ul>
<li>Tokens in SQLite would be readable if the database file is accessed</li>
<li>System keyrings provide OS-level encryption and access control</li>
<li>Fallback ensures functionality on minimal systems without a keyring daemon</li>
</ul>
<h2 id="secure-storage-module"><a class="header" href="#secure-storage-module">Secure Storage Module</a></h2>
<p><strong>Location</strong>: <code>src-tauri/src/secure_storage/</code> (planned)</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>pub trait SecureStorage: Send + Sync {
fn store(&amp;self, key: &amp;str, value: &amp;str) -&gt; Result&lt;(), SecureStorageError&gt;;
fn retrieve(&amp;self, key: &amp;str) -&gt; Result&lt;Option&lt;String&gt;, SecureStorageError&gt;;
fn delete(&amp;self, key: &amp;str) -&gt; Result&lt;(), SecureStorageError&gt;;
}
// Platform implementations
pub struct KeyringStorage; // Uses keyring crate
pub struct EncryptedFileStorage; // AES-256-GCM fallback
<span class="boring">}</span></code></pre></pre>
<h2 id="network-security"><a class="header" href="#network-security">Network Security</a></h2>
<div class="table-wrapper"><table><thead><tr><th>Aspect</th><th>Implementation</th></tr></thead><tbody>
<tr><td>Transport</td><td>HTTPS required for all Jellyfin API calls</td></tr>
<tr><td>Certificate Validation</td><td>System CA store (configurable for self-signed)</td></tr>
<tr><td>Token Transmission</td><td>Bearer token in <code>Authorization</code> header only</td></tr>
<tr><td>Token Refresh</td><td>Handled by Jellyfin server (long-lived tokens)</td></tr>
<tr><td>Android cleartext</td><td><code>res/xml/network_security_config.xml</code> blocks cleartext everywhere except <code>127.0.0.1</code> (the loopback media server, DR-137/DR-138). The manifest's <code>usesCleartextTraffic</code> is ignored once the config is present, so the config is the single authority</td></tr>
<tr><td>Android WebView</td><td><code>mixedContentMode = COMPATIBILITY</code> with <code>allowFileAccess</code>/<code>allowContentAccess</code> both <code>false</code> (DR-199). These are the second half of the cleartext policy: <code>ALWAYS_ALLOW</code> re-opened by hand what the network security config closes. Change the two together</td></tr>
</tbody></table>
</div>
<h2 id="webview-content-security-policy"><a class="header" href="#webview-content-security-policy">Webview Content Security Policy</a></h2>
<p><code>app.security.csp</code> in <code>tauri.conf.json</code> (TRACES: UR-012, UR-071 | DR-198). It was
<code>null</code> — CSP disabled — which meant any script that reached the web layer
inherited the full IPC surface. Tauri computes the header from this value when it
serves the embedded HTML, injecting a nonce for SvelteKit's inline bootstrap
script, so <code>script-src</code> needs no <code>'unsafe-inline'</code>.</p>
<pre><code>default-src 'self';
script-src 'self';
style-src 'self' 'unsafe-inline';
font-src 'self' data:;
img-src 'self' data: blob: asset: http://asset.localhost http: https:;
media-src 'self' blob: asset: http://asset.localhost http://127.0.0.1:* http: https:;
connect-src 'self' ipc: http://ipc.localhost http: https:;
worker-src 'self' blob:;
object-src 'none'; frame-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'
</code></pre>
<div class="table-wrapper"><table><thead><tr><th>Directive</th><th>Why</th></tr></thead><tbody>
<tr><td><code>default-src 'self'</code></td><td>Everything not named below is same-origin only.</td></tr>
<tr><td><code>script-src 'self'</code></td><td>The genuinely restrictive half. Bundled JS only; Tauri's build-time nonce covers the one inline <code>&lt;script&gt;</code> in <code>index.html</code>. Adding <code>'unsafe-inline'</code> here would silently do nothing anyway — a nonce in a directive voids it.</td></tr>
<tr><td><code>style-src 'self' 'unsafe-inline'</code></td><td>Svelte compiles <code>style="…"</code> attributes into markup, including <code>app.html</code>'s <code>display: contents</code> wrapper, and CSP treats a style <em>attribute</em> as inline. Safe only while no <code>&lt;style&gt;</code> <strong>element</strong> survives into <code>index.html</code>: Tauri would nonce it, and the nonce would then void <code>'unsafe-inline'</code>. The production build extracts all CSS to files, so it currently has none.</td></tr>
<tr><td><code>img-src</code></td><td>Thumbnails come from two places: the asset protocol (<code>asset://localhost/…</code> on Linux/macOS, <code>http://asset.localhost/…</code> on Windows/Android — the same protocol, named differently by <code>convertFileSrc</code>) and, on a cache miss, straight from the Jellyfin server. <code>data:</code>/<code>blob:</code> cover inline and generated images.</td></tr>
<tr><td><code>media-src</code></td><td><code>&lt;video&gt;</code>/<code>&lt;audio&gt;</code> sources: HLS transcodes and progressive streams from the server, the token-guarded loopback media server on <code>http://127.0.0.1:&lt;random port&gt;</code> (DR-137), and <code>blob:</code> for the MSE object URL hls.js attaches.</td></tr>
<tr><td><code>connect-src</code></td><td><code>ipc:</code> / <code>http://ipc.localhost</code> is Tauri's <code>invoke</code> transport (custom scheme on Linux/macOS, <code>http</code> host on Windows/Android) — without it every command is blocked. <code>http:</code>/<code>https:</code> is hls.js fetching manifests and segments; ordinary API traffic goes through Rust and is not subject to CSP.</td></tr>
<tr><td><code>worker-src 'self' blob:</code></td><td>hls.js runs its demuxer in a worker built from a blob (<code>enableWorker: true</code>). Without <code>blob:</code> it falls back to main-thread demuxing — playback survives but costs more CPU.</td></tr>
<tr><td><code>object-src</code>, <code>frame-src</code> = <code>'none'</code></td><td>No plugins, no iframes; both are classic injection sinks.</td></tr>
<tr><td><code>base-uri 'self'</code>, <code>form-action 'self'</code>, <code>frame-ancestors 'none'</code></td><td>Block <code>&lt;base&gt;</code> hijacking, form exfiltration and framing. <code>frame-ancestors</code> is only honoured when the policy is delivered as a header, which is platform-dependent; it is harmless where it is not.</td></tr>
</tbody></table>
</div>
<p><strong><code>img-src</code>/<code>media-src</code>/<code>connect-src</code> are deliberately permissive.</strong> The Jellyfin
origin is typed in by the user at run time and is routinely plain <code>http</code> on a
LAN, so it cannot be enumerated at build time. <code>http: https:</code> is a wide grant for
<em>data</em> — but it still bars <code>file:</code>, <code>filesystem:</code> and scripting schemes, and it
does not touch <code>script-src</code>, which is where an injected origin would actually
hurt. A run-time policy naming the server exactly was considered and rejected:
Tauri derives the header from immutable config at the moment it serves the HTML,
so it would mean rebuilding the config and reloading the webview whenever the
user adds or switches a server, to constrain a destination the user chooses
anyway.</p>
<p><code>devCsp</code> mirrors the policy with <code>'unsafe-inline' 'unsafe-eval'</code> on <code>script-src</code>
and <code>ws:</code>/<code>wss:</code> on <code>connect-src</code>, because the Vite dev server injects styles and
code and drives HMR over a websocket. It applies only to <code>tauri dev</code>.</p>
<h3 id="asset-protocol-scope"><a class="header" href="#asset-protocol-scope">Asset protocol scope</a></h3>
<p><code>app.security.assetProtocol.scope</code> is <code>$APPDATA/thumbnails/**</code> — not the storage
root. <code>imageCache.ts</code> is the only <code>convertFileSrc</code> caller left in the frontend:
downloaded media moved to the loopback media server in DR-137, and downloaded
audio is opened by MPV/ExoPlayer directly from its path. The old <code>$APPDATA/**</code>
grant let the webview read the SQLite database and the encrypted-token fallback
file alongside the thumbnails it actually needs.</p>
<p>If a new feature hands the webview a local file, widen this scope to that
subdirectory specifically; a path outside it resolves to nothing and the webview
reports <code>NETWORK_NO_SOURCE</code> (which is exactly how DR-134's failure presented).</p>
<h2 id="local-data-protection"><a class="header" href="#local-data-protection">Local Data Protection</a></h2>
<div class="table-wrapper"><table><thead><tr><th>Data Type</th><th>Protection</th></tr></thead><tbody>
<tr><td>Access Tokens</td><td>System keyring or encrypted file</td></tr>
<tr><td>Database (SQLite)</td><td>Plaintext (metadata only, no secrets)</td></tr>
<tr><td>Downloaded Media</td><td>Filesystem permissions only</td></tr>
<tr><td>Cached Thumbnails</td><td>Filesystem permissions only</td></tr>
</tbody></table>
</div>
<h2 id="path-confinement-and-input-binding"><a class="header" href="#path-confinement-and-input-binding">Path Confinement and Input Binding</a></h2>
<p>Two classes of defect, both of the same <em>shape</em>: a value that arrived from
outside decided something it should not, at a site whose neighbours a few lines
away already did it correctly.</p>
<h3 id="filesystem-path-confinement"><a class="header" href="#filesystem-path-confinement">Filesystem path confinement</a></h3>
<div class="table-wrapper"><table><thead><tr><th>Surface</th><th>Rule</th><th>TRACES</th></tr></thead><tbody>
<tr><td>Thumbnail cache</td><td>The filename is built from <code>item_id</code>, <code>image_type</code> and <code>tag</code>; all three are sanitised (non-alphanumerics → <code>_</code>), and the resolved path is checked with <code>starts_with(cache_dir)</code> <strong>at the point of use</strong></td><td>DR-210</td></tr>
<tr><td>Downloads</td><td><code>file_path</code> and <code>target_dir</code> are sanitised inside <code>download_item</code> itself, not only in <code>download_item_and_start</code> — the latter is what made the existing guard bypassable rather than absent</td><td>DR-211</td></tr>
</tbody></table>
</div>
<p>Two mechanics worth remembering, because both are easy to get subtly wrong:</p>
<ul>
<li><code>Path::join</code> <strong>neither folds <code>..</code> nor keeps the base when handed an absolute
path</strong>. Confinement therefore has to be checked <em>after</em> the join, not before.</li>
<li>Sanitising is <strong>per path component</strong>. Whole-string sanitising would rewrite
<code>downloads/x.mp3</code> to <code>downloads_x.mp3</code> and relocate every existing download.</li>
</ul>
<p>The database keeps both the raw key and the resolved path, so lookups still match
and pre-existing rows still resolve.</p>
<h3 id="query-and-url-construction"><a class="header" href="#query-and-url-construction">Query and URL construction</a></h3>
<p>Caller-supplied values are <strong>bound or encoded</strong>, never interpolated (DR-212):</p>
<ul>
<li>The offline <code>get_items</code> item-type filter uses parameter placeholders rather
than formatting <code>IN ('a','b')</code>.</li>
<li><code>build_get_items_endpoint</code> encodes <code>ParentId</code> / <code>IncludeItemTypes</code> / <code>SortBy</code> /
<code>SortOrder</code>. Encoding is <strong>per element</strong> and list separators stay unencoded,
because Jellyfin splits these parameters on the comma.</li>
<li><code>player_set_volume</code> clamps at the command boundary — it previously accepted
NaN and out-of-range floats even though every backend clamps internally.</li>
</ul>
<h2 id="security-considerations"><a class="header" href="#security-considerations">Security Considerations</a></h2>
<ol>
<li><strong>No Secrets in SQLite</strong>: The database contains only non-sensitive metadata</li>
<li><strong>Token Isolation</strong>: Each user/server combination has a separate token entry</li>
<li><strong>Logout Cleanup</strong>: Token deletion from secure storage on logout</li>
<li><strong>No Token Logging</strong>: Tokens are never written to logs or debug output</li>
<li><strong>IPC Security</strong>: Tauri's IPC uses structured commands, not arbitrary code execution</li>
<li><strong>Webview Containment</strong>: A restrictive <code>script-src</code> keeps injected script off the IPC surface; the asset protocol is scoped to the thumbnail cache only (see above)</li>
</ol>
</main>
<nav class="nav-wrapper" aria-label="Page navigation">
<!-- Mobile navigation buttons -->
<a rel="prev" href="../architecture/08-database-design.html" class="mobile-nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="../ux-flows.html" class="mobile-nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
<div style="clear: both"></div>
</nav>
</div>
</div>
<nav class="nav-wide-wrapper" aria-label="Page navigation">
<a rel="prev" href="../architecture/08-database-design.html" class="nav-chapters previous" title="Previous chapter" aria-label="Previous chapter" aria-keyshortcuts="Left">
<i class="fa fa-angle-left"></i>
</a>
<a rel="next prefetch" href="../ux-flows.html" class="nav-chapters next" title="Next chapter" aria-label="Next chapter" aria-keyshortcuts="Right">
<i class="fa fa-angle-right"></i>
</a>
</nav>
</div>
<script>
window.playground_copyable = true;
</script>
<script src="../elasticlunr.min.js"></script>
<script src="../mark.min.js"></script>
<script src="../searcher.js"></script>
<script src="../clipboard.min.js"></script>
<script src="../highlight.js"></script>
<script src="../book.js"></script>
<!-- Custom JS scripts -->
</div>
</body>
</html>