fix(postinst): chmod 600 the container env file#217
Conversation
The env file at /etc/container-apps/<package>/env can hold user-set secrets (e.g. INFLUXDB_ADMIN_TOKEN) and the sibling env.defaults carries shipped default credentials, but both were created world-readable (644), letting any local process read them. Set mode 600 unconditionally so fresh installs are restricted and existing world-readable installs are hardened on upgrade. env.defaults is rewritten from the template on every configure, so it is re-hardened each time. Closes #201 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
87b4ccc to
1bac0f7
Compare
Independent security reviewReviewed the env-permission hardening with a fresh-context security persona. The P1 (fixed in this PR — P2 (deferred → halos-marine-containers#184): influxdb prestart create-from-absent branch. If P3 (deferred → #218): create-restricted idiom. The OIDC client secret (and the Note: CI |
Motivation
Container env files at
/etc/container-apps/<package>/envwere created world-readable (644). They can hold secrets such asINFLUXDB_ADMIN_TOKEN, so any local process could read them without root.Approach
templates/debian/postinst.j2: add an unconditionalchmod 600on the env file immediately after the create-if-missing block, outside the first-install guard. Becausepostinst configureruns on every upgrade, this both restricts fresh installs and corrects already-deployed world-readable files on upgrade.Tests
New
tests/test_env_permissions.pyrenders the postinst and asserts thechmod 600is present and sits after the first-install guard'sfi(locking in the upgrade-hardening intent). Confirmed failing before the change, passing after.Verification
ruff check,ruff format --check,ty check: passNote
VERSION/debian/changelogintentionally not bumped here — version-cycle coordination across the parallel container-packaging-tools PRs is handled at merge time, soversion-bump-checkmay show red until then.Closes #201