CVE-2022-46663
📋 TL;DR
This vulnerability in GNU Less allows crafted data to bypass ANSI escape sequence filtering when using the '-R' flag, potentially enabling terminal manipulation. It affects users who process untrusted files with 'less -R' or have it configured as their default pager. The impact is limited to terminal sessions where malicious content is displayed.
💻 Affected Systems
- GNU Less
📦 What is this software?
Fedora by Fedoraproject
⚠️ Risk & Real-World Impact
Worst Case
An attacker could execute arbitrary commands in the user's terminal session by injecting malicious escape sequences, potentially leading to full terminal compromise, data theft, or lateral movement.
Likely Case
Terminal display corruption, unexpected behavior, or limited command injection depending on terminal emulator security features and user interaction.
If Mitigated
Minimal impact if users avoid processing untrusted files with 'less -R' or use updated versions with proper filtering.
🎯 Exploit Status
Exploitation requires user to open a malicious file with 'less -R'. Proof of concept exists in security advisories showing escape sequence injection.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Version 609 and later
Vendor Advisory: http://www.greenwoodsoftware.com/less/news.609.html
Restart Required: No
Instructions:
1. Check current version: less --version
2. Update via package manager: sudo apt update && sudo apt install less (Debian/Ubuntu) or sudo yum update less (RHEL/CentOS)
3. Verify update: less --version should show 609 or higher
4. Recompile from source if needed using patched version from official site
🔧 Temporary Workarounds
Avoid less -R with untrusted files
allDo not use 'less -R' when viewing files from untrusted sources. Use plain 'less' or other viewers.
Remove R from LESS environment variable
linuxEnsure LESS environment variable does not include 'R' flag to prevent automatic raw character processing.
unset LESS
export LESS="-X"
🧯 If You Can't Patch
- Restrict file permissions to prevent untrusted users from creating files that might be viewed with less -R
- Use alternative pager programs like 'more' or configure applications to use different pagers
🔍 How to Verify
Check if Vulnerable:
Run: less --version | head -1. If version is earlier than 609, system is vulnerable when using less -R.
Check Version:
less --version | head -1
Verify Fix Applied:
After update, run: less --version | head -1. Should show 609 or higher. Test with: echo -e '\033[31mtest\033[0m' | less -R - should display colored text without escape sequences visible.
📡 Detection & Monitoring
Log Indicators:
- Unusual terminal escape sequences in files being viewed
- Unexpected process execution following less usage
Network Indicators:
- Not network exploitable - no direct network indicators
SIEM Query:
Process execution where command contains 'less -R' followed by suspicious child processes
🔗 References
- http://www.greenwoodsoftware.com/less/news.609.html
- http://www.openwall.com/lists/oss-security/2023/02/07/7
- https://github.com/gwsw/less/commit/a78e1351113cef564d790a730d657a321624d79c
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/LR7AUWB34JD4PCW3HHASBEDGGHFWPAQP/
- https://security.gentoo.org/glsa/202310-11
- https://www.openwall.com/lists/oss-security/2023/02/07/7
- http://www.greenwoodsoftware.com/less/news.609.html
- http://www.openwall.com/lists/oss-security/2023/02/07/7
- https://github.com/gwsw/less/commit/a78e1351113cef564d790a730d657a321624d79c
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/LR7AUWB34JD4PCW3HHASBEDGGHFWPAQP/
- https://security.gentoo.org/glsa/202310-11
- https://www.openwall.com/lists/oss-security/2023/02/07/7