[security-fix] Fix incorrect file permissions for MCP gateway config containing API keys#8024
Merged
[security-fix] Fix incorrect file permissions for MCP gateway config containing API keys#8024
Conversation
Fix for security alert #391 (gosec G306) Changed file permissions from 0644 to 0600 when writing MCP gateway config file containing sensitive API keys. This prevents unauthorized users from reading the config file. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
pelikhan
approved these changes
Dec 29, 2025
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 File Permissions for MCP Gateway Config
Alert Number: #391
Severity: Medium
Rule: G306 - Expect WriteFile permissions to be 0600 or less
Vulnerability Description
The MCP gateway config file was being written with permissions
0644(readable by all users), despite containing sensitive API keys in theAuthorizationheaders. This could allow unauthorized users on the same system to read API keys from the config file.Location:
pkg/awmg/gateway.go:444Fix Applied
Changed file permissions from
0644to0600when writing the MCP gateway config file. This restricts access to the file owner only, preventing unauthorized access to sensitive API keys.Changes:
os.WriteFile(configPath, data, 0644)toos.WriteFile(configPath, data, 0600)Security Best Practices
Testing Considerations
Impact
This is a minimal, surgical change that only affects the file permissions when writing the MCP gateway config. No functional changes to the code logic.