Repository navigation
π‘οΈ Sentinel: [LOW] a media-server switch's restore point stays 0600 - #372
Merged
Merged
Conversation
The switch backs the whole database up under data/backups/rebind-*/ before it re-keys anything. That copy is not the stripped nightly one: it keeps the members' Plex tokens, so it can restore the install as it was. It was written with the process umask (0644 in a 0755 folder) and the start-up pass then gave it the backups' mode, 0640 with BACKUP_GROUP_READABLE, whose premise is that backups carry no tokens. Now the folder is made 0700 and the copy chmod'ed 0600, and the start-up pass keeps files under backups/rebind-* at 0600 like the live database. The nightly backups keep following backup_modes(). test_rebind +1, test_backup_perms +1 (both fail without the change). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014GBDVA6WTizC7z9Sp9S7Eg
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
A Plex β Jellyfin switch (
rebind.apply_plan) backs up the whole database todata/backups/rebind-*/curatarr.dbbefore it re-keys anything. This copy is not the stripped nightly backup. It is the restore point, so it keeps every member'susers.plex_tokenand the webhook secret. Its file mode didn't match that:_secure_db_filesgave it the backups' mode. WithBACKUP_GROUP_READABLE=truethat is 0640, an option that is only safe because "the backups carry no tokens" (backup_modes()docstring, CHANGELOG).Problem (evidence)
Two checks added to existing suites, run on untouched
main:Severity LOW: this needs a local account on the host, or membership in the app's group when the option is on, plus a completed switch. With that, the attacker can read members' Plex tokens. Nothing is reachable over the network.
Change
rebind.apply_plan: creates therebind-*folder with mode0o700and runsos.chmod(snap, 0o600)after the snapshot passes its check.connection._secure_db_files: database files underbackups/rebind-*/stay 0600. Every other backup still followsbackup_modes().Tests
test_rebind41/1 β 42/0test_backup_perms13/1 β 14/0test_media_switchandtest_backup_retentionare unchanged and green.test_enrichment_status_perf.py, which fails the same way on untouched main in this sandbox (SQLite 3.45.1 picks another plan) and passes in CI.Risk & edge cases
chmodonly sets the read-only bit andmkdir(mode=)is ignored, so nothing changes there.relative_to(backups).parts[0]always has at least one part, because the path is insidebackups.Duplicate check
I searched open and closed PRs for
rebind backup,rebind permissions,switch snapshot tokenandBACKUP_GROUP_READABLE(only #363 and #370 came up, neither covers this), the three agent journals, andgit log -300for rebind/backup changes. Main is at 3d9c8fd.Checks
python tests/run_all.pyis green (except the known sandbox perf suite above)mainGenerated by Claude Code