Skip to content

Security hardening: credentials on the server's origin, PBKDF2 PIN, lost-PIN recovery - #62

Merged
Two-Play merged 5 commits into
developfrom
fix/security-hardening
Nov 18, 2026
Merged

Two-Play merged 5 commits into
developfrom
fix/security-hardening

Conversation

@Two-Play

Copy link
Copy Markdown
Owner

Summary

Credentials stay on the server's origin

  • AuthHeaders.forUrl gives the API key / session cookie only for URLs on the configured scheme, host and port: images, sprites, streams, previews, lock screen art, iOS PiP and the cast ?apikey=.
  • OriginGuardClient follows redirects itself and drops ApiKey, Cookie and Authorization once a redirect leaves the origin (dart:io forwards custom headers). It is used by GraphQL, server files and the image cache (stashImageCacheManager).
  • MediaOriginBanner warns when the server hands out media URLs on another origin (reverse proxy without Host / X-Forwarded-Proto), names both addresses and says how to fix it. It can be hidden per server.
  • Limit: mpv follows stream redirects on its own, so only a stream's first request is guarded.

App lock and PIN

  • PINs are stored as PBKDF2-HMAC-SHA256 (60k rounds, in an isolate, checked against the RFC 7914 vector). Migration: legacy salted SHA-256 values still unlock and are rewritten after the next correct PIN.
  • A lock that is on but whose PIN can't be read (unreadable or emptied secure storage) stays locked instead of turning itself off. PinLostView offers biometrics followed by a new PIN, or "Reset app".
  • With biometrics on, changing the PIN and turning the lock off also accept Face ID or the fingerprint, so a forgotten PIN can be replaced.

Other

  • User info in a server URL (user:pass@) moves from the profile JSON to the secret store (url_auth:<id>); existing profiles migrate on start, and the UI shows the URL without it.
  • GraphQL uses noCache: networkOnly kept filling a normalized cache that was never read.
  • The preview check cancels the body after the status instead of downloading whole files.
  • The password login times out after 20 s.
  • What's new entry 3 (also announcing PR List position through fullscreen, favorites selector, zoom snap feedback #61) and the release notes draft for the next beta.

Testing

  • dart analyze clean, flutter test 944 passing (new: origin guard, session origin and timeout, PIN hash, migration, lost PIN, biometric confirm, URL password migration, empty GraphQL cache, preview check, media origin check and banner).
  • Not tried on a device yet: the proxy warning on a misconfigured server, the lost-PIN screen, and upgrading a PIN set by beta.8 or earlier.

🤖 Generated with Claude Code

Two-Play and others added 4 commits November 18, 2026 16:47
Credentials stay on the server's origin:
- AuthHeaders.forUrl gives the API key / session cookie only for URLs on
  the configured scheme, host and port (images, sprites, streams,
  previews, lock screen art, iOS PiP, cast ?apikey=).
- OriginGuardClient follows redirects itself and drops ApiKey, Cookie and
  Authorization once a redirect leaves the origin (GraphQL, server files,
  and the image cache via stashImageCacheManager).
- StashSessionClient adds the cookie only on the origin.
- MediaOriginBanner warns when the server hands out media URLs on another
  origin (proxy without Host / X-Forwarded-Proto), naming both addresses.

App lock and PIN:
- PINs are stored as PBKDF2-HMAC-SHA256 (StoredPin). Legacy salted
  SHA-256 values are still accepted and upgraded after the next correct
  PIN, so existing users keep their PIN.
- An enabled lock whose PIN can't be read (unreadable or emptied secure
  storage) stays locked: PinLostView offers biometrics followed by a new
  PIN, or resetting the app.

Other fixes:
- User info in a server URL (user:password@) is kept in the secret store
  (url_auth:<id>) instead of the profile JSON; stored profiles migrate on
  start, and the UI shows the URL without it.
- GraphQL uses noCache: networkOnly kept filling a normalized cache that
  was never read.
- The preview check cancels the body after the status instead of
  downloading whole files when a server ignores Range.
- The password login times out after 20 s and reads only the headers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With biometric unlock on, confirmPin also accepts Face ID or the
fingerprint: a button on the PIN pad, or asked right away while wrong
PINs block the pad. Success resets the PIN throttle. Before, a forgotten
PIN could only be replaced by clearing the app's data, even though the
app could still be unlocked with biometrics.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Entry 3 (entry 2 shipped with v1.0.0-beta.8) announces the changes from
PR #61 and this branch: lists keep their place through fullscreen, the
favorites selector, zoom snap feedback, biometrics for the PIN and the
proxy warning; the PIN hash, lost-PIN recovery, URL passwords in the
secure storage and fewer requests are behind "Show more". The release
notes draft now describes the next beta.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 3 duplication

Metric Results
Duplication 3

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

StatusBanner holds the layout ConnectionBanner and MediaOriginBanner both
copied, and the two confirmPin widget tests pump the same page through
pumpConfirm (Codacy's duplication report on PR #62).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Two-Play
Two-Play merged commit 3edeecb into develop Nov 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant