Files
luminary/SECURITY-AUDIT.md
T
bhursey 3759b47bc6 Add JPEG XL export with a lossless option
Export now offers JPEG XL (8-bit sRGB) next to JPEG, PNG, WebP and 16-bit
TIFF, encoded on-device by libjxl compiled to WebAssembly so the export stays
offline. The codec loads only when a JXL is chosen, the quality slider applies
to the lossy mode, and a lossless switch disables it. The user guide and
changelog describe the format and its current limits (no ICC or XMP yet).

Also adds SECURITY-AUDIT.md with the dependency scan and the review of the
server's trust boundaries.
2026-12-01 14:43:29 +00:00

7.4 KiB

Security audit

Date: 1 December 2026 · Version: 0.5.3.1 · Scope: this repository (server, client, build/release scripts, dependencies). Review was static: dependency scan plus a targeted read of the server's trust boundaries. No infrastructure, host or third-party service was tested.

Summary

No critical or high-severity issue was found in code that ships and runs by default. The production dependency tree has two high advisories that come from one transitive package (adm-zip inside onnxruntime-node) and are not reachable through anything this application does.

Everything else is either a development-only toolchain advisory, a hardening opportunity, or an operational note.

Area Result
Production dependencies 0 critical, 0 moderate, 2 high (one transitive package, not reachable)
Development dependencies 2 critical, 3 high, 3 moderate — dev server and test runner only
Authentication and sessions scrypt with per-user salt, random tokens, HttpOnly/SameSite cookies, rate limiting
Authorisation Every /api/admin/* route calls requireAdmin; gallery routes are token-scoped
Injection No eval, no new Function, no innerHTML/dangerouslySetInnerHTML; SQLite access is entirely prepared statements
Path traversal Static and tether paths are resolved and compared against a root; uploads use generated IDs
Secret handling SMTP and bridge credentials AES-256-GCM encrypted at rest; no secrets in the tree
Uploads Global size cap, content-length checked before reading, quota per account
Outbound requests Immich and dashboard URLs are operator-configured, not user-configured

Dependency findings

1. adm-zip — high, transitive (onnxruntime-node → adm-zip)

Advisories: crafted ZIP triggers a 4 GB allocation; extraction follows destination symlinks and can overwrite arbitrary files; uncontrolled memory allocation via a declared size.

Reachability here: onnxruntime-node declares adm-zip for its own archive handling. Luminary never extracts a ZIP it did not create: the denoise models are read from local storage, and the only ZIP code in the app writes archives (src/lib/zip.ts) rather than reading them. No route accepts a ZIP. Impact is therefore latent rather than exploitable.

Fix: upgrade onnxruntime-node 1.23.0 → 1.31.1 (npm i onnxruntime-node@1.31.1). That is the version npm proposes, a non-major bump. Not applied in this pass because it changes the denoise runtime and needs its own regression run.

2. Development toolchain — 2 critical, 3 high, 3 moderate

vitest/tinypool/@vitest/mocker (prototype-pollution gadget to RCE, arbitrary file read via the Vitest UI server), vite (path traversal in optimised-deps .map handling, launch-editor NTLM hash disclosure), esbuild (dev server request proxying).

None of these ship: the release bundle is static dist/ output and the Node server does not run Vite. They matter only for a machine that runs npm run dev or the Vitest UI while exposed to an untrusted network. Fix by moving to the current Vite/Vitest majors on a branch, not by a patch bump inside the current majors.

npm audit --omit=dev is the meaningful gate for releases; add it to predeploy if that gate should be enforced.

Verified controls

  • Password storage: scrypt (server/auth.mjs), 32-byte key, per-hash random salt, compared with timingSafeEqual. Non-existent accounts spend the same scrypt work and return the same message, so the endpoint does not reveal which addresses are registered.
  • Sessions: 32-byte random tokens, HttpOnly, SameSite=Lax, Secure when the request arrived over HTTPS, 30-day lifetime, server-side revocation on logout.
  • Rate limiting: sign-in is limited per IP and per IP+account (429 with Retry-After), gallery unlock is limited per link.
  • Authorisation: 26 requireAdmin checks cover the admin surface; missing or disabled accounts are rejected; the desktop local owner is only used when LUMINARY_LOCAL=1.
  • Gallery links: separate password hash with its own salt, constant-time compare, unlock cookie random per session and held in memory, so a restart re-locks the gallery. Share tokens are 18 random bytes.
  • Bridge: HMAC-SHA256 over the payload, version-tagged, expiry checked, constant-time signature compare.
  • Path handling: static requests are resolved then checked with path.relative against dist; tether file names go through basename and must match exactly; stored files are addressed by generated IDs.
  • Uploads: MAX_UPLOAD enforced against content-length before reading and again while streaming.
  • Headers: CSP with object-src 'none', frame-ancestors 'self', nosniff, SAMEORIGIN, same-origin referrer policy, restrictive Permissions-Policy. No CORS headers are emitted, so browsers cannot read responses cross-origin.
  • Secrets: SMTP app password and bridge tokens are sealed with AES-256-GCM (server/secrets.mjs); the key comes from LUMINARY_SECRET_KEY or a 0600 file beside the database. No credentials or API keys are committed.

Hardening opportunities (not vulnerabilities)

  1. CSP includes 'unsafe-eval'. It is there for the WebAssembly engines. The modern token is 'wasm-unsafe-eval'; keeping the broader one means any future DOM-XSS can compile and run script. Tighten to 'wasm-unsafe-eval' and test LibRaw/JXL/ONNX still initialise.
  2. Server-side request forgery surface. The Immich base URL and dashboard URL are operator-supplied and fetched by the server with credentials attached. An admin can point them at internal services. Acceptable for a self-hosted tool, but worth blocking loopback/link-local targets by default, or stating the trust assumption in the docs.
  3. Per-account sign-in limiting is scoped by IP. A distributed attempt against one address is not globally throttled; scrypt cost is the only brake. A global per-account counter would close that.
  4. 30-day sessions with no rotation on privilege change. Revoking sessions on password change is worth adding.
  5. No HSTS, no built-in TLS. Correct for a loopback desktop app; for team installs it depends on a reverse proxy, so document that.
  6. secret.key beside the database protects backups and dumps, not a full data-directory compromise. LUMINARY_SECRET_KEY is the stronger option and should be recommended for team installs.
  7. Minimum password length is 8 with no breach-list check. Fine; consider 12 for admin accounts.

Release artefact checks

  • The desktop bundles copy dist/ and production node_modules/; no dev dependencies or test files are included.
  • The new JPEG XL encoder is WebAssembly executed in the browser sandbox, loads only when a JXL export is chosen, makes no network requests, and is Apache-2.0 (@jsquash/jxl, libjxl BSD-3-Clause). No new server-side attack surface.
  • JPEG exports re-encode pixels, so camera EXIF is not carried into delivered files; only the XMP block Luminary writes is added.
  1. onnxruntime-node@1.31.1 with a denoise regression run (clears both production highs).
  2. Tighten CSP to 'wasm-unsafe-eval' and re-test raw, JXL and denoise loading.
  3. Vite/Vitest major upgrade on a branch (clears every dev advisory).
  4. Seal the Immich API key if it is not already sealed.
  5. Add npm audit --omit=dev --audit-level=high to scripts/predeploy.mjs.