Conversation
The store deliberately creates config.json, account.json and the account registry with mode 0600 and their directories with 0700. session.json is the one credential file left at the process umask, because mtcute writes it — so on a default umask it lands as 0644. The enclosing directories are 0700, so nothing is exposed today; this is consistency rather than a live hole. It matters for the cases that reach past the directory mode: a store on a shared or copied volume, a backup that preserves file modes but not directory ones, or a umask-relaxed environment. Applied after a successful login, where the file is known to exist. A missing or foreign-owned file is ignored rather than failing the login.
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
session.jsonis the only credential file in the store left at the process umask — on a default umask it is created0644. Everything else the store writes is explicit:config.json,account.jsonand the account registry are0600, and their directories are0700(core/accounts.js).The difference exists because mtcute writes the session file, not tgcli, so the store's own mode discipline never reaches it. This applies a
chmodafter a successful login, where the file is known to exist.Severity: consistency, not a live hole
Worth being precise, since a permissions patch invites the wrong reading. Nothing is exposed today — the enclosing directories are
0700, so the file mode is never what stands between the auth key and another user.It matters where the directory mode stops carrying the guarantee: a store placed on a shared or synced volume, a backup or archive that preserves file modes but recreates directories, or an environment with a relaxed umask. In those cases the file mode is the only thing left, and right now it is
0644.Details
login(), so it also repairs stores created by earlier versions.npx vitest run— 299 passed, 1 skipped, 19 files. Two new tests: narrowing a0644file, and not throwing when the file is absent.Split out from #31 as suggested there; the two changes are unrelated.