logo

Database

Config Files Directory Browsing Enabled

Description

Directory browsing allows attackers to view the contents and structure of web application directories when enabled in ASP.NET configurations. This can expose sensitive files, application structure, and other information that aids in attacking the application.

Weakness:

125 - Directory listing

Category: Information Collection

Detection Strategy

    Search web.config files for directory browsing configurations

    Check for <directoryBrowse> XML tags where enabled='true'

    Report vulnerability when directory browsing is explicitly enabled

Vulnerable code example

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <!-- SECURITY RISK: Enabling directory browsing exposes file listing to unauthorized users -->
    <directoryBrowse enabled="true" />
  </system.webServer>
</configuration>

✅ Secure code example

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <!-- Directory browsing disabled to prevent unauthorized file/folder enumeration -->
    <directoryBrowse enabled="false" />
    
    <!-- Define default documents to serve when directory is accessed -->
    <defaultDocument>...