Skip to content

[security] - Database restore command injection via sh -c #95

Open

Description

@shieldx-bot
  • Description: shared/shieldx-common/pkg/database/backup.go builds gunzip -c <backupPath> | psql ... using fmt.Sprintf and executes through sh. An attacker controlling the backup path or DB settings can inject shell payloads.
  • Location: BackupManager.Restore function, plain SQL branch when isCompressed is true.
  • Recommendation: Avoid sh -c; stream gzip contents via Go (gzip.NewReader) or call pg_restore/psql with exec.CommandContext argument slices. Validate and whitelist paths.
  • Done when: Restore uses argument-safe invocations, injection strings are rejected, and tests cover malicious paths.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is neededsecuritysystem security vulnerabilities

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions