# Missing Access Restriction on Directory Listing

## Overview

* **Rule ID**: `javascript_express_exposed_dir_listing`
* **Applicable Languages**: Javascript
* **Weakness ID**: CWE-548

## Description

Exposing a directory listing without restrictions can lead to unauthorized access to sensitive data or source code. This vulnerability occurs when the file structure of a server or application is made visible to users without proper access control, potentially allowing attackers to exploit the exposed files.

## Remediation Guidelines

* **Restrict access** to sensitive directories and files to prevent unauthorized access. Implementing access controls ensures that only authorized users can view or interact with specific file directories.

## References

* [**Express Serve index middleware**](https://expressjs.com/en/resources/middleware/serve-index.html)
* [**CWE-548: Exposure of Information Through Directory Listing**](https://cwe.mitre.org/data/definitions/548.html)
* [**OWASP Top 10: A01:2021 - Broken Access Control**](https://owasp.org/Top10/A01_2021-Broken_Access_Control/)

## Configuration

To omit this rule during a scan, and to provide you with continuous 24/7 code-level scanning, you can employ our [**SAST TOOL**](https://scopy.sec1.io/login)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sec1.io/user-docs/4-sast/3-javascript/missing-access-restriction-on-directory-listing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
