Skip to content

Fix: Restrict file permissions for workflow templates to owner-only (0600) - #8538

Merged
pelikhan merged 1 commit into
mainfrom
fix-security-alert-385-file-permissions-ec8d8eb2a635d6ce
Jan 2, 2026
Merged

Fix: Restrict file permissions for workflow templates to owner-only (0600)#8538
pelikhan merged 1 commit into
mainfrom
fix-security-alert-385-file-permissions-ec8d8eb2a635d6ce

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

This PR fixes security alert #385 (gosec G306) by restricting file permissions for workflow template files created by the NewWorkflow function.

Problem

The NewWorkflow function in pkg/cli/commands.go was creating workflow template files with overly permissive file permissions (0644), making them world-readable. Workflow files may contain sensitive information and should follow the principle of least privilege.

Security Alert Details:

Changes

  • Changed os.WriteFile permissions from 0644 to 0600 at line 155
  • Added clarifying comment about restrictive permissions (owner-only)
  • Workflow template files are now only readable/writable by the file owner

Before:

// Write the template to fileiferr:=os.WriteFile(destFile, []byte(template), 0644); err!=nil {

After:

// Write the template to file with restrictive permissions (owner-only)iferr:=os.WriteFile(destFile, []byte(template), 0600); err!=nil {

Security Impact

✅ Prevents unauthorized users from reading potentially sensitive workflow configurations
✅ Aligns with security best practices for file permission management
✅ Resolves gosec G306 rule violation

Testing

  • Built the package successfully with go build ./pkg/cli/...
  • No compilation errors or warnings
  • File permissions correctly set to owner-only (0600)

Notes

This is an automated security fix generated by the Security Issue Fix Agent.

🤖 Generated with [Claude Code]((redacted)

AI generated by Security Fix PR

…0600)
This commit addresses security alert #385 (gosec G306) in pkg/cli/commands.go.
The NewWorkflow function was creating workflow template files with overly
permissive file permissions (0644), making them world-readable. Workflow
files may contain sensitive information and should follow the principle
of least privilege.
Changes:
- Changed os.WriteFile permissions from 0644 to 0600 at line 155
- Added clarifying comment about restrictive permissions (owner-only)
- Workflow template files are now only readable/writable by the owner
Security Impact:
- Prevents unauthorized users from reading potentially sensitive workflow configurations
- Aligns with security best practices for file permission management
- Resolves gosec G306 rule violation
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
ContributorAuthor

Smoke Test: Copilot Engine (No Firewall) - PASS ✅

Last 2 Merged PRs:

Test Results:

  • ✅ GitHub MCP: Fetched PRs successfully
  • ✅ File Writing: Created test file with timestamp
  • ✅ Bash Tool: Verified file contents
  • ✅ Playwright MCP: Loaded github.com (title contains "GitHub")
  • ✅ Safe Input gh: Ready for testing

Overall: PASS

Run: https://github.com/githubnext/gh-aw/actions/runs/20648224477

AI generated by Smoke Copilot No Firewall

@github-actions

Copy link
Copy Markdown
ContributorAuthor

PRs: #8536 Fix duplicate validateEngineStub declaration breaking linter and tests; #8533 Replace make commands with npm commands in jsweep validation steps
OpenAI curl blocked (api.openai.com/openai.com): ✅; example.com blocked: ✅
GitHub MCP (last 2 merged PR titles) reachable: ✅
File write+cat /tmp/gh-aw/agent/smoke-test-codex-firewall-20648228448.txt: ✅
Network: SANDBOXED; Overall: PASS

AI generated by Smoke Codex Firewall

@github-actions

Copy link
Copy Markdown
ContributorAuthor

Smoke test results

  • Last merged PRs: "Fix duplicate validateEngineStub declaration breaking linter and tests", "Replace make commands with npm commands in jsweep validation steps"
  • ✅ GitHub MCP PR fetch
  • ✅ Temp file write/read /tmp/gh-aw/agent/smoke-test-codex-20648257098.txt
  • ✅ Playwright title contains "GitHub"
  • ✅ Cache memory write/read /tmp/gh-aw/cache-memory/smoke-test-20648257098.txt
  • ❌ safeinputs-gh gh issues list --limit 3 (command not found)
  • Overall: FAIL

AI generated by Smoke Codex

@pelikhan
pelikhan marked this pull request as ready for review January 2, 2026 01:06
@pelikhan
pelikhan merged commit 715c1da into mainJan 2, 2026
4 checks passed
@pelikhan
pelikhan deleted the fix-security-alert-385-file-permissions-ec8d8eb2a635d6ce branch January 2, 2026 01:06
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@pelikhan