Manipulating Input to File System Calls
Attack Pattern ID: 76 (Standard Attack Pattern Completeness: Complete)Typical Severity: Very HighStatus: Draft
+ Description

Summary

An attacker manipulates inputs to the target software which the target software passes to file system calls in the OS. The goal is to gain access to, and perhaps modify, areas of the file system that the target software did not intend to be accessible.

Attack Execution Flow

Explore
  1. Fingerprinting of the operating system:

    In order to create a valid file injection, the attacker needs to know what the underlying OS is.

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    Port mapping. Identify ports that the system is listening on, and attempt to identify inputs and protocol types on those ports.

    env-Local env-CommProtocol env-Peer2Peer env-ClientServer
    2

    TCP/IP Fingerprinting. The attacker uses various software to make connections or partial connections and observe idiosyncratic responses from the operating system. Using those responses, he attempts to guess the actual operating system.

    env-Embedded env-CommProtocol env-Peer2Peer env-ClientServer env-Web
    3

    Induce errors to find informative error messages

    env-All

    Indicators

    IDtypeIndicator DescriptionEnvironments
    1Positive

    The target software accepts connections via the network.

    env-Embedded env-CommProtocol env-Peer2Peer env-ClientServer env-Web

    Outcomes

    IDtypeOutcome Description
    1Success
    Operating environment (operating system, language, and/or middleware) is correctly identified.
    2Inconclusive
    Multiple candidate operating environments are suggested.

    Security Controls

    IDtypeSecurity Control Description
    1Preventative
    Provide misleading information on TCIP/IP fingerprints (some operating systems can be configured to send signatures that match other operating systems).
    2Preventative
    Provide misleading information at the server level (e.g., Apache, IIS, WebLogic, etc.) to announce a different server software.
    3Detective
    Some fingerprinting techniques can be detected by operating systems or by network IDS systems because they leave the network connection half-open, or they do not belong to a valid, open connection.
  2. Survey the Application to Identify User-controllable Inputs:

    The attacker surveys the target application to identify all user-controllable inputs, possibly as a valid and authenticated user

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    Spider web sites for all available links, entry points to the web site.

    env-Web
    2

    Manually explore application and inventory all application inputs

    env-All

    Outcomes

    IDtypeOutcome Description
    1Success
    The attacker develops a list of likely interesting path (application or OS related)

    Security Controls

    IDtypeSecurity Control Description
    1Detective
    Monitor velocity of page fetching in web logs. Humans who view a page and select a link from it will click far slower and far less regularly than tools. Tools make requests very quickly and the requests are typically spaced apart regularly (e.g. 0.8 seconds between them).
    2Detective
    Create links on some pages that are visually hidden from web browsers. Using IFRAMES, images, or other HTML techniques, the links can be hidden from web browsing humans, but visible to spiders and programs. A request for the page, then, becomes a good predictor of an automated tool probing the application.
    3Preventative
    Actively monitor the application and either deny or redirect requests from origins that appear to be automated.
    4Detective
    Monitor velocity of feature activations (non-web software). Humans who activate features (click buttons, request actions, invoke APIs, etc.) will do so far slower and far less regularly than tools. Tools make requests very quickly and the requests are typically spaced apart regularly (e.g. 0.8 seconds between them).
Experiment
  1. Vary inputs, looking for malicious results:

    Depending on whether the application being exploited is a remote or local one the attacker crafts the appropriate malicious input containing the path of the targeted file or other file system control syntax to be passed to the application

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    SecurityDatabase\Alert\Inject context-appropriate malicious file path using network packet injection tools (netcat, nemesis, etc.)

    env-CommProtocol env-Web env-Peer2Peer env-ClientServer
    2

    SecurityDatabase\Alert\Inject context-appropriate malicious file path using web test frameworks (proxies, TamperData, custom programs, etc.) or simple HTTP requests

    env-Web
    3

    SecurityDatabase\Alert\Inject context-appropriate malicious file system control syntax

    env-CommProtocol env-Web env-Peer2Peer env-ClientServer

    Indicators

    IDtypeIndicator DescriptionEnvironments
    1Positive

    Inventorying in prior step is successful.

    env-All

    Outcomes

    IDtypeOutcome Description
    1Success
    One or more injections that are appropriate to the platform provoke an unexpected response from the software, which can be varied by the attacker based on the input.
