CVE-2024-32487

8.6 HIGH

📋 TL;DR

CVE-2024-32487 is a command injection vulnerability in the 'less' pager utility that allows attackers to execute arbitrary OS commands via specially crafted filenames containing newline characters. The vulnerability affects systems where LESSOPEN environment variable is set (common default configuration) and users process untrusted files. This impacts any system using vulnerable versions of 'less' to view files from untrusted sources.

💻 Affected Systems

Products:
  • less
Versions: All versions through 653
Operating Systems: Linux, Unix-like systems, macOS, BSD variants
Default Config Vulnerable: ⚠️ Yes
Notes: Vulnerability requires LESSOPEN environment variable to be set, which is common in many distributions' default configurations. Exploitation requires processing files with attacker-controlled names.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full system compromise with root privileges if 'less' is executed with elevated permissions on attacker-controlled files, leading to complete system takeover, data exfiltration, or ransomware deployment.

🟠

Likely Case

Limited privilege escalation or lateral movement within a compromised environment where users view files from untrusted archives or downloads, potentially leading to user account compromise.

🟢

If Mitigated

No impact if proper security controls prevent execution of 'less' on untrusted files or if LESSOPEN is disabled.

🌐 Internet-Facing: MEDIUM
🏢 Internal Only: HIGH

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires user interaction (viewing malicious files) but the technical complexity is low. Proof-of-concept details are publicly available in security advisories.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Version 654 and later

Vendor Advisory: https://github.com/gwsw/less/commit/007521ac3c95bc76e3d59c6dbfe75d06c8075c33

Restart Required: No

Instructions:

1. Update 'less' package using system package manager. 2. For Debian/Ubuntu: sudo apt update && sudo apt upgrade less. 3. For RHEL/CentOS: sudo yum update less. 4. For source installation: Download and compile version 654+ from official repository.

🔧 Temporary Workarounds

Disable LESSOPEN

linux

Unset the LESSOPEN environment variable to prevent the vulnerable code path from being triggered

unset LESSOPEN
export LESSOPEN=

Restrict file processing

all

Implement policies preventing 'less' from being used on files from untrusted sources

🧯 If You Can't Patch

  • Implement strict file handling policies to prevent processing of untrusted files with 'less'
  • Use alternative pager utilities (like 'more' or custom viewers) for viewing files from untrusted sources

🔍 How to Verify

Check if Vulnerable:

Check 'less' version: less --version | head -1. If version is 653 or earlier, system is vulnerable. Also check if LESSOPEN is set: echo $LESSOPEN.

Check Version:

less --version | head -1

Verify Fix Applied:

Verify 'less' version is 654 or later: less --version | head -1. Confirm patch by checking for commit 007521ac3c95bc76e3d59c6dbfe75d06c8075c33 in source.

📡 Detection & Monitoring

Log Indicators:

  • Unusual command execution following 'less' usage
  • Suspicious filenames with newline characters in access logs
  • Failed attempts to execute commands via 'less'

Network Indicators:

  • Outbound connections from systems after 'less' execution on suspicious files
  • Command and control traffic patterns

SIEM Query:

process.name:"less" AND (command_line:"*\n*" OR command_line:"*$LESSOPEN*")

🔗 References

📤 Share & Export