Skip to content

Credentials file written with default umask, not 0600 #96

Closed

Description

@KalebCole

src/lib/auth.ts:59:

fs.writeFileSync(configPath, JSON.stringify(config, null, 2));

No mode argument, so ~/.config/partiful/auth.json is created 0644 under a typical umask — group- and world-readable.

The file holds apiKey, refreshToken, accessToken, tokenExpiry and userId. The refresh token is long-lived and sufficient to mint new access tokens, so this is a durable credential sitting at default permissions.

Fix

  • Create the file at 0o600 (pass { mode: 0o600 } — note mode is subject to umask, so verify with an explicit fs.chmodSync where it matters).
  • Ensure the containing directory is 0o700.
  • Write atomically (temp file + rename) so a crash mid-write can't leave a truncated or world-readable credential file.
  • Repair pre-existing files on load — anyone who has already authenticated has a 0644 file today, and a fix that only applies to new writes leaves them exposed.

A post-hoc chmod after writeFileSync is not sufficient on its own: it leaves a window where the file exists with permissive bits.

Follow-up

Consider a partiful doctor check that warns when the config file or directory is group/world readable.

Activity

  1. added
    bug
    on Aug 5, 2026
  2. KalebCole commented on Nov 14, 2026

    @KalebCole
    OwnerAuthor

    Triage bot: closing as stale. src/lib/auth.ts is gone with the Aug 12 Go cutover. The Go credential store writes 0600 (internal/auth/os_files.go). The retired TypeScript CLI is historical evidence, not a compatibility target (draft VISION (#256)). Reopen with a Go repro if this still applies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions