How to Fix CVE-2024-21351: Improper Control of Generation of Code ('Code Injection')
Related fixes
Other vulnerabilities in the same area that are worth patching alongside this one:
- How to Fix CVE-2024-21338: Untrusted Pointer Dereference in Windows 10 Version 1809 — Untrusted Pointer Dereference in Windows 10 Version 1809
- How to Fix CVE-2024-38189: Improper Input Validation in Microsoft Office 2019 — Improper Input Validation in Microsoft Office 2019
- How to Fix CVE-2024-38178: Memory Corruption in Windows 11 Version 24H2 , Memory Corruption in Windows 11 Version 24H2
- How to Fix CVE-2024-21410: Improper Authentication in Microsoft Exchange Server 2016 Cumulative Update 23 , Improper Authentication in Microsoft Exchange Server 2016 Cumulative Update 23
- How to Fix CVE-2024-26169: Privilege Escalation in Windows 10 Version 1809 , Privilege Escalation in Windows 10 Version 1809
*By Sai Kiran Pandrala*
| Severity | CVSS 7.6 - High |
|---|---|
| Actively exploited? | Yes, listed in CISA KEV (added 2024-02-13) |
| Affected | Windows 11 Version 23H2: 10.0.22631.0 < 10.0.22631.3155; Windows 11 version 22H3: 10.0.22631.0 < 10.0.22631.3155; Windows 10 Version 1809: 10.0.17763.0 < 10.0.17763.5458; Windows 10 Version 1809: 10.0.0 < 10.0.17763.5458; Windows Server 2019: 10.0.17763.0 < 10.0.17763.5458; Windows Server 2022: 10.0.20348.0 < 10.0.20348.2322 |
| Fixed in | See vendor advisory for the patched build |
| Type (CWE) | CWE-94: Improper Control of Generation of Code ('Code Injection') |
Patch immediately. CISA's Known Exploited Vulnerabilities catalog lists this CVE, which means active exploitation has been confirmed. CISA KEV entry added 2024-02-13, federal due date 2024-03-05.
What is CVE-2024-21351?
CVE-2024-21351 is a improper control of generation of code ('code injection') in Windows 11 Version 23H2 from Microsoft. Windows SmartScreen Security Feature Bypass Vulnerability
Why this CVE matters
This CVE sits on CISA's Known Exploited Vulnerabilities catalog, which only happens after active exploitation is observed in the wild. The improper control of generation of code ('code injection') class of flaw gives attackers a reliable foothold against vulnerable instances of Windows 11 Version 23H2. If your deployment matches the affected versions, treat any window of unpatched exposure as compromise-likely and review logs accordingly.
Am I affected?
Run the version check that matches your platform. If the installed build sits inside the affected range from the table above, the fix applies to you.
# Linux package check
dpkg -s windows11version23h2 2>/dev/null | grep -i version # Debian / Ubuntu
rpm -q windows11version23h2 2>/dev/null # RHEL / Rocky
# Windows version check
Get-CimInstance Win32_Product | Where-Object { $_.Name -match 'Windows 11 Version 23H2' } | Select-Object Name,Version
How to fix CVE-2024-21351
Apply the patched build the vendor names in the advisory. The commands below are starting points keyed to common platforms - adapt the package name and target version to your environment.
Ubuntu / Debian
sudo apt-get update
sudo apt-get install --only-upgrade windows11version23h2
# verify the package version matches the fixed release in the advisory
dpkg -s windows11version23h2 | grep -i version
RHEL / CentOS / Rocky / AlmaLinux
sudo dnf upgrade --refresh windows11version23h2 -y
rpm -q windows11version23h2
Container image
# Vendor advisory: https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-21351
# Pull the patched base image and rebuild
docker pull <your-registry>/windows11version23h2:<patched-tag>
docker build -t <your-app>:patched .
docker stop <your-app> && docker rm <your-app>
docker run -d --name <your-app> <your-app>:patched
Windows (PowerShell, run as administrator)
# Vendor advisory: https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-21351
# Make sure Windows Update is current. For monthly rollups this is the safest path.
Install-Module -Name PSWindowsUpdate -Force -SkipPublisherCheck -Confirm:$false
Import-Module PSWindowsUpdate
Get-WindowsUpdate -KBArticleID <KB-from-advisory>
Install-WindowsUpdate -KBArticleID <KB-from-advisory> -AcceptAll -AutoReboot
# Confirm the KB landed
Get-HotFix | Where-Object { $_.HotFixID -eq 'KB<id>' }
# Or, for an MSU file downloaded from the Microsoft Update Catalog:
wusa.exe C:\Patches\windows10.0-kb<id>-x64.msu /quiet /norestart
shutdown /r /t 60
PowerShell detect/upgrade/verify/log (Windows)
# CVE-2024-21351 remediation runner — adapt the version checks to your environment.
$log = "C:\Logs\CVE-2024-21351-fix.log"
New-Item -ItemType Directory -Force -Path (Split-Path $log) | Out-Null
function Write-Log($msg) { "$(Get-Date -Format s) $msg" | Out-File $log -Append }
try {
Write-Log "Detect: checking installed product"
$installed = Get-CimInstance Win32_Product -ErrorAction SilentlyContinue |
Where-Object { $_.Name -match 'Windows 11 Version 23H2' }
if (-not $installed) { Write-Log "Product not installed; nothing to do"; return }
Write-Log "Found version $($installed.Version)"
Write-Log "Backup: copying program files and registry hive"
$stamp = Get-Date -Format yyyyMMdd-HHmm
$backup = "C:\Backup\CVE-2024-21351-$stamp"
New-Item -ItemType Directory -Force -Path $backup | Out-Null
Copy-Item $installed.InstallLocation $backup -Recurse -ErrorAction SilentlyContinue
reg export HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall "$backup\uninstall.reg" /y | Out-Null
Write-Log "Upgrade: install patched build via vendor MSI / Windows Update"
# Example MSI: Start-Process msiexec.exe -ArgumentList '/i C:\Patches\Windows 11 Version 23H2-patched.msi /qn /norestart' -Wait
Install-WindowsUpdate -AcceptAll -AutoReboot -ErrorAction SilentlyContinue
Write-Log "Verify: re-reading product version"
$after = Get-CimInstance Win32_Product | Where-Object { $_.Name -match 'Windows 11 Version 23H2' }
Write-Log "Post-patch version: $($after.Version)"
if ($after.Version -ne $installed.Version) { Write-Log "SUCCESS: version changed" } else { Write-Log "WARN: version unchanged - check vendor advisory" }
} catch {
Write-Log "ERROR: $_"
throw
}
Bash detect/upgrade/verify/log (Linux)
#!/usr/bin/env bash
# CVE-2024-21351 remediation runner. Re-runnable, exits non-zero on failure.
set -euo pipefail
log() { printf '%s %s\n' "$(date -Is)" "$*" | tee -a /var/log/cve-2024-21351-fix.log; }
log "Detect: current windows11version23h2 version"
if command -v dpkg >/dev/null 2>&1; then
current=$(dpkg-query -W -f='${Version}' windows11version23h2 2>/dev/null || echo "not-installed")
elif command -v rpm >/dev/null 2>&1; then
current=$(rpm -q --qf '%{VERSION}-%{RELEASE}' windows11version23h2 2>/dev/null || echo "not-installed")
else
current="unknown"
fi
log "Current: $current"
log "Backup: snapshotting config"
backup="/var/backups/cve-2024-21351-$(date +%Y%m%d-%H%M)"
mkdir -p "$backup"
[ -d /etc/windows11version23h2 ] && cp -a /etc/windows11version23h2 "$backup/" || true
log "Upgrade: applying vendor patch"
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update -qq
sudo apt-get install -y --only-upgrade windows11version23h2
elif command -v dnf >/dev/null 2>&1; then
sudo dnf upgrade -y windows11version23h2
elif command -v yum >/dev/null 2>&1; then
sudo yum update -y windows11version23h2
fi
log "Verify: re-reading windows11version23h2 version"
if command -v dpkg >/dev/null 2>&1; then
after=$(dpkg-query -W -f='${Version}' windows11version23h2)
else
after=$(rpm -q --qf '%{VERSION}-%{RELEASE}' windows11version23h2)
fi
log "After: $after"
if [ "$after" != "$current" ]; then
log "SUCCESS: windows11version23h2 upgraded"
else
log "WARN: version unchanged. Confirm the patched build is in your repository."
exit 1
fi
After the upgrade, restart any service that loads the patched binary so the new code is actually running.
If you can't patch immediately
Patching is the only durable fix. These mitigations cut exposure while the change window is scheduled, they do not remove the vulnerability.
Windows: disable the vulnerable feature via registry
# Vendor advisory: https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-21351
# Replace <Component> / <Setting> with the exact key from the vendor advisory.
# Always export the key first so you can roll back.
reg export "HKLM\SOFTWARE\Vendor\windows 11 version 23h2" "C:\Backup\preFix-CVE-2024-21351.reg" /y
Set-ItemProperty -Path "HKLM:\SOFTWARE\Vendor\windows 11 version 23h2" -Name "Disable<Setting>" -Value 1 -Type DWord
Restart-Service -Name "<service-name>" -Force
How to verify the fix worked
After applying the patched build, confirm the version string matches the fixed release named in the Microsoft advisory.
dpkg -s windows11version23h2 | grep -i version # Debian / Ubuntu
rpm -q windows11version23h2 # RHEL / Rocky
Get-HotFix | Sort-Object InstalledOn -Descending | Select-Object -First 5
Run an authenticated vulnerability scan with a current signature set and confirm the scanner no longer flags CVE-2024-21351. For internet-facing deployments that were unpatched during the disclosure window, review logs for the affected endpoints over the full exposure period and rotate any credentials the vulnerable process could touch.
Frequently asked questions
Is CVE-2024-21351 being exploited in the wild?
Yes. CISA added CVE-2024-21351 to the Known Exploited Vulnerabilities catalog, which means active exploitation has been confirmed.
Will a firewall rule or WAF signature fully mitigate CVE-2024-21351?
No. Network-layer filters slow opportunistic scanners and block a subset of payloads, but a focused attacker who knows the bug will work around them. The vendor patch is the only durable fix.
Do I need to assume compromise if the affected service was internet-facing and unpatched?
For a CVE that CISA confirms is under active exploitation, yes. Review logs for the affected endpoints over the entire exposure window, rotate credentials the vulnerable process could read, and look for unexpected accounts, scheduled tasks, or outbound connections.
References
- Official vendor advisory: https://msrc.microsoft.com/update-guide/vulnerability/CVE-2024-21351
- NVD entry: https://nvd.nist.gov/vuln/detail/CVE-2024-21351
- CISA KEV catalog: https://www.cisa.gov/known-exploited-vulnerabilities-catalog
- CISA KEV record: https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2024-21351
- Additional reference: https://www.cisa.gov/known-exploited-vulnerabilities-catalog?field_cve=CVE-2024-21351
*This guide was assembled from the official vendor advisory, the NVD record, and the CISA KEV catalog entry on 2026-05-25. Always confirm against the vendor advisory before applying changes in production.*