This is an automated email from the ASF dual-hosted git repository.

HoustonPutman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 63df4300 Prevent command injection via SolrBackup.spec.location (#844)
63df4300 is described below

commit 63df43003b5705abf461086483088da50dc18720
Author: apvxlab <[email protected]>
AuthorDate: Fri Nov 20 02:20:36 2026 +0530

    Prevent command injection via SolrBackup.spec.location (#844)
    
    * Prevent command injection via SolrBackup.spec.location
    
    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 <[email protected]>
    Signed-off-by: apvxlab <[email protected]>
    
    * Add a changelog entry for the backup directory command injection fix
    
    Also shorten the comment on the mkdir exec.
    
    ---------
    
    Signed-off-by: apvxlab <[email protected]>
    Co-authored-by: Claude Opus 4.8 <[email protected]>
    Co-authored-by: Jan Høydahl <[email protected]>
---
 controllers/util/backup_util.go | 3 ++-
 helm/solr-operator/Chart.yaml   | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/controllers/util/backup_util.go b/controllers/util/backup_util.go
index 317112be..6944735a 100644
--- a/controllers/util/backup_util.go
+++ b/controllers/util/backup_util.go
@@ -171,10 +171,11 @@ func EnsureDirectoryForBackup(solrCloud *solr.SolrCloud, 
backupRepository *solr.
        // Directory creation only required/possible for volume (i.e. local) 
backups
        if IsRepoVolume(backupRepository) {
                backupPath := BackupLocationPath(backupRepository, 
backup.Spec.Location)
+               // No shell, since backupPath contains the user-provided 
spec.location
                return RunExecForPod(
                        solrCloud.GetAllSolrPodNames()[0],
                        solrCloud.Namespace,
-                       []string{"/bin/bash", "-c", "mkdir -p " + backupPath},
+                       []string{"mkdir", "-p", backupPath},
                        config,
                )
        }
diff --git a/helm/solr-operator/Chart.yaml b/helm/solr-operator/Chart.yaml
index aab5d663..5b918d4c 100644
--- a/helm/solr-operator/Chart.yaml
+++ b/helm/solr-operator/Chart.yaml
@@ -55,6 +55,11 @@ annotations:
   # Allowed syntax is described at: 
https://artifacthub.io/docs/topics/annotations/helm/#example
   # 'kind' accepts values: "added", "changed", "deprecated", "removed", 
"fixed" and "security"
   artifacthub.io/changes: |
+    - kind: security
+      description: The operator no longer runs a shell when creating the 
directory for a volume backup, so a SolrBackup `location` can no longer inject 
commands into the Solr pod
+      links:
+        - name: Github PR
+          url: https://github.com/apache/solr-operator/pull/844
     - kind: removed
       description: The preStop hook running 'solr stop' has been removed from 
the Solr container, along with the SOLR_STOP_WAIT envVar that only served it. 
Solr shuts down on SIGTERM, so pod deletions no longer emit a FailedPreStopHook 
warning event
       links:

Reply via email to