8000 fix(install): keep .env readable only by its owner when the line runs again by adeelahmad · Pull Request #361 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

fix(install): keep .env readable only by its owner when the line runs again - #361

Merged
adeelahmad merged 1 commit into
mainfrom
claude/project-thread-snty5h
Oct 14, 2026
Merged

adeelahmad merged 1 commit into
mainfrom
claude/project-thread-snty5h

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: a first install wrote .env as 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 read ACCESS_SECRET_KEY, ARCHIVE_SECRET_KEY, AUTH_SECRET and SURREAL_PASS.

After: .env stays 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. setenv replaces .env through sed ... >.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), and packaging/host/lens-upgrade.sh sets 022. How: the copy is now written under umask 077 in a subshell, and chmod 600 .env runs after the secrets section on every run.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (shellcheck clean).
  • I added or updated tests: both "Running it again ... keeps the secrets" CI steps (Docker and microsandbox) now check that .env is 600 after the second run.
  • My change requires documentation updates: n/a, nothing in docs/ describes the mode.
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

Done questions (AGENTS.md)

  • Goal: merged on green CI (pending).
  • Agents: n/a, install-time file permissions.
  • Zero setup: nothing new to do.
  • Fewest clicks and keystrokes: n/a.
  • Configurable: n/a, no setting.
  • Light: n/a.
  • Private and secure: this closes local read access to the install's secrets; no new surface.
  • Cost: n/a.
  • User decides: n/a. A first install's 600 is now kept on updates too; nothing that reads .env runs 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).
  • Upgrades: existing installs are fixed on their next run.
  • Honest: the changelog says only this.
  • Tests, docs and generated files updated.
  • Open standards; no dependencies.
  • Result reported with evidence: a local check of setenv under umask 022 keeps .env at 600.

🤖 Generated with Claude Code

https://claude.ai/code/session_016M1M7EXU6uJVnqfp77L19k


Generated by Claude Code

… 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 adeelahmad self-assigned this Oct 14, 2026
@adeelahmad
adeelahmad merged commit 9e521fe into main Oct 14, 2026
16 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-snty5h branch October 14, 2026 11:55
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
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.

2 participants

0