Bug: GetDefaultStateDir ignores UserHomeDir error, may use empty path #14

Closed
opened 2026-02-15 23:01:48 +01:00 by clawbot · 1 comment
Collaborator

Summary

internal/secret/helpers.go:50 falls back to os.UserHomeDir() when os.UserConfigDir() fails, but discards the error with _ =. If both calls fail, homeDir is empty string, producing a path like /.config/berlin.sneak.secret which is a root-level directory.

Impact

On systems where neither config dir nor home dir is available (containers, restricted users), the tool would attempt to write to the root filesystem.

Fix

Return an error when both os.UserConfigDir() and os.UserHomeDir() fail.

Location

internal/secret/helpers.go line 50

## Summary `internal/secret/helpers.go:50` falls back to `os.UserHomeDir()` when `os.UserConfigDir()` fails, but discards the error with `_ =`. If both calls fail, `homeDir` is empty string, producing a path like `/.config/berlin.sneak.secret` which is a root-level directory. ## Impact On systems where neither config dir nor home dir is available (containers, restricted users), the tool would attempt to write to the root filesystem. ## Fix Return an error when both `os.UserConfigDir()` and `os.UserHomeDir()` fail. ## Location `internal/secret/helpers.go` line 50
Author
Collaborator

Fix submitted in PR #18.

Fix submitted in PR #18.
sneak closed this issue 2026-02-20 08:54:22 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 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: sneak/secret#14
No description provided.