Skip to content

[LOW] Directory and File Permissions Should Be More Restrictive #8

@MacJediWizard

Description

@MacJediWizard

Description

Several files and directories are created with permissions that could be more restrictive.

Locations

Directory creation with 0755

  • `cmd/patchmon-agent/commands/root.go` line 90
  • `internal/config/config.go` line 254
  • `cmd/patchmon-agent/commands/version_update.go` lines 527, 562, 612
_ = os.MkdirAll(filepath.Dir(logFile), 0755)

Crontab file with 0644

`internal/crontab/crontab.go` line 47

if err := os.WriteFile(config.CronFilePath, []byte(content), 0644); err != nil {

Backup files with 0755

`cmd/patchmon-agent/commands/version_update.go` line 433

return os.WriteFile(dst, data, 0755)

Note: Good Practice Found

Credentials file correctly uses 0600:
`internal/config/config.go` lines 165-167

if err := os.Chmod(m.config.CredentialsFile, 0600); err != nil {
    return fmt.Errorf("error setting credentials file permissions: %w", err)
}

Recommended Fix

  1. Use more restrictive permissions for sensitive directories:
// For /etc/patchmon/
_ = os.MkdirAll(filepath.Dir(logFile), 0750)  // Group read/execute only
  1. For crontab, check minimum required permissions for cron daemon

  2. For backup files:

return os.WriteFile(dst, data, 0700)  // Owner only

Severity

🟢 LOW - Defense in depth

Labels

security, low

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestlowLow prioritysecuritySecurity vulnerability

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions