Home > CAPEC List > CAPEC-127: Directory Indexing (Version 2.9)  

CAPEC-127: Directory Indexing

 
Directory Indexing
Definition in a New Window Definition in a New Window
Attack Pattern ID: 127
Abstraction: Detailed
Status: Draft
Completeness: Complete
Presentation Filter:
+ Summary

An adversary crafts a request to a target that results in the target listing/indexing the content of a directory as output. One common method of triggering directory contents as output is to construct a request containing a path that terminates in a directory name rather than a file name since many applications are configured to provide a list of the directory's contents when such a request is received. An adversary can use this to explore the directory tree on a target as well as learn the names of files. This can often end up revealing test files, backup files, temporary files, hidden files, configuration files, user accounts, script contents, as well as naming conventions, all of which can be used by an attacker to mount additional attacks.

+ Attack Execution Flow
Explore
  1. Directory Discovery:

    Use a method, either manual, scripted, or automated to discover the directories on the server by making requests for directories that may possibly exist. During this phase the adversary is less concerned with whether a directory can be accessed or indexed and more focused on simply discovering what directories do exist on the target.

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    Send requests to the web server for common directory names

    env-Web
    2

    If directories are discovered that are native to a server type further refine the directory search to include directories usually present on those types of servers.

    env-All
    3

    Search for uncommon or potentially user created directories that may be present.

    env-Web

    Indicators

    IDTypeIndicator DescriptionEnvironments
    1Positive

    ACLs or other access control mechanisms are present in the application or server configuration that indicate the existence of the directory but the attacker lacks the proper authorization to access the directory (HTTP Status Code 401)

    env-Web env-ClientServer
    2Positive

    ACLs or other access control mechanisms are present in the application or server configuration that indicate the existence of the directory, but access is forbidden and authorization will not help. (HTTP Status Code 403)

    env-Web env-ClientServer
    3Positive

    The directory exists and can be accessed. HTTP Status Code 200 is the standard code for a successful request

    env-Web
    4Inconclusive

    The directory may or may not exist because the server is redirecting the user to another location. HTTP Status codes 301 or 302 indicate the server configuration is redirecting the user to some other page or directory. It cannot be automatically assumed that the location to which the attacker is redirected is the requested directory located elsewhere.

    env-Web

    Outcomes

    IDTypeOutcome Description
    1Success
    The adversary compiles a list of one or more directories that exist on the server. Some of these directories may not be immediately accessible but they are present.

    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).
    2Preventative
    Block access to the directory listing by setting access control in the .htaccess file.
    3Preventative
    Actively monitor the application and either deny or redirect requests from origins that appear to be automated.
Experiment
  1. Iteratively explore directory/file structures:

    The adversary attempts to access the discovered directories that allow access and may attempt to bypass server or application level ACLs by using manual or automated methods

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    Use a scanner tool to dynamically add directories/files to include their scan based upon data obtained in initial probes.

    env-Web
    2

    Use a browser to manually explore the website by issuing a request ending the URL in a slash '/'.

    env-Web
    3

    Attempt to bypass ACLs on directories by using methods that known to work against some server types by appending data to the directory request. For instance, appending a Null byte to the end of the request which may cause an ACL to fail and allow access.

    env-Web
    4

    Sequentially request a list of common base files to each directory discovered.

    env-Web
    5

    Try multiple fuzzing techniques to list directory contents for directories that will not reveal their contents with a "/" request

    env-Web

    Indicators

    IDTypeIndicator DescriptionEnvironments
    1Positive

    There are no normal base files (index.html /home.html /default.html /default.asp /default.asp / index.php) at present

    env-Web
    2Positive

    "File not found" error messages along with invalid path name.

    env-Web
    3Inconclusive

    The website automatically redirects to the base file. Note that the attacker may still be able to explore the directory listings.

    env-Web
    4Negative

    Error 403 Forbidden message displays. The access to directory indexing is blocked by the web server.

    env-Web

    Outcomes

    IDTypeOutcome Description
    1Success
    A list of files within a requested directory.
    2Success
    A "File not found" error messages along with invalid path name.
    3Success
    The directory index page shows that there are some sub-directories or files available in the current directory

    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).
    2Preventative
    Block access to the directory listing by setting access control in the .htaccess file.
    3Preventative
    Automatically redirects to the base file if the request has not given specific filename.
