config.SetToken: chmod-after-write exposes token with default permissions #591

Closed
opened 2026-08-07 18:36:24 +00:00 by the.auditor · 1 comment
Owner

config.SetToken writes the config file via viper (WriteConfig) and only then applies os.Chmod(path, 0o600). The file is created with default umask-based permissions, leaving a window where the plaintext token is world-readable to local observers.

Write to a temp file, chmod 0600, then rename into place (atomic), or create the file with 0600 upfront.

See #588

`config.SetToken` writes the config file via viper (`WriteConfig`) and only then applies `os.Chmod(path, 0o600)`. The file is created with default umask-based permissions, leaving a window where the plaintext token is world-readable to local observers. Write to a temp file, chmod 0600, then rename into place (atomic), or create the file with 0600 upfront. See https://git.lan.thwap.org/thwap/thwap-pagesd/pulls/588
Owner

Already resolved in PR #588: writeConfig creates the temp file with 0o600 upfront (os.OpenFile mode), then renames it over the target — no chmod-after-write window. Verified during the CLI-lump pass; closing without further change.

Already resolved in PR #588: `writeConfig` creates the temp file with `0o600` upfront (os.OpenFile mode), then renames it over the target — no chmod-after-write window. Verified during the CLI-lump pass; closing without further change.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thwap/thwap-pagesd#591
No description provided.