Skip to content

fix: check config file is not world-writable before loading - #40

Closed
Jah-yee wants to merge 1 commit into
dolph:mainfrom
Jah-yee:fix/use-isFileWorldWritable
Closed

fix: check config file is not world-writable before loading#40
Jah-yee wants to merge 1 commit into
dolph:mainfrom
Jah-yee:fix/use-isFileWorldWritable

Conversation

@Jah-yee

@Jah-yee Jah-yee commented May 5, 2026

Copy link
Copy Markdown

Summary

LoadConfigByPath now checks whether the config file is world-writable before reading it, using the existing but unused isFileWorldWritable function from security.go.

What changed

Added a world-writable check at the top of LoadConfigByPath in config.go (8 lines added). If the file is world-writable (or unreadable), the load is skipped and a warning is logged:

Refusing to load configuration from /etc/ussher/<user>.yml: file is world-writable

This follows the same pattern as other security gates in ussher.go (isExecutableWritable, isRunningAsRoot, isValidUser) which all prevent unsafe operation.

Why

isFileWorldWritable was defined in security.go but never called anywhere in the codebase. The config file at /etc/ussher/<user>.yml controls which URLs ussher fetches SSH keys from — a world-writable config file means an attacker could redirect key lookups.

Fixes #5

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
@Jah-yee

Jah-yee commented May 11, 2026

Copy link
Copy Markdown
Author

Hi maintainer, gentle ping - this security check is ready for review. Let me know if anything needs adjustment! 🙏

@Jah-yee

Jah-yee commented May 12, 2026

Copy link
Copy Markdown
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! 🙏

@dolph dolph closed this May 18, 2026
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.

security.go: isFileWorldWritable is defined but never called, so config files are loaded without a permissions check

2 participants