Repository navigation
fix(install): keep .env readable only by its owner when the line runs again - #361
Merged
Merged
Conversation
… again setenv rewrote .env through a temporary file made with the shell's umask, so on an update (where install.sh sets no umask, and the upgrade agent sets 022) .env became 0644 and its secrets readable to other local users. The copy is now made with umask 077, and .env is set to 600 on every run, which also closes installs an earlier update left open. CI checks the mode after the second run in both the Docker and microsandbox jobs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016M1M7EXU6uJVnqfp77L19k
adeelahmad
pushed a commit
that referenced
this pull request
Oct 14, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014pKRz6HkdQ7hTqEbpnyhYo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Adeel · project thread
Description
Before: a first install wrote
.envas 600, but every later run of the install line (an update by hand, Lens.app or the web app's upgrade agent) rewrote it as 644. Other users of the machine could then readACCESS_SECRET_KEY,ARCHIVE_SECRET_KEY,AUTH_SECRETandSURREAL_PASS.After:
.envstays 600 on every run, and an install that an earlier update left at 644 is set back to 600 the next time the line runs.Motivation and Context
Found while fixing #360.
setenvreplaces.envthroughsed ... >.env.tmp && mv. The temporary file takes the shell's umask, which is only 077 on a first install; on updates it's the user's own (usually 022), andpackaging/host/lens-upgrade.shsets 022. How: the copy is now written underumask 077in a subshell, andchmod 600 .envruns after the secrets section on every run.Types of changes
!in the title)Checklist:
.envis 600 after the second run.docs/describes the mode.## UnreleasedinCHANGELOG.md.Done questions (AGENTS.md)
.envruns as another user (Compose, the upgrade agent and Lens.app run as the owner or root, and the sandbox reads it the same way it does after a first install).setenvunder umask 022 keeps.envat 600.🤖 Generated with Claude Code
https://claude.ai/code/session_016M1M7EXU6uJVnqfp77L19k
Generated by Claude Code