CVE-2021-4166
📋 TL;DR
CVE-2021-4166 is an out-of-bounds read vulnerability in Vim text editor that allows attackers to read memory contents beyond allocated buffers. This affects users who open specially crafted files in vulnerable Vim versions. The vulnerability could lead to information disclosure or be combined with other flaws for more severe attacks.
💻 Affected Systems
- Vim
- Neovim (potentially affected)
📦 What is this software?
Factory by Opensuse
Fedora by Fedoraproject
Fedora by Fedoraproject
Macos by Apple
macOS is Apple's desktop and laptop operating system powering Mac computers used by millions of professionals, developers, creative professionals, and enterprise users worldwide. Built on a Unix foundation with the Darwin kernel and modern Cocoa frameworks, macOS delivers a seamless ecosystem integr...
Learn more about Macos →Macos by Apple
macOS is Apple's desktop and laptop operating system powering Mac computers used by millions of professionals, developers, creative professionals, and enterprise users worldwide. Built on a Unix foundation with the Darwin kernel and modern Cocoa frameworks, macOS delivers a seamless ecosystem integr...
Learn more about Macos →Macos by Apple
macOS is Apple's desktop and laptop operating system powering Mac computers used by millions of professionals, developers, creative professionals, and enterprise users worldwide. Built on a Unix foundation with the Darwin kernel and modern Cocoa frameworks, macOS delivers a seamless ecosystem integr...
Learn more about Macos →Vim by Vim
⚠️ Risk & Real-World Impact
Worst Case
Memory contents disclosure leading to sensitive information exposure, potential ASLR bypass, or crash causing denial of service.
Likely Case
Application crash (denial of service) when processing malicious files, potentially with some memory content leakage.
If Mitigated
Limited impact with proper file handling controls and sandboxing; crash without privilege escalation.
🎯 Exploit Status
Exploitation requires user to open a malicious file; proof-of-concept code is publicly available in disclosure references.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Vim 8.2.4066 and later
Vendor Advisory: https://github.com/vim/vim/commit/6f98371532fcff911b462d51bc64f2ce8a6ae682
Restart Required: No
Instructions:
1. Update Vim using your system's package manager. 2. For Linux: 'sudo apt update && sudo apt upgrade vim' (Debian/Ubuntu) or 'sudo yum update vim' (RHEL/CentOS). 3. For Windows/macOS: Download latest version from vim.org. 4. Verify version with 'vim --version'.
🔧 Temporary Workarounds
Avoid opening untrusted files
allDo not open files from untrusted sources in Vim
Use alternative editors for untrusted files
allUse less, cat, or other simple viewers for suspicious files
🧯 If You Can't Patch
- Restrict Vim usage through application control policies
- Implement file integrity monitoring for Vim binary and configuration changes
🔍 How to Verify
Check if Vulnerable:
Run 'vim --version' and check if version is below 8.2.4066
Check Version:
vim --version | head -1
Verify Fix Applied:
Run 'vim --version' and confirm version is 8.2.4066 or higher
📡 Detection & Monitoring
Log Indicators:
- Vim crash logs
- Core dumps from Vim process
- Abnormal termination of Vim
Network Indicators:
- File transfers of suspicious text files to target systems
SIEM Query:
process_name:vim AND (event_type:crash OR exit_code:139 OR exit_code:11)
🔗 References
- http://seclists.org/fulldisclosure/2022/Jul/14
- http://seclists.org/fulldisclosure/2022/Mar/29
- http://seclists.org/fulldisclosure/2022/May/35
- http://www.openwall.com/lists/oss-security/2022/01/15/1
- https://github.com/vim/vim/commit/6f98371532fcff911b462d51bc64f2ce8a6ae682
- https://huntr.dev/bounties/229df5dd-5507-44e9-832c-c70364bdf035
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/2EY2VFBU3YGGWI5BW4XKT3F37MYGEQUD/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/
- https://security.gentoo.org/glsa/202208-32
- https://support.apple.com/kb/HT213183
- https://support.apple.com/kb/HT213256
- https://support.apple.com/kb/HT213343
- http://seclists.org/fulldisclosure/2022/Jul/14
- http://seclists.org/fulldisclosure/2022/Mar/29
- http://seclists.org/fulldisclosure/2022/May/35
- http://www.openwall.com/lists/oss-security/2022/01/15/1
- https://github.com/vim/vim/commit/6f98371532fcff911b462d51bc64f2ce8a6ae682
- https://huntr.dev/bounties/229df5dd-5507-44e9-832c-c70364bdf035
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/2EY2VFBU3YGGWI5BW4XKT3F37MYGEQUD/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/3FH2J57GDA2WMBS6J56F6QQRA6BXQQFZ/
- https://security.gentoo.org/glsa/202208-32
- https://support.apple.com/kb/HT213183
- https://support.apple.com/kb/HT213256
- https://support.apple.com/kb/HT213343