Skip to content

fix: security and ownership fixes from an audit - #55

Merged
blurbery merged 3 commits into
mainfrom
fix/security-audit
Nov 18, 2026
Merged

blurbery merged 3 commits into
mainfrom
fix/security-audit

Conversation

@blurbery

@blurbery blurbery commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

What this changes

Fixes from a full audit of CineSets: the web dashboard, the server clients and outbound fetches, the deployment files and workflows, and the engine and CLI logic. Each finding was checked against the code, most by reproducing it, before it was fixed. Nothing critical was found.

Ownership (the core promise)

  • A create that failed part way left a pending record with no expiry. A later run could claim a user's own collection with the same name, replace its titles, and delete it when its season ended. A pending create now only claims a collection for a day, and only one holding nothing but the titles CineSets sent. Records from before this change claim nothing (the usual "already exists, run adopt" message covers them). A create that hands back an existing collection, as Emby does, is checked the same way.

Silo and outbound fetches

  • The check that keeps Silo's API key on Silo's own address compared links with urlparse, which reads some malformed links differently from the library that actually connects. A link Silo passed through could therefore have sent the key elsewhere (Silo's own link filtering currently blocks the example case). Links the two parsers disagree on, or with credentials, spaces or other schemes, are no longer fetched at all, and IPv6 addresses still work.
  • server.verify (off, or a CA file) now applies only to Silo itself. Artwork storage on another host is checked against the usual certificate authorities.
  • Images over 12.5 million pixels are refused before decoding. Pillow only warned up to about 179 million, and a small file can claim that many. The largest image CineSets makes is 1.5 million pixels.
  • A config.yml holding the API key that other users can read (copied by hand from the example, say) is made owner-only when it's loaded, with a note.
  • The list cache now names files user@list.json. Two slugs like a__b/c and a/b__c used to share a file, so one list could be served the other's titles. Copies saved under the old names are still read until they're replaced.
  • An empty answer from mdblist keeps the saved copy, with the usual warning. Before, it took that list's titles out of a collection made from several lists.

Dashboard

  • Session cookies now carry a random session id, and signing out records it in web.json. A copied cookie stops working at sign-out, and other devices stay signed in. Old-style cookies no longer count, so everyone signs in once after updating.
  • The request line and headers now have 15 seconds to arrive in full, and open connections are capped at 64. Before, a client sending a byte every few seconds could hold a thread for days, and enough of them could use up the process's open files and lock everyone out.

Scheduler and CLI

  • A scheduled job whose collections are all unpicked is done, not failed. It used to be retried every hour, for ever.
  • Jobs that finish are timed from when they start, so a daily job that takes a while no longer comes round later each day. A failed job still waits its hour from when it ended (the Claude review caught that the first version retried a long failed job straight away).
  • --all can't be combined with --only, --group or --unpicked. remove --only m-x --all used to remove everything CineSets made.

Workflows and deployment

  • The Claude review's allowed gh commands took any extra flags, and its Read tool could read the process environment. Text in a pull request could therefore have led it to post the API key or send it to another host. Now:
    • A plain step fetches the PR (no Claude involved).
    • Claude runs with only Read, Grep and Glob: no shell, no GitHub token, no settings, hooks or MCP servers from the branch, and no reading /proc, /sys or /etc. It answers with JSON.
    • A separate step without the API key posts the review, and refuses anything that looks like a key or token. Comments on lines outside the diff go into the summary.
    • The checkout no longer keeps credentials, and the failure message is kept to one line so it can't be read as a workflow command.
  • A .dockerignore, so docker build . in a working install doesn't send config.yml, data/ or venv/ to the builder.
  • Time zone data in the image, with a commented TZ line in the compose example. Seasonal collections go by the local date, which was always UTC in the container. CI checks that TZ takes effect.
  • Extra systemd hardening for the dashboard unit (UMask=0077, PrivateDevices, kernel and cgroup protection, no capabilities, IP and Unix sockets only).
  • install.sh's warning about root cron jobs now says what the risk is: root runs run.sh, a file the folder's owner can change. It no longer claims those jobs "stop without doing anything".
  • constraints.txt no longer says Dependabot updates it.

Not changed in this PR (repository settings, for the owner):

  • Turn on Dependabot vulnerability alerts.
  • Set "Allow GitHub Actions to approve pull requests" to off.
  • Optionally, require SHA pinning for actions.
  • Delete the unused CLAUDE_CODE_OAUTH_TOKEN and ANTHROPIC_WORKSPACE_ID secrets.

How I tested it

  • New regression tests. Each fails on main (checked for the ownership and Silo ones) and passes here:
    • test_ownership.py: an old, expired or foreign-titled pending create claims nothing and leaves the user's collection alone; a create that hands back someone else's collection is refused.
    • test_silo.py: hostile artwork links are never fetched or given the key; storage on another host is verified even with verify: false.
    • test_web_security.py: sign-out ends that session even for a copied cookie while another device stays signed in; old-style cookies are refused; a client trickling its headers is hung up on; connections beyond the cap are closed and the dashboard still answers.
    • test_scheduler.py: a job with nothing picked is done; finished jobs are timed from their start; a long failed job waits its hour from its end.
    • test_lists_cache.py: separate cache files for look-alike slugs; old cache names still read; an empty answer keeps the saved copy.
    • test_catalog_config.py: a key-holding config is made owner-only (one without a key is left alone); --all with a narrower choice is refused.
    • test_mosaic.py: a 30-million-pixel image is refused before decoding.
  • Ran each affected test file on its own with Python 3.14 (silo, ownership, engine, scheduler, lists cache, catalog config, web security, web, mosaic, run results): all pass. ruff check . and shellcheck are clean.
  • Ran the Claude review's posting script against a fake gh (a normal review, one containing a key-like string, and plain text), and checked the failure step keeps a message to one line.
  • CI on this PR covers the full unit test matrix, the end-to-end runs on Emby, Jellyfin and Silo, the Docker image (including the new TZ check), and the reworked Claude review.

Release notes

BEGIN_COMMIT_OVERRIDE
fix: a failed create can no longer claim, change and later delete a collection you made with the same name
fix(silo): artwork links that could take the API key to another host are no longer fetched
fix: refuse images too big to decode safely, and keep a config.yml holding the API key private
fix(lists): look-alike list names no longer share a saved copy, and an empty answer keeps the saved one
fix(web): signing out ends that session even for a copied cookie, and slow clients can't lock everyone out
fix(schedule): a job with nothing picked is done, not retried every hour, and jobs no longer drift later
fix(cli): --all can't be mixed with --only, --group or --unpicked
ci: the Claude review only reads, and a separate step posts it
build: time zone data in the Docker image, a .dockerignore and a hardened systemd unit
END_COMMIT_OVERRIDE

AI disclosure (required)

  • No AI tools were used for any part of this change.
  • AI tools were used for this change, as described below.

AI tools used and what they did:

I designed and directed this change (an audit split into dashboard, clients, deployment and engine reviews, every finding checked against the code before fixing, and fixes that keep CineSets' ownership rules strict rather than convenient) and used Claude Opus to help run the audit and write the code, tests and docs.

Checklist

  • I've read CONTRIBUTING.md.
  • The title follows Conventional Commits, like fix: keep posters on Jellyfin 12.
  • I understand every line of this change and can explain it.
  • New source files have the CineSets header, and the unit tests pass.
  • Nothing private is included (server addresses, API keys, user names, logs).

Silo artwork links that Python's URL parser and requests read differently (https://evil\@silo/) are no longer fetched, so the API key can't follow one to another host; storage on other hosts is checked against the usual CAs. Images over 12.5 million pixels are refused before decoding. A config.yml holding the key that others can read is made owner-only on load. Two list slugs no longer share a cache file, and an empty answer from mdblist keeps the saved copy.

A pending create only claims a collection for a day, and only one holding titles CineSets sent, so a user's own collection with the same name is never taken, emptied and later deleted; a create that hands back someone else's collection is refused the same way.

The dashboard's sessions have ids, and signing out ends one for good, copied cookie included. Request headers have a 15 s deadline and open connections are capped at 64, so trickling clients can't lock everyone out.

The scheduler treats a job with nothing picked as done and times jobs from their start; --all can't be mixed with --only, --group or --unpicked.

The Claude review runs Claude with read-only tools and no GitHub token, and a separate step without the API key posts its JSON, refusing anything that looks like a key. Also a .dockerignore, time zone data in the image, systemd hardening and an accurate warning about root cron jobs.
@github-actions

Copy link
Copy Markdown
Contributor

The fixes look sound, and the Silo origin check, ownership claims and session handling hold up. I found one regression in the scheduler: a failed job that ran for over an hour is now retried straight away.

  • cinesets/cli.py:247: Recording started as at also applies to failed runs. job_due retries a failed job once now - at >= RETRY_AFTER (one hour), so a job that fails after running for an hour or more is due again as soon as it finishes and is retried in a tight loop. Use started only when ok is true, and keep time.time() for failures so the hour's wait still starts from the end of the run.

Timing every run from its start made a job that failed after more than an hour due again the moment it ended (found by the Claude review on #55). Finished runs are still timed from their start, so they don't drift.
…torage checks

The note that config.yml was made owner-only now goes to stderr, so output other programs read (a run's printed results) stays clean. The Silo storage test now checks the rule this PR introduces: server.verify applies to Silo's own address, and storage elsewhere is always verified.
@blurbery
blurbery merged commit 512fb5e into main Nov 18, 2026
17 checks passed
@blurbery
blurbery deleted the fix/security-audit branch November 18, 2026 01:19
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