Repository navigation
fix(auth): restore browser sessions only from a private session store - #32
Merged
Merged
Conversation
attach_session_store read run/sessions-<port>.json with a plain open: it followed symlinks, blocked on a FIFO, and checked neither owner nor mode. The private-directory rule existed only on the write side. With a shared or pre-created TAILFLOW_DATA_DIR, another local user could create run/ and plant a fresh store holding a secret they know. The daemon loaded it (the rewrite then failed with only a warning) and accepted that session cookie. The default data directory is in the user's home and was not exposed. On Unix the store is now read only when its directory and the file belong to this user with no group or other access, and the file is a regular file. It is opened with O_NOFOLLOW | O_NONBLOCK. Anything else is ignored with a warning: no sessions are restored and the user signs in again. Windows keeps relying on the per-user ACLs of the data directory. The two tests that write a store by hand now make it private, as the daemon does (tempfile creates 0755 directories). A new test covers a shared directory, a group/world-readable file, a symlink and a FIFO, with a private store as the control. Found in the v0.4.0 release-candidate review; pre-existing since M4-A.
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.
Found in the v0.4.0 release-candidate review (model-based). The issue is pre-existing (M4-A).
Problem
attach_session_storereadrun/sessions-<port>.jsonwith a plainFile::open:write_private.With a shared or pre-created
TAILFLOW_DATA_DIR, another local user could createrun/and plant a fresh store holding a secret they know. The daemon loaded it, the rewrite then failed with only a warning, and the daemon acceptedCookie: tailflow_session_<port>=…withSec-Fetch-Site: same-origin, a header any non-browser client can set. The default data directory (in the user's home) was not exposed.Fix
On Unix, the store is read only when:
write_privateenforces);O_NOFOLLOW | O_NONBLOCK.Otherwise the daemon logs a warning and restores no sessions, so the user signs in again. Windows behaviour is unchanged (per-user ACLs).
This adds the crate's only
unsafe:libc::geteuid(), which has no preconditions and carries a SAFETY comment.libcwas already a Unix dependency since #27.Tests
planted_session_stores_are_not_restored: shared directory, group/world-readable file, symlink and FIFO, with a private store as the control. With the privacy checks disabled it fails.stale_session_stores_are_not_restoredandexpired_or_malformed_stored_sessions_are_droppedwrote stores by hand intotempfiledirectories, which are 0755. They now make them private, as the daemon does, so they keep testing age and validity rather than the new rule.cargo test -p tailflow-daemon --bin tailflow-daemon auth::: 19 passed. Stable clippy is clean.