CAPEC-127 - Directory Indexing

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.

Severity

Likelihood

Confidentiality

Integrity

Availability

  • Attack Methods 2
  • Brute Force
  • API Abuse
  • Purposes 3
  • Reconnaissance
  • Exploitation
  • Penetration
  • Sec Principles 4
  • Failing Securely
  • Least Privilege
  • Reluctance To Trust
  • Complete Mediation
  • Scopes 1
  • Read files or directories
  • Confidentiality

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

High level: To bypass the access control of the directory of listings

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.

Ability to send HTTP requests to a web application.

Use Authorization Mechanisms Correctly

Design Configuration Subsystems Correctly and Distribute Safe Default Configurations

Step 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..

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

Send requests to the web server for common directory names

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

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.

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

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

Indicator ID: 1 - Environment(s) env-Web env-ClientServer

Type: Positive

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)

Indicator ID: 2 - Environment(s) env-Web env-ClientServer

Type: Positive

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)

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

Type: Positive

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

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

Type: Inconclusive

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.


Security Control ID: 1

Type: Detective

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).

Security Control ID: 2

Type: Preventative

Block access to the directory listing by setting access control in the .htaccess file.

Security Control ID: 3

Type: Preventative

Actively monitor the application and either deny or redirect requests from origins that appear to be automated.


Outcome ID: 1

Type: Success

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.



Step 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.

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

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

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

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

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

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.

Tecnique ID: 4 - Environment(s) env-Web

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

Tecnique ID: 5 - Environment(s) env-Web

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

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

Type: Positive

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

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

Type: Positive

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

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

Type: Inconclusive

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

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

Type: Negative

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


Security Control ID: 1

Type: Detective

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).

Security Control ID: 2

Type: Preventative

Block access to the directory listing by setting access control in the .htaccess file.

Security Control ID: 3

Type: Preventative

Automatically redirects to the base file if the request has not given specific filename.


Outcome ID: 1

Type: Success

A list of files within a requested directory.

Outcome ID: 2

Type: Success

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

Outcome ID: 3

Type: Success

The directory index page shows that there are some sub-directories or files available in the current directory



Step 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.

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

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

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

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

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

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

Tecnique ID: 4 - Environment(s) env-Web

Access the files via direct URL and capture contents.

Tecnique ID: 5 - Environment(s) env-Web

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.

Tecnique ID: 6 - Environment(s) env-Web

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

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

Type: Positive

A request for the directory name yields a directory listing

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

Type: Positive

Either an application or server exploit yields a directory listing

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

Type: Negative

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.


Security Control ID: 1

Type: Detective

Monitor server logs for unintended file or directory access.

Security Control ID: 2

Type: Detective

Monitor errors (e.g., 404, 401, 403) from web servers, application servers and generate an alert on a disproportionate number of HTTP errors.

Security Control ID: 3

Type: Detective

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.

Security Control ID: 4

Type: Preventative

Automatically redirect to the base file (such as index.html) for the requests without given specific file name.

Security Control ID: 5

Type: Preventative

Not allow access to the sensitive files (such as DB dump data) directly.

Security Control ID: 6

Type: Preventative

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.

Security Control ID: 7

Type: Corrective

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.


Outcome ID: 1

Type: Success

Directory contents are accessible to the attacker.



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.

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.