Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: owner-only permissions for config dir and config.json

Luigi Agosti66d16323104a
diff --git a/internal/config/fileio.go b/internal/config/fileio.go
index f28a2f66..67ca9001 100644
--- a/internal/config/fileio.go
+++ b/internal/config/fileio.go
@@ -38,9 +38,13 @@ func LoadFileConfig() (*FileConfig, string, error) {
// SaveFileConfig saves a FileConfig to the specified path.
func SaveFileConfig(fc *FileConfig, path string) error {
- if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
+ dir := filepath.Dir(path)
+ if err := os.MkdirAll(dir, 0700); err != nil {
return fmt.Errorf("failed to create config directory: %w", err)
}
+ if err := os.Chmod(dir, 0700); err != nil {
+ return fmt.Errorf("failed to set config directory permissions: %w", err)
+ }
data, err := json.MarshalIndent(fc, "", " ")
if err != nil {
@@ -48,9 +52,12 @@ func SaveFileConfig(fc *FileConfig, path string) error {
}
data = append(data, '\n')
- if err := os.WriteFile(path, data, 0644); err != nil {
+ if err := os.WriteFile(path, data, 0600); err != nil {
return fmt.Errorf("failed to write config file: %w", err)
}
+ if err := os.Chmod(path, 0600); err != nil {
+ return fmt.Errorf("failed to set config file permissions: %w", err)
+ }
return nil
}
diff --git a/internal/config/workflow/mutate.go b/internal/config/workflow/mutate.go
index acc17cd3..724ac2f8 100644
--- a/internal/config/workflow/mutate.go
+++ b/internal/config/workflow/mutate.go
@@ -87,7 +87,7 @@ func UpdateValue(path, value string) (*config.RuntimeConfig, bool, error) {
}
func InitDefaultConfig(path string) error {
- if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
+ if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
return fmt.Errorf("create config directory: %w", err)
}
diff --git a/internal/orchestrator/orchestrator.go b/internal/orchestrator/orchestrator.go
index f61020a6..2eb3d5ac 100644
--- a/internal/orchestrator/orchestrator.go
+++ b/internal/orchestrator/orchestrator.go
@@ -340,9 +340,12 @@ func (o *Orchestrator) LaunchWithOptions(name, port string, headless bool, opts
return nil, fmt.Errorf("create profile dir: %w", err)
}
instanceStateDir := filepath.Join(profilePath, ".pinchtab-state")
- if err := os.MkdirAll(instanceStateDir, 0755); err != nil {
+ if err := os.MkdirAll(instanceStateDir, 0700); err != nil {
return nil, fmt.Errorf("create state dir: %w", err)
}
+ if err := os.Chmod(instanceStateDir, 0700); err != nil {
+ return nil, fmt.Errorf("set state dir permissions: %w", err)
+ }
requestedPolicy := cloneSecurityPolicy(opts.SecurityPolicy)
effectivePolicy := effectiveSecurityPolicy(o.runtimeCfg, requestedPolicy)
@@ -460,7 +463,10 @@ func (o *Orchestrator) writeChildConfig(port string, cdpPort int, profilePath, i
if err != nil {
return "", err
}
- if err := os.WriteFile(configPath, data, 0644); err != nil {
+ if err := os.WriteFile(configPath, data, 0600); err != nil {
+ return "", err
+ }
+ if err := os.Chmod(configPath, 0600); err != nil {
return "", err
}
return configPath, nil