Skip to content

Keep ~/.spawn and DCV session pages owner-only (#1593) - #1615

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1593-session-file-perms
Nov 13, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1593-session-file-perms

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1593

What

#1603 already made a new DCV session page 0600 and ~/.spawn/sessions 0700. Three gaps remained, and this PR closes them:

  • ~/.spawn itself was created 0755 by spawn cleanup's log, and MkdirAll never changes an existing parent. A new spawnHomeSubdir creates ~/.spawn and the subdirectory 0700, and tightens either to 0700 when it is looser. The chmod skips symlinks and is best-effort.
  • Pages written 0644 by releases before Move session tokens out of EC2 tags #1603 stayed readable. getSessionsDir now tightens every *.html in the directory to 0600.
  • The sweeps state directory (~/.spawn/sweeps, 0755) and the cleanup log (0644) were looser than needed. Both are now owner-only.

Tests

  • TestSessionFilesAreOwnerOnly: an old 0755/0644 layout ends up 0700/0600, and a new page is 0600. I watched it fail with the tighten step disabled.
  • TestCleanupLogKeepsSpawnHomeOwnerOnly.

This PR changes only local files on the CLI host. There is no user-data, bootstrap, IAM or spored change.

Live check (optional, local only)

  1. On a Linux host, run chmod 755 ~/.spawn ~/.spawn/sessions; chmod 644 ~/.spawn/sessions/*.html.
  2. Run spawn app launch <DCV app> --ttl 15m, or spawn app list if it opens the sessions directory.
  3. stat -c '%a %n' ~/.spawn ~/.spawn/sessions ~/.spawn/sessions/* should show 700, 700 and 600.
  4. Terminate the instance and leak-check.

The session page embeds the DCV session token. #1603 made new pages 0600
and the sessions directory 0700, but ~/.spawn itself was still created
0755 by spawn cleanup's log, and pages older releases wrote stayed 0644.
spawnHomeSubdir creates and tightens ~/.spawn and the subdirectory to
0700; getSessionsDir tightens existing pages to 0600; the sweeps state
dir and the cleanup log follow.
@codecov

codecov Bot commented Nov 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.28571% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/spawnhome.go 89.47% 2 Missing ⚠️
cmd/app.go 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn marked this pull request as ready for review November 13, 2026 21:40
@scttfrdmn
scttfrdmn merged commit 51fdb9d into main Nov 13, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1593-session-file-perms branch November 13, 2026 21:40
@scttfrdmn scttfrdmn mentioned this pull request Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: DCV session HTML containing the auth token is written world-readable under ~/.spawn/sessions

1 participant