[security-fix] Fix file permission vulnerability in MCP gateway config (Alert #391)#7958
Closed
github-actions[bot] wants to merge 1 commit intomainfrom
Closed
[security-fix] Fix file permission vulnerability in MCP gateway config (Alert #391)#7958github-actions[bot] wants to merge 1 commit intomainfrom
github-actions[bot] wants to merge 1 commit intomainfrom
Conversation
Changed os.WriteFile permissions from 0644 to 0600 for MCP gateway configuration file to prevent unauthorized access to sensitive API keys. Security issue: The config file contains Authorization: Bearer tokens (line 420) that should only be readable by the file owner. - Changed file permissions from 0644 (rw-r--r--) to 0600 (rw-------) - Added explanatory comment documenting the security requirement - Satisfies gosec G306 requirement (expect WriteFile permissions ≤ 0600) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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.
Security Fix: Incorrect Default Permissions in MCP Gateway Config
Alert Number: #391
Severity: Medium
Rule: G306 - Expect WriteFile permissions to be 0600 or less
Tool: gosec (Golang security checks)
Location:
pkg/awmg/gateway.go:444Vulnerability Description
Gosec detected that the MCP gateway configuration file was being written with
0644permissions (readable by owner, group, and others), when it should use0600or less. This is a security issue because:Authorization: Bearer (API_KEY))Data Flow:
Fix Applied
Changed file permissions from
0644to0600for the rewritten MCP gateway config file:Before:
After:
Security Best Practices Applied
✅ Principle of Least Privilege: File is now owner-readable/writable only
✅ Defense in Depth: Prevents unauthorized access to sensitive configuration
✅ Industry Standard: Follows security best practices for credential storage
✅ G306 Compliance: Satisfies gosec security scanner requirements
✅ No Breaking Changes: Functionality remains identical
Testing
✅ Build succeeded:
go build ./pkg/awmg/...passes without errors✅ No breaking changes: File writing functionality unchanged
✅ Enhanced security: Config file with API keys no longer world-readable
✅ Backwards compatible: Owner can still read/write the file
Impact Assessment
Risk: Minimal
Breaking Changes: None
Backwards Compatibility: Full
Performance: No impact
The fix only changes file permissions from
0644(rw-r--r--) to0600(rw-------). The owner can still read and write the file normally, but group and other users can no longer read sensitive API keys from the config file.Why This Fix Is Important
Files Modified
pkg/awmg/gateway.go:References
🤖 Generated by Security Fix Agent in workflow run 20548775423