## CVE-2023-51066 ### Description An authenticated remote code execution vulnerability in QStar Archive Solutions Release RELEASE_3-0 Build 7 Patch 0 allows attackers to arbitrarily execute commands. ### Vulnerability Type Remote Code Execution ### Vendor of Product QStar ### Affected Product Code Base QStar Archive Solutions - Release RELEASE_3-0 Build 7 Patch 0 ### Exploitation to exploit this vulnerability, an authenticated attacker must parse malicious code into the username and password parameters which allows you to append malicious code onto the execution stack. An attacker may also modify SMB settings. ### PoC > Vulnerable Code lib/qstar_admin.php ```php function smb_join($smb, $admin_user, $password) { if ($smb->security == 'ads') $cmd = 'net ads join -U '; else if ($smb->security == 'domain') $cmd = 'net rpc join -U '; else return "Invalid security mode for domain security"; $cmd .= "'"; $cmd .= $admin_user . "%"; $cmd .= $password; $cmd .= "'"; $result = cmd_exec($cmd, $stdout, $stderr); $msg = implode("\n", $stdout); if (strstr($msg, "Joined ")) return true; $errmsg = implode("
\n", $stderr); return $errmsg; } function smb_leave($smb, $admin_user, $password) { if ($smb->security == 'ads') $cmd = 'net ads leave -U '; else if ($smb->security == 'domain') $cmd = 'net rpc leave -U '; else return "Invalid security mode for domain security"; $cmd .= "'"; $cmd .= $admin_user . "%"; $cmd .= $password; $cmd .= "'"; $result = cmd_exec($cmd, $stdout, $stderr); $msg = implode("\n", $stdout); if (strstr($msg, "Disabled account for ")) return true; $errmsg = implode("
\n", $stderr); return $errmsg; } ``` As shown above, no authentication checks exist for this function, additionally, we can see the vulnerability here on how they are appending things to the `$cmd` variable. ```php $cmd .= "'"; $cmd .= $admin_user . "%"; $cmd .= $password; $cmd .= "'"; ``` An attacker may input a string such as this- `admin; rm -rf /*;`