This attack exploits terminal devices that allow themselves to be written to by other users. The attacker sends command strings to the target terminal device hoping that the target user will hit enter and thereby execute the malicious command with their privileges. The attacker can send the results (such as copying /etc/passwd) to a known directory and collect once the attack has succeeded.
Last updated
CAPEC-40 (Manipulating Writeable Terminal Devices) is a standard-level attack pattern catalogued by MITRE in the Common Attack Pattern Enumeration and Classification (CAPEC). It describes a recurring method attackers use to exploit software weaknesses.
The phases an attacker typically follows to carry out this attack.
[Identify attacker-writable terminals] Determine if users TTYs are writable by the attacker.
[Execute malicious commands] Using one or more vulnerable TTY, execute commands to achieve various impacts.
What a successful CAPEC-40 attack can achieve.
Gain Privileges
Affects: Confidentiality, Access Control, Authorization
Read Data
Affects: Confidentiality
Execute Unauthorized Commands
Affects: Confidentiality, Integrity, Availability
Run Arbitrary Code
Defenses that reduce the risk of CAPEC-40.
"Any system that allows other peers to write directly to its terminal process is vulnerable to this type of attack. If the terminals are available through being over-privileged (i.e. world-writable) or the attacker is an administrator, then a series of commands in this format can be used to echo commands out to victim terminals. "$echo -e "\033[30m\033\132" > /dev/ttyXX where XX is the tty number of the user under attack. This will paste the characters to another terminal (tty). Note this technique works only if the victim's tty is world writable (which it may not be). That is one reason why programs like write(1) and talk(1) in UNIX systems need to run setuid." [REF-1] If the victim continues to hit "enter" and execute the commands, there are an endless supply of vectors available to the attacker, copying files, open up network connections, ftp out to servers, and so on.
Common questions about CAPEC-40.
This attack exploits terminal devices that allow themselves to be written to by other users. The attacker sends command strings to the target terminal device hoping that the target user will hit enter and thereby execute the malicious command with their privileges. The attacker can send the results (such as copying /etc/passwd) to a known directory and collect once the attack has succeeded.
It typically unfolds over 2 phases. It begins with: [Identify attacker-writable terminals] Determine if users TTYs are writable by the attacker.
Design: Ensure that terminals are only writeable by named owner user and/or administrator
CAPEC-40 exploits 1 CWE weakness, including CWE-77 (Improper Neutralization of Special Elements used in a Command ('Command Injection')).
MITRE rates CAPEC-40 as Very High severity with high likelihood of attack.
Attack-pattern data is sourced from the MITRE CAPEC catalog (v3.9). Weakness associations link to the corresponding CWE entries on RadicalNotion.AI.
Track the CVEs and weaknesses attackers exploit with this technique, with AI-written analysis and remediation guidance.