[13.4-stable] pillar: fix decimal literals used as file modes - #6284
Merged
milan-zededa merged 2 commits intoAug 11, 2026
Merged
Conversation
os.MkdirAll(dir, 755) and os.WriteFile(file, data, 644) pass decimal, not octal, values. Go reads 755 as 0o1363, leaving permission bits 0o363 (-wxrw--wx), and 644 as 0o1204, leaving 0o204 (-w----r--). The vault directories were therefore created world-writable, and the attestation integrity token was written world-readable while not being readable by its owner. Use octal literals, keeping the permissions each site already intended. In vault/key.go that is not sufficient on its own: stageKey() mounts a tmpfs onto the key staging directory right after creating it, and a tmpfs root defaults to 01777, which masks the mode underneath for as long as the unsealed vault key is staged there. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Christoph Ostarek <christoph@zededa.com> (cherry picked from commit 1204936)
This was referenced Aug 7, 2026
github-actions
Bot
requested review from
OhmSpectator,
eriknordmark,
milan-zededa,
rouming and
uncleDecart
August 7, 2026 13:30
9 tasks
os.Mkdir(RunWlanDir, 600) passes a decimal literal. Go reads 600 as 0o1130, leaving permission bits 0o130 (--x-wx---), so /run/wlan is created group-writable and not readable by its owner. The directory holds the generated wpa_supplicant configuration, i.e. the WiFi credentials. Use 0700 rather than 0600: the intent was clearly owner-only, but a directory also needs the execute bit to be traversable. This code is not present on master, where b92d1ff moved wpa_supplicant into pillar and removed it, so the fix applies to the stable branches only and cannot be a cherry-pick. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Signed-off-by: Christoph Ostarek <christoph@zededa.com>
Contributor
Author
|
/rerun red |
christoph-zededa
marked this pull request as ready for review
August 7, 2026 14:18
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 13.4-stable #6284 +/- ##
===============================================
+ Coverage 24.78% 32.66% +7.88%
===============================================
Files 8 9 +1
Lines 1138 1090 -48
===============================================
+ Hits 282 356 +74
+ Misses 788 654 -134
- Partials 68 80 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
milan-zededa
approved these changes
Aug 10, 2026
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.
Description
Backport of #6264
Six file-mode arguments in pillar are written as decimal literals, so the
permission bits they produce are not the ones they read as:
7550o13630o363—-wxrw--wx6440o12040o204—-w----r--Measured, not inferred:
So the vault directories were created world-writable, and the attestation
integrity token file (
/run/eve.integrity_token) was written world-readablewhile not being readable by its owner. Affected call sites:
pkg/pillar/vault/key.go— key staging directorypkg/pillar/vault/handler_ext4.go(x2) — default vault and vault pathpkg/pillar/vault/handler_unsupported.go— default vaultpkg/pillar/vault/handler_zfs.go— sealed dataset mount pointpkg/pillar/cmd/zedagent/attesttask.go— integrity token fileEach site is switched to an octal literal keeping the permissions it already
intended, so there is no change of intent anywhere — only the notation bug.
Cherry-picked with
git cherry-pick -x, applies cleanly with no conflicts.Only the fix commit of #6264 is backported. That PR's second commit,
semgrep: run the rules from make and in CI, is developer tooling (a maketarget and a CI workflow) rather than a fix, and it modifies
tests/semgrep-rules/os-openfile-non-perm-mode.yaml, which is absent from16.0-stable, 14.5-stable and 13.4-stable.
In addition, this PR carries one fix that is not part of #6264, because the
affected code does not exist on master and so cannot be cherry-picked:
pkg/pillar/dpcreconciler/linuxitems/wlan.gocreates/run/wlanwithos.Mkdir(RunWlanDir, 600). 600 decimal is0o1130, permission bits0o130(
--x-wx---), so the directory is group-writable and not readable by itsowner — and it holds the generated wpa_supplicant configuration, i.e. the WiFi
credentials. It is changed to
0700rather than0600, since a directory alsoneeds the execute bit to be traversable. On master this code was removed by
b92d1ff, which moved wpa_supplicant into pillar.
How to test and validate this PR
The mistake is checkable statically. This reports nothing after this PR, and
the six call sites above before it:
Also run:
make -C pkg/pillar fmt-check make -C pkg/pillar vet make -C pkg/pillar testOn a device, the permission change can be confirmed directly. Since
MkdirAllonly applies its mode when creating the directory, the vault checks need a
device whose vault does not exist yet (fresh install, or an installation
without TPM where the vault is a plain folder):
drwxr-xr-xrather thand-wxrw--wx:stat -c '%a %A %n' /persist/vaultvolumes start. All the affected directories are used by root-owned
processes only, so no functional change is expected.
drwxr-xr-x:stat -c '%a %A %n' /persist/vault-rw-r--r--rather than--w----r--:stat -c '%a %A %n' /run/eve.integrity_tokendrwx------rather thand--x-wx---on a device with a WiFi port configured:
stat -c '%a %A %n' /run/wlanSuggested QA regression focus: vault creation and unlock on a fresh install,
both with and without TPM, on ext4 and zfs; plus one attestation cycle.
Changelog notes
Fixed file permissions on the vault directories, the vault key staging
directory and the attestation integrity token file, which were created with
different permission bits than intended.
PR Backports
Original: #6264
Checklist
For backport PRs (remove it if it's not a backport):
And the last but not least:
check them
Reasons for the unchecked boxes:
nothing to document.
changes are architecture-independent, but the vault paths are device
management code, so the on-device steps above still need to be run before
this leaves draft.