fix: check config file is not world-writable before loading - #40
Closed
Jah-yee wants to merge 1 commit into
Closed
Conversation
LoadConfigByPath now calls isFileWorldWritable before reading the config file. If the file is world-writable, the load is skipped and a warning is logged. Fixes dolph#5
Author
|
Hi maintainer, gentle ping - this security check is ready for review. Let me know if anything needs adjustment! 🙏 |
Author
|
Hi @dolph 👋 Following up — this adds a world-writable permission check (8 lines) to prevent security issues when loading config. Would appreciate a review when you have time! 🙏 |
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
LoadConfigByPathnow checks whether the config file is world-writable before reading it, using the existing but unusedisFileWorldWritablefunction fromsecurity.go.What changed
Added a world-writable check at the top of
LoadConfigByPathinconfig.go(8 lines added). If the file is world-writable (or unreadable), the load is skipped and a warning is logged:This follows the same pattern as other security gates in
ussher.go(isExecutableWritable,isRunningAsRoot,isValidUser) which all prevent unsafe operation.Why
isFileWorldWritablewas defined insecurity.gobut never called anywhere in the codebase. The config file at/etc/ussher/<user>.ymlcontrols which URLs ussher fetches SSH keys from — a world-writable config file means an attacker could redirect key lookups.Fixes #5