Fix orbit crash loop on incorrect file permissions#40887
Open
bash-bandicoot wants to merge 3 commits intofleetdm:mainfrom
Open
Fix orbit crash loop on incorrect file permissions#40887bash-bandicoot wants to merge 3 commits intofleetdm:mainfrom
bash-bandicoot wants to merge 3 commits intofleetdm:mainfrom
Conversation
3d7e39d to
da2641d
Compare
lucasmrod
reviewed
Mar 3, 2026
Member
lucasmrod
left a comment
There was a problem hiding this comment.
LGTM!
Please add a changes file to changes/ (fleetctl) and orbit/changes/ (fleetd), because the involved method is used by fleetctl and by orbit
Author
|
@lucasmrod , see last commit |
lucasmrod
approved these changes
Mar 3, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #40887 +/- ##
==========================================
- Coverage 66.31% 66.31% -0.01%
==========================================
Files 2469 2469
Lines 197788 197846 +58
Branches 8748 8678 -70
==========================================
+ Hits 131163 131199 +36
- Misses 54759 54774 +15
- Partials 11866 11873 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Member
|
I've created #40934 for tracking purposes. |
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.
Summary
checkPermFileinpkg/secure/secure.gonow self-heals incorrect file permissions viaos.Chmodinstead of returning a fatal error/opt/orbit/updates-metadata.jsonhas mode 755 instead of the expected 600Problem
Orbit refuses to start when
updates-metadata.jsonhas wrong permissions (e.g. 755 instead of 600), entering an infinite restart loop (systemdrestart counter observed at 3447+). The manual workaround ischmod 600 /opt/orbit/updates-metadata.json, but the root cause — an external process changing file permissions — is intermittent and hard to track.The
checkPermFilefunction inpkg/secure/secure.gowas designed as a security check, but its behavior of fatally erroring on any permission mismatch causes a denial-of-service on the legitimate user. For comparison,checkPermPath(the directory equivalent) already tolerates permissions that are less permissive than expected.Fix
When
checkPermFiledetects a permission mismatch, it now attemptsos.Chmodto correct the permissions before proceeding. It only returns an error if the chmod itself fails (e.g. insufficient privileges). This preserves the security intent — files end up with correct permissions — while making orbit resilient to external permission drift.Test plan
go test ./pkg/secure/ -v -run TestOpenFile— verifies self-healing behaviorgo test ./pkg/secure/ -v -run TestMkdirAll— unchanged, verifies directory checks still work/opt/orbit/updates-metadata.jsonwith mode 755, start orbit, confirm it self-heals and starts normally