CAPEC-40: Manipulating Writeable Terminal Devices
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
Overview
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.
How the attack works
The phases an attacker typically follows.
- Step 1Explore
[Identify attacker-writable terminals] Determine if users TTYs are writable by the attacker.
- Determine the permissions for the TTYs found on the system. Any that allow user write to the TTY may be vulnerable.
- Attempt to write to other user TTYs. This approach could leave a trail or alert a user.
- Step 2Exploit
[Execute malicious commands] Using one or more vulnerable TTY, execute commands to achieve various impacts.
- Commands that allow reading or writing end user files can be executed.
What the attacker needs
Prerequisites
- User terminals must have a permissive access control such as world writeable that allows normal users to control data on other user's terminals.
Skills required
- Low skill: Ability to discover permissions on terminal devices. Of course, brute force can also be used.
Resources required
- Access to a terminal on the target network
Consequences
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
How to mitigate it
Defenses that reduce the risk of CAPEC-40.
- Design: Ensure that terminals are only writeable by named owner user and/or administrator
- Design: Enforce principle of least privilege
Examples
"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." [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.
Frequently asked questions
Common questions about CAPEC-40.
- What is 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.
- How does a Manipulating Writeable Terminal Devices attack work?
- It typically unfolds over 2 phases. It begins with: [Identify attacker-writable terminals] Determine if users TTYs are writable by the attacker.
- How do you prevent CAPEC-40?
- Design: Ensure that terminals are only writeable by named owner user and/or administrator
- What weaknesses does CAPEC-40 target?
- CAPEC-40 exploits one CWE weakness: CWE-77 (Improper Neutralization of Special Elements used in a Command ('Command Injection')).
- How severe is CAPEC-40?
- MITRE rates CAPEC-40 as Very High severity with high likelihood of attack.
Sources
- [1]Exploiting Software: How to Break Code (2004)
References
Attack-pattern data is sourced from the MITRE CAPEC catalog (v3.9). Weakness associations link to the corresponding CWE entries on RadicalNotion.AI.
Defend against CAPEC-40
Track the CVEs and weaknesses this technique exploits, with AI-written analysis and remediation steps.