CAPEC-159 - Redirect Access to Libraries

An attacker exploits the execution flow of a call to an external library to point to an attacker supplied library or code base, allowing the attacker to compromise the application or server via the execution of unauthorized code. An application typically makes calls to functions that are a part of libraries external to the application. These libraries may be part of the operating system or they may be third party libraries. If an attacker can redirect an application's attempts to access these libraries to other libraries that the attacker supplies, the attacker will be able to force the targeted application to execute arbitrary code. This is especially dangerous if the targeted application has enhanced privileges. Access can be redirected through a number of techniques, including the use of symbolic links, search path modification, and relative path manipulation.

Severity

Likelihood

Confidentiality

Integrity

Availability

  • Attack Methods 3
  • Modification of Resources
  • Injection
  • API Abuse
  • Purposes 2
  • Exploitation
  • Penetration
  • Scopes 2
  • Execute unauthorized code or commands
  • Authorization
  • Bypass protection mechanism
  • Authorization
  • Access_Control

Low level: To modify the entries in the configuration file pointing to malicious libraries

Medium level: To force symlink and timing issues for redirecting access to libraries

High level: To reverse engineering the libraries and inject malicious code into the libraries

The target must utilize external libraries and must fail to verify the integrity of these libraries before using them.

Step 1 - Identify target general susceptibility

An attacker uses an automated tool or manually finds whether the target application uses dynamically linked libraries and the configuration file or look up table (such as Procedure Linkage Table) which contains the entries for dynamically linked libraries..

Tecnique ID: 1 - Environment(s) env-Local

The attacker uses a tool such as the OSX "otool" utility or manually probes whether the target application uses dynamically linked libraries.

Tecnique ID: 2 - Environment(s) env-Local

The attacker finds the configuration files containing the entries to the dynamically linked libraries and modifies the entries to point to the malicious libraries the attacker crafted.

Indicator ID: 1 - Environment(s) env-Local

Type: Positive

The target application uses dynamically linked libraries.

Indicator ID: 2 - Environment(s) env-Local

Type: Positive

The attacker can redirect or control access to files in areas leveraged by the target.

Indicator ID: 3 - Environment(s) env-Local

Type: Positive

The attacker can modify the entries in the configuration files to the libraries the attacker crafted.

Indicator ID: 4 - Environment(s) env-Local

Type: Inconclusive

The attacker cannot modify the configuration files entries. The attacker may still be able to redirect access to libraries using other techniques such as using symbolic links.

Indicator ID: 5 - Environment(s) env-Local

Type: Negative

The application does not use dynamically linked libraries.


Security Control ID: 1

Type: Preventative

Restrict the permission to modify the entries in the configuration file.


Outcome ID: 1

Type: Success

The attacker can successfully redirect or control access to libraries leveraged by the target.

Outcome ID: 2

Type: Success

The attacker identifies and gains control of the configuration file containing entries of a list of dynamically linked libraries and be able to modify the entry to point to the malicious libraries the attacker created.



Step 1 - Craft malicious libraries

The attacker uses knowledge gained in the Explore phase to craft malicious libraries that he will redirect the target to leverage. These malicious libraries could have the same APIs as the legitimate library and additional malicious code..

Tecnique ID: 1 - Environment(s) env-Local

The attacker monitors the file operations performed by the target application using a tool like dtrace or FileMon. And the attacker can delay the operations by using "sleep(2)" and "usleep()" to prepare the appropriate conditions for the attack, or make the application perform expansive tasks (large files parsing, etc.) depending on the purpose of the application.

Security Control ID: 1

Type: Preventative

Restrict the permission to modify the entries in the configuration file.

Security Control ID: 2

Type: Preventative

If possible, use obfuscation and other techniques to prevent reverse engineering the libraries.


Outcome ID: 1

Type: Success

The entries in the configuration file points to the malicious libraries he crafted.



Step 1 - Redirect the access to libraries to the malicious libraries

The attacker redirects the target to the malicious libraries he crafted in the Experiment phase. The attacker will be able to force the targeted application to execute arbitrary code when the application attempts to access the legitimate libraries..

Tecnique ID: 1 - Environment(s) env-Local

The attacker modifies the entries in the configuration files pointing to the malicious libraries he crafted.

Tecnique ID: 2 - Environment(s) env-Local

The attacker leverages symlink/timing issues to redirect the target to access the malicious libraries he crafted.

Tecnique ID: 3 - Environment(s) env-Local

The attacker leverages file search path order issues to redirect the target to access the malicious libraries he crafted.

Security Control ID: 1

Type: Preventative

Restrict the permission to modify the entries in the configuration file.

Security Control ID: 2

Type: Preventative

Check the integrity of the dynamically linked libraries before using them.

Security Control ID: 3

Type: Preventative

If possible, use obfuscation and other techniques to prevent reverse engineering the libraries.


Outcome ID: 1

Type: Success

The application is redirected to the malicious libraries the attacker crafted when the application attempts to call the legitimate libraries.



Implementation: Restrict the permission to modify the entries in the configuration file.

Implementation: Check the integrity of the dynamically linked libraries before use them.

Implementation: Use obfuscation and other techniques to prevent reverse engineering the libraries.