CAPECattack pattern

CAPEC-132 Symlink Attack

High Official page ↗
Abstraction
Detailed
Status
Draft
Likelihood of attack
Low
Typical severity
High
CAPEC version
3.9

Description

An adversary positions a symbolic link in such a manner that the targeted user or application accesses the link's endpoint, assuming that it is accessing a file with the link's name.

Extended description

The endpoint file may be either output or input. If the file is output, the result is that the endpoint is modified, instead of a file at the intended location. Modifications to the endpoint file may include appending, overwriting, corrupting, changing permissions, or other modifications. In some variants of this attack the adversary may be able to control the change to a file while in other cases they cannot. The former is especially damaging since the adversary may be able to grant themselves increased privileges or insert false information, but the latter can also be damaging as it can expose sensitive information or corrupt or destroy vital system or application files. Alternatively, the endpoint file may serve as input to the targeted application. This can be used to feed malformed input into the target or to cause the target to process different information, possibly allowing the adversary to control the actions of the target or to cause the target to expose information to the adversary. Moreover, the actions taken on the endpoint file are undertaken with the permissions of the targeted user or application, which may exceed the permissions that the adversary would normally have.

Execution flow

1. [Explore] [Identify Target] Adversary identifies the target application by determining whether there is sufficient check before writing data to a file and creating symlinks to files in different directories. 2. [Experiment] [Try to create symlinks to different files] The adversary then uses a variety of techniques, such as monitoring or guessing to create symlinks to the files accessed by the target application in the directories which are identified in the explore phase. 3. [Exploit] [Target application operates on created symlinks to sensitive files] The adversary is able to create symlinks to sensitive files while the target application is operating on the file.

Prerequisites

• The targeted application must perform the desired activities on a file without checking whether the file is a symbolic link or not. The adversary must be able to predict the name of the file the target application is modifying and be able to create a new symbolic link where that file would appear.

Skills required

• [Low] To create symlinks • [High] To identify the files and create the symlinks during the file operation time window

Consequences

• Confidentiality: Other • Integrity: Modify Data • Confidentiality: Read Data • Integrity: Modify Data • Authorization: Execute Unauthorized Commands • Accountability, Authentication, Authorization, Non-Repudiation: Gain Privileges • Access Control, Authorization: Bypass Protection Mechanism • Availability: Unreliable Execution

Mitigations

• Design: Check for the existence of files to be created, if in existence verify they are neither symlinks nor hard links before opening them. • Implementation: Use randomly generated file names for temporary files. Give the files restrictive permissions.

Related

Att&ck technique · MITRE ATT&CK (1)

  • T1547.009 Shortcut Modification sub-technique

Child of · CAPEC (1)

  • CAPEC-159 Redirect Access to Libraries attack pattern

Weakness · CWE (1)

  • CWE-59 Improper Link Resolution Before File Access weakness

Referenced by CWE · attack pattern (1)

  • CWE-59 Improper Link Resolution Before File Access weakness