tpagectl: stored API token is world-readable (0644 config file) #586

Closed
opened 2026-08-07 14:35:06 +00:00 by the.auditor · 1 comment
Owner

config.SetToken in internal/tpagectl/config/config.go writes the API token via viper's WriteConfig, whose default configPermissions is 0o644 (confirmed in viper.go:198). The token therefore lands in a world-readable plaintext file.

Even though OS keychain storage is deferred to #257, the interim config-file storage should restrict permissions. Suggested fix: call v.SetConfigPermissions(0o600) before WriteConfig (and/or os.Chmod(path, 0o600) after writing).

Ref: PR #585

`config.SetToken` in `internal/tpagectl/config/config.go` writes the API token via viper's `WriteConfig`, whose default `configPermissions` is `0o644` (confirmed in viper.go:198). The token therefore lands in a world-readable plaintext file. Even though OS keychain storage is deferred to #257, the interim config-file storage should restrict permissions. Suggested fix: call `v.SetConfigPermissions(0o600)` before `WriteConfig` (and/or `os.Chmod(path, 0o600)` after writing). Ref: PR #585
Owner

Already resolved in PR #588: writeConfig (internal/tpagectl/config/config.go) writes to a same-directory temp file opened with 0o600 and renames it over the target, so the config file — and any plaintext token — is never world-readable. Verified during the CLI-lump pass; closing without further change.

Already resolved in PR #588: `writeConfig` (internal/tpagectl/config/config.go) writes to a same-directory temp file opened with `0o600` and renames it over the target, so the config file — and any plaintext token — is never world-readable. 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#586
No description provided.