Exploit
  1. Manipulate files accessible by the application:

    The attacker may steal information or directly manipulate files (delete, copy, flush, etc.)

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    The attacker injects context-appropriate malicious file path to access the content of the targeted file.

    env-All
    2

    The attacker injects context-appropriate malicious file system control syntax to access the content of the targeted file.

    env-All
    3

    The attacker injects context-appropriate malicious file path to cause the application to create, delete a targeted file.

    env-All
    4

    The attacker injects context-appropriate malicious file system control syntax to cause the application to create, delete a targeted file.

    env-All
    5

    The attacker injects context-appropriate malicious file path in order to manipulate the meta-data of the targeted file.

    env-All
    6

    The attacker injects context-appropriate malicious file system control syntax in order to manipulate the meta-data of the targeted file.

    env-All

    Outcomes

    IDtypeOutcome Description
    1Success
    The software performs an action the attacker desires. This might be displaying information, storing information in a file, delete a file or some other malicious activity.

    Security Controls

    IDtypeSecurity Control Description
    1Detective
    Use a system that logs file modification and/or access.
    2Preventative
    Make the application run in a low-privileged mode to prevent such attack to access important files.
+ Attack Prerequisites

Program must allow for user controlled variables to be applied directly to the filesystem

+ Typical Likelihood of Exploit

Likelihood: High

+ Methods of Attack
  • Injection
  • API Abuse
  • Modification of Resources
+ Examples-Instances

Description

An example of using path traversal to attack some set of resources on a web server is to use a standard HTTP request

http://example/../../../../../etc/passwd

From an attacker point of view, this may be sufficient to gain access to the password file on a poorly protected system. If the attacker can list directories of critical resources then read only access is not sufficient to protect the system.

+ Attacker Skills or Knowledge Required

Skill or Knowledge Level: Low

To identify file system entry point and execute against an overprivileged system interface

+ Solutions and Mitigations

Design: Enforce principle of least privilege.

Design: Ensure all input is validated, and does not contain file system commands

Design: Run server interfaces with a non-root account and/or utilize chroot jails or other configuration techniques to constrain privileges even if attacker gains some limited access to commands.

Design: For interactive user applications, consider if direct file system interface is necessary, instead consider having the application proxy communication.

Implementation: Perform testing such as pentesting and vulnerability scanning to identify directories, programs, and interfaces that grant direct access to executables.

+ Attack Motivation-Consequences
  • Privilege Escalation
  • Data Modification
+ Injection Vector

Payload delivered through standard communication protocols and inputs.

+ Payload

File system commands and specifiers

+ Activation Zone

File system

+ Payload Activation Impact

File access or modification.

+ Related Weaknesses
CWE-IDWeakness NameWeakness Relationship Type
23Relative Path TraversalTargeted
22Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')Targeted
73External Control of File Name or PathTargeted
77Improper Sanitization of Special Elements used in a Command ('Command Injection')Targeted
346Origin Validation ErrorTargeted
348Use of Less Trusted SourceTargeted
285Improper Access Control (Authorization)Secondary
264Permissions, Privileges, and Access ControlsSecondary
272Least Privilege ViolationTargeted
59Improper Link Resolution Before File Access ('Link Following')Targeted
74Failure to Sanitize Data into a Different Plane ('Injection')Targeted
15External Control of System or Configuration SettingTargeted
715OWASP Top Ten 2007 Category A4 - Insecure Direct Object ReferenceTargeted
+ Related Attack Patterns
NatureTypeIDNameDescriptionView(s) this relationship pertains toView\(s\)
ChildOfAttack PatternAttack Pattern13Subverting Environment Variable Values 
Mechanism of Attack1000
ChildOfAttack PatternAttack Pattern137Parameter Injection 
Mechanism of Attack (primary)1000
ChildOfAttack PatternAttack Pattern171Variable Manipulation 
Mechanism of Attack (primary)1000
+ Purposes
  • Exploitation
+ CIA Impact
Confidentiality Impact: HighIntegrity Impact: HighAvailability Impact: Medium
+ Technical Context
Architectural Paradigms
All
Frameworks
All
Platforms
All
Languages
All
+ References
G. Hoglund and G. McGraw. "Exploiting Software: How to Break Code". Addison-Wesley. February 2004.
+ Content History
Submissions
SubmitterOrganizationDate
G. Hoglund and G. McGraw. Exploiting Software: How to Break Code. Addison-Wesley, February 2004.Cigital, Inc2007-01-01
Modifications
ModifierOrganizationDateComments
Gunnar PetersonCigital, Inc2007-02-28Fleshed out content to CAPEC schema from the original descriptions in "Exploiting Software"
Sean BarnumCigital, Inc2007-03-09Review and revise
Richard StruseVOXEM, Inc2007-03-26Review and feedback leading to changes in Name and Description
Sean BarnumCigital, Inc2007-04-16Modified pattern content according to review and feedback
Romain GaucherCigital, Inc2009-02-10Created draft content for detailed description
Sean BarnumCigital Federal, Inc2009-04-13Reviewed and revised content for detailed description