security: create store entries with private permissions (ai:gpt-5) #53

Closed
opened 2026-05-23 22:20:39 +02:00 by heiko · 0 comments
Owner

Finding from a whole-codebase security review.

Affected code:

  • cmd/once-server/store/store.go:153-171 creates UUID directories with os.MkdirAll(f.path, 0777) and creates meta.json/content with os.Create.
  • cmd/once-server/examples/once.service:12 mitigates this only for the packaged systemd path via UMask=0077.

Impact:
The store contains uploaded secrets. Outside the systemd example, permissions depend on the process umask. With a common umask like 0022, directories may become 0755 and files 0644, exposing uploaded content and metadata to other local users on the host. Security should not depend on deployment-specific umask hygiene.

Suggested fix:

  • Create store directories with mode 0700.
  • Create meta.json, temp metadata files, and content with mode 0600 via os.OpenFile.
  • Consider chmod/migration for existing store entries whose permissions are too broad.
  • Add tests that set a permissive umask temporarily and assert private store permissions.
Finding from a whole-codebase security review. Affected code: - cmd/once-server/store/store.go:153-171 creates UUID directories with `os.MkdirAll(f.path, 0777)` and creates `meta.json`/`content` with `os.Create`. - cmd/once-server/examples/once.service:12 mitigates this only for the packaged systemd path via `UMask=0077`. Impact: The store contains uploaded secrets. Outside the systemd example, permissions depend on the process umask. With a common umask like 0022, directories may become 0755 and files 0644, exposing uploaded content and metadata to other local users on the host. Security should not depend on deployment-specific umask hygiene. Suggested fix: - Create store directories with mode 0700. - Create `meta.json`, temp metadata files, and `content` with mode 0600 via `os.OpenFile`. - Consider `chmod`/migration for existing store entries whose permissions are too broad. - Add tests that set a permissive umask temporarily and assert private store permissions.
heiko closed this issue 2026-05-24 20:56:24 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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
IUS/once#53
No description provided.