Exploit
  1. Read directories or files which are not intended for public viewing.:

    The adversary attempts to access the discovered directories that allow access and may attempt to bypass server or application level ACLs by using manual or automated methods

    Attack Step Techniques

    IDAttack Step Technique DescriptionEnvironments
    1

    Try multiple exploit techniques to list directory contents for directories that will not reveal their contents with a "/" request

    env-Web
    2

    Try other known exploits to elevate privileges sufficient to bypass protected directories.

    env-All
    3

    List the files in the directory by issuing a request with the URL ending in a "/" slash.

    env-Web
    4

    Access the files via direct URL and capture contents.

    env-Web
    5

    Attempt to bypass ACLs on directories by using methods that are known to work against some server types by appending data to the directory request. For instance, appending a Null byte to the end of the request which may cause an ACL to fail and allow access.

    env-Web
    6

    Sequentially request a list of common base files to each directory discovered.

    env-Web

    Indicators

    IDTypeIndicator DescriptionEnvironments
    1Positive

    A request for the directory name yields a directory listing

    env-All
    2Positive

    Either an application or server exploit yields a directory listing

    env-All
    3Negative

    Errors 401 or 403 indicate access to directory indexing is blocked by the web server and all methods tried have yielded no success to bypass the ACL or elevate the adversary's privileges.

    env-All

    Outcomes

    IDTypeOutcome Description
    1Success
    Directory contents are accessible to the attacker.

    Security Controls

    IDTypeSecurity Control Description
    1Detective
    Monitor server logs for unintended file or directory access.
    2Detective
    Monitor errors (e.g., 404, 401, 403) from web servers, application servers and generate an alert on a disproportionate number of HTTP errors.
    3Detective
    Identify platform and application-specific sensitive directories and generate logs and alerts for any requests to these resources. Setup ACLs as your operating system, application, and server permit. Consult your server or application documentation for the proper procedure.
    4Preventative
    Automatically redirect to the base file (such as index.html) for the requests without given specific file name.
    5Preventative
    Not allow access to the sensitive files (such as DB dump data) directly.
    6Preventative
    Monitor the volume of failed requests and either deny or redirect requests that appear to be generated by a bot, script, or some other form of scanning tool.
    7Corrective
    Obtain a list of sensitive areas that should not be directly accessible based on your application and server type. Use an external protection device such as a filtering proxy, packet scrubbing load balancer, etc., and frequently update the list of protected areas.
+ Attack Prerequisites
  • The target must be misconfigured to return a list of a directory's content when it receives a request that ends in a directory name rather than a file name.

  • The adversary must be able to control the path that is requested of the target.

  • The administrator must have failed to properly configure an ACL or has associated an overly permissive ACL with a particular directory.

  • The server version or patch level must not inherently prevent known directory listing attacks from working.

+ Typical Severity

Medium

+ Typical Likelihood of Exploit

Likelihood: High

+ Methods of Attack
  • Brute Force
  • API Abuse
+ Examples-Instances

Description

In this example, the adversary uses directory listing to view sensitive files in the application. This is an example of accessing the backup file. The attack issues a request for http://www.example.com/admin/ and receives the following dynamic directory indexing content in the response: Index of /admin Name Last Modified Size Description backup/ 31-May-2007 08:18 - Apache/ 2.0.55 Server at www.example.com Port 80

The target application does not have direct hyperlink to the "backup" directory in the normal html webpage, however the attacker has learned of this directory due to indexing the content. The client then requests the backup directory URL and receives output which has a "db_dump.php" file in it. This sensitive data should not be disclosed publicly.

+ Attacker Skills or Knowledge Required

Skill or Knowledge Level: Low

To issue the request to URL without given a specific file name

Skill or Knowledge Level: High

To bypass the access control of the directory of listings

+ Resources Required

Ability to send HTTP requests to a web application.

+ Solutions and Mitigations

1. Using blank index.html: putting blank index.html simply prevent directory listings from displaying to site visitors.

2. Preventing with .htaccess in Apache web server: In .htaccess, write "Options-indexes".

3. Suppressing error messages: using error 403 "Forbidden" message exactly like error 404 "Not Found" message.

+ Attack Motivation-Consequences
ScopeTechnical ImpactNote
Confidentiality
Read files or directories
Information Leakage
+ Relevant Security Requirements

All resources must be constrained to be inaccessible by default followed by selectively allowing access to resources as dictated by application and business logic

In addition to a central controller, every resource must also restrict, wherever possible, incoming accesses as dictated by the relevant ACL.

+ Purposes
  • Reconnaissance
  • Exploitation
  • Penetration
+ CIA Impact
Confidentiality Impact: HighIntegrity Impact: LowAvailability Impact: Low
+ Technical Context
Architectural Paradigms
Client-Server
n-Tier
Frameworks
All
Platforms
All
Languages
All
+ References
[R.127.1] [REF-1] "WASC Threat Classification 2.0". WASC-16 - Directory Indexing. The Web Application Security Consortium (WASC). 2010. <http://projects.webappsec.org/Directory-Indexing>.
[R.127.2] ATT&CK Project. "File system enumeration (1083)". MITRE. <https://attack.mitre.org/wiki/File_system_enumeration>.
+ Content History
Submissions
SubmitterOrganizationDateSource
CAPEC Content TeamThe MITRE Corporation2014-06-23Internal_CAPEC_Team
Modifications
ModifierOrganizationDateCommentsSource
CAPEC Content TeamThe MITRE Corporation2015-11-09Updated References, Related_Attack_PatternsInternal

More information is available — Please select a different filter.
Page Last Updated or Reviewed: December 07, 2015