Skip to content

feat: create workdir securely with 0o700 permissions - #147

Merged
mkoura merged 1 commit into
masterfrom
secure-workdir-creation
Jul 7, 2026
Merged

feat: create workdir securely with 0o700 permissions#147
mkoura merged 1 commit into
masterfrom
secure-workdir-creation

Conversation

@mkoura

@mkoura mkoura commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

The workdir lives in the shared /var/tmp and was never explicitly created; filelock/create_delay_file would create it with default world-readable permissions. Add create_workdir() that makes it 0o700 and rejects a pre-existing symlink, non-directory or foreign-owned path to avoid hijacking. Call it before any lock/touch in cmd_create and delay_instance.

Use pwd.getpwuid(os.geteuid()).pw_name instead of os.getlogin() for the workdir name (getlogin fails without a controlling terminal, e.g. detached/cron/container runs) and match the effective uid in the ownership check.

The workdir lives in the shared /var/tmp and was never explicitly
created; filelock/create_delay_file would create it with default
world-readable permissions. Add create_workdir() that makes it 0o700
and rejects a pre-existing symlink, non-directory or foreign-owned
path to avoid hijacking. Call it before any lock/touch in cmd_create
and delay_instance.

Use pwd.getpwuid(os.geteuid()).pw_name instead of os.getlogin() for
the workdir name (getlogin fails without a controlling terminal, e.g.
detached/cron/container runs) and match the effective uid in the
ownership check.
@mkoura
mkoura merged commit 4620e92 into master Jul 7, 2026
4 checks passed
@mkoura
mkoura deleted the secure-workdir-creation branch July 7, 2026 12:17
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.

1 participant