How to Fix CVE-2019-6340: Insecure Deserialization in Drupal Core
By Sai Kiran Pandrala
| Severity | CVSS 8.1 (High) |
|---|---|
| Actively exploited? | Yes, listed in CISA KEV (added 2022-03-25, federal due date 2022-04-15) |
| Affected | Drupal Core: 8.5 < version 8.5.11, 8.6 < version 8.6.10 |
| Fixed in | Drupal Core: 8.5.11, 8.6.10 |
| Type (CWE) | CWE-502: Deserialization of Untrusted Data |
Actively exploited. Listed in the CISA Known Exploited Vulnerabilities catalog since 2022-03-25; federal civilian agencies must remediate by 2022-04-15. Patch on an emergency cycle if the system is internet-exposed.
What is CVE-2019-6340?
Some field types do not properly sanitize data from non-form sources in Drupal 8.5.x before 8.5.11 and Drupal 8.6.x before 8.6.10. This can lead to arbitrary PHP code execution in some cases. A site is only affected by this if one of the following conditions is met: The site has the Drupal 8 core RESTful Web Services (rest) module enabled and allows PATCH or POST requests, or the site has another web services module enabled, like JSON:API in Drupal 8, or Services or RESTful Web Services in Drupal 7. (Note: The Drupal 7 Services module itself does not require an update at this time, but you should apply other contributed updates associated with this advisory if Services is in use.)
A successful exploit lets a attacker run arbitrary code on the target system. The fix is to install the patched build of Drupal Core listed in the table above, then confirm the running version after the upgrade.
Am I affected?
Check your installed version of Drupal Core against the Affected row above. If the build sits inside any of those ranges, treat the host as vulnerable until patched.
Read the version the same way you would for any maintenance task: the management console About page, the CLI version command, or the package manager record for the installed binary. The vendor advisory linked in the references is the authoritative source for the affected-build matrix.
How to fix CVE-2019-6340
The remediation is the patched build of Drupal Core. The blocks below give you runnable commands for the platforms that ship this product, plus a full PowerShell and Bash script you can drop into your patch automation.
Drupal core upgrade (Composer)
cd /var/www/html
drush cr
drush sql-dump > /tmp/pre-patch-$(date +%F).sql
tar czf /tmp/web-pre-patch.tgz .
composer require drupal/core-recommended:^8.5.11 drupal/core-composer-scaffold:^8.5.11 --update-with-dependencies
drush updb -y
drush cr
drush status | grep -E 'Drupal version'
Manual upgrade (no Composer)
wget https://www.drupal.org/download-latest/8.tar.gz
tar xzf 7.59.tar.gz
rsync -a --delete drupal-7.x/ /var/www/html/ # excluding sites/, files/
drush updb -y
Full PowerShell remediation script (detect, back up, patch, verify, log)
<#
.SYNOPSIS Remediates CVE-2019-6340 on Windows hosts.
.DESCRIPTION
Detects current version of Core, takes a config backup, applies the patched build
(8.5.11), confirms the upgrade, and writes a transcript to %ProgramData%\Patching.
#>
$ErrorActionPreference = 'Stop'
$logDir = "$env:ProgramData\Patching"
New-Item -ItemType Directory -Force -Path $logDir | Out-Null
Start-Transcript -Path "$logDir\CVE-2019-6340-$(Get-Date -Format yyyyMMdd-HHmmss).log"
try {
Write-Host '[1/5] Detecting current version'
$svc = Get-Service | Where-Object { $_.DisplayName -match 'Core' } | Select-Object -First 1
if ($svc) { Write-Host " Service: $($svc.Name) state=$($svc.Status)" }
Write-Host '[2/5] Backup config directory if present'
$cfg = "$env:ProgramFiles\Core"
if (Test-Path $cfg) {
$bak = "$logDir\CVE-2019-6340-backup-$(Get-Date -Format yyyyMMdd-HHmmss).zip"
Compress-Archive -Path $cfg -DestinationPath $bak -Force
Write-Host " Backup -> $bak"
}
Write-Host '[3/5] Apply patch'
try {
winget upgrade --id <vendor.Core> --accept-source-agreements --accept-package-agreements --silent
} catch {
Write-Warning "winget upgrade failed: $_ -- falling back to MSU/MSI installer"
Start-Process msiexec.exe -ArgumentList '/i "C:\Temp\patched.msi" /qn /norestart' -Wait
}
Write-Host '[4/5] Verify version'
Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 5
# Adapt the next line to your product's version file:
Get-ChildItem "$env:ProgramFiles\Core" -Recurse -Filter *.exe -ErrorAction SilentlyContinue |
Select-Object -First 1 | ForEach-Object { $_.VersionInfo.FileVersion }
Write-Host '[5/5] Restart service if needed'
if ($svc) { Restart-Service $svc.Name }
Write-Host "CVE-2019-6340 remediation complete"
} catch {
Write-Error "CVE-2019-6340 remediation FAILED: $_"
exit 1
} finally {
Stop-Transcript
}
Full Bash remediation script (detect, back up, patch, verify, log)
#!/usr/bin/env bash
# remediate-cve-2019-6340.sh — detect, back up, patch, verify.
set -euo pipefail
LOG="/var/log/patching"
mkdir -p "$LOG"
STAMP="$(date +%Y%m%d-%H%M%S)"
LOGFILE="$LOG/CVE-2019-6340-$STAMP.log"
exec > >(tee -a "$LOGFILE") 2>&1
echo "[1/5] Detect installed Core"
if command -v dpkg >/dev/null 2>&1; then
dpkg -l | grep -i "core" || true
elif command -v rpm >/dev/null 2>&1; then
rpm -qa | grep -i "core" || true
fi
echo "[2/5] Backup config"
for d in /etc/core /opt/core /usr/local/core; do
if [[ -d "$d" ]]; then
tar czf "$LOG/CVE-2019-6340-$(basename $d)-$STAMP.tgz" "$d"
echo " Backup -> $LOG/CVE-2019-6340-$(basename $d)-$STAMP.tgz"
fi
done
echo "[3/5] Apply patch (target: 8.5.11)"
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install --only-upgrade "core" -y
elif command -v dnf >/dev/null 2>&1; then
sudo dnf upgrade "core" --security -y
elif command -v yum >/dev/null 2>&1; then
sudo yum update "core" --security -y
elif command -v zypper >/dev/null 2>&1; then
sudo zypper patch --category security
fi
echo "[4/5] Verify"
if systemctl status "core" >/dev/null 2>&1; then
sudo systemctl restart "core"
systemctl is-active "core"
fi
command -v "core" >/dev/null 2>&1 && "core" --version || true
echo "[5/5] CVE-2019-6340 remediation script complete. Log: $LOGFILE"
If you can't patch immediately
WAF rule (ModSecurity, drop the obvious exploit pattern)
SecRule REQUEST_URI "@rx (?i)(?:\.\./|%2e%2e|%2f|cmd\=|exec\=|system\(|<\?php)" \
"id:90196340,phase:1,deny,log,msg:'Block likely CVE-2019-6340 exploit'"
Block at NGINX
location ~* (\.\./|cmd=|exec=|<\?php) {
return 403;
}
How to verify the fix worked
- Re-run the version command from the fix section. The output must match the patched build listed in the vendor advisory for your branch.
- Re-run an authenticated vulnerability scan (Nessus, Qualys, OpenVAS, Defender Vulnerability Management) targeting the patched host. CVE-2019-6340 must no longer be reported.
- Pull the latest service logs and search for the exploitation signatures in the vendor advisory. Treat any match before the patch timestamp as a possible compromise: isolate the host, rotate credentials the affected process could see, and run a full IR triage.
- Confirm any compensating control you put in place (firewall rules, sysctl, registry edits) is either intentionally left in place or rolled back, with the change documented in your CMDB.
Frequently asked questions
Related fixes
Other vulnerabilities in the same area that are worth patching alongside this one:
- How to Fix CVE-2026-3526: Access Control Bypass in File Access Fix (deprecated) — Access Control Bypass in File Access Fix (deprecated)
- How to Fix CVE-2026-9082: SQL Injection in Drupal core — SQL Injection in Drupal core
- How to Fix CVE-2026-6366: Critical Vulnerability in Drupal core , Critical Vulnerability in Drupal core
- How to Fix CVE-2026-6871: Cross-Site Scripting in Obfuscate , Cross-Site Scripting in Obfuscate
- How to Fix CVE-2018-7600: remote code execution , remote code execution
Is CVE-2019-6340 being exploited right now?
Yes. CVE-2019-6340 is in the CISA Known Exploited Vulnerabilities catalog, added 2022-03-25. CISA only lists CVEs with confirmed active exploitation.
What is the CVSS score for CVE-2019-6340?
CVSS 8.1 (High). Use it together with your exposure picture (internet-facing first, then DMZ, then internal) when you set the patch order.
Can I run the fix without downtime?
It depends on the platform. Network appliances often support hitless HA upgrades (upgrade the standby, fail over, upgrade the former primary). Application servers usually need a service restart. Clustered services (Elasticsearch, Tomcat behind a load balancer, MySQL replicas) tolerate a rolling upgrade. Schedule a maintenance window if HA is not in place.
What if my version is not in the affected list?
Re-check the build string in the vendor advisory linked below. CVE records reflect the affected-products list at publication. Variants discovered later are added to the same advisory or a follow-up CVE.
References
- Official vendor advisory: https://www.drupal.org/sa-core-2019-003
- NVD entry: https://nvd.nist.gov/vuln/detail/CVE-2019-6340
- CISA KEV catalog: https://www.cisa.gov/known-exploited-vulnerabilities-catalog
- https://www.synology.com/security/advisory/Synology_SA_19_09
- https://www.exploit-db.com/exploits/46452/
- https://www.exploit-db.com/exploits/46510/
- http://www.securityfocus.com/bid/107106
*This guide was assembled from the official vendor advisory, NVD record, and CISA KEV listing on 2026-05-25. Always confirm against the vendor advisory before applying changes in production.*