Skip to content

config.json (containing access/refresh tokens) is written with 0644 permissions #1027

Description

@holdeeno

Description

~/.railway/config.json stores live credentials (user.accessToken, user.refreshToken, user.token), but the CLI writes it with mode 0644 (world-readable). Every rewrite — login, project link, MCP server activity — resets the file to 0644 even if the user has previously tightened it to 0600, because the file is replaced wholesale (new inode each time).

Expected

Credential-bearing files should be created 0600, matching peer CLIs:

  • gh writes ~/.config/gh/hosts.yml at 0600
  • AWS CLI writes ~/.aws/credentials at 0600
  • kubectl warns loudly when a kubeconfig is group/world-readable

Reproduce

$ railway login          # or any command that rewrites config
$ stat -f "%Sp" ~/.railway/config.json
-rw-r--r--
$ chmod 600 ~/.railway/config.json
# ... any subsequent CLI/MCP activity that rewrites config ...
$ stat -f "%Sp" ~/.railway/config.json
-rw-r--r--

Environment

  • railway 5.23.1 (Homebrew), macOS 15.x
  • Observed via both direct CLI use and railway mcp server activity

The fix is presumably a 0o600 mode on the config file create (and ideally an umask-independent explicit set_permissions on the rename-into-place path, since the file is replaced rather than truncated).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions