Safeguard
Application Security•

CWE-163 Multiple Trailing Special Elements: Directory Listings

Many trailing slashes or dots can make a server list a directory it should hide. How CWE-163 works and how to normalize paths to stop it.

Safeguard Security Team
2 min read

CWE-163 covers input with several special elements in a row at the end, handled in ways the author did not expect. The observed cases involve piles of trailing slashes or dots on a web request.

Web servers and any code that decides what to show based on how a path ends should care. MITRE lists the weakness as not language specific and not technology specific.

How it happens

A server decides whether to serve an index file, show a listing or refuse based on the end of the path. Extra trailing elements push the path out of the case the rule covers, and the fallback behavior is more generous.

Two observed examples show it. CVE-2002-1078 gives directory listings in a web server using multiple trailing slashes. CVE-2004-0281 gives directory listings with multiple trailing dots.

What an attacker gains

MITRE lists integrity impact as unexpected state. In these cases it meant seeing the names of files in a directory, which helps an attacker find backups, configs and other things to request next.

How to find it

No detection methods are listed. Request each directory with extra trailing slashes and dots, and compare the output with the normal request. A listing where there should be a refusal is the finding.

How to fix it

  1. Anticipate that multiple trailing special elements will be injected or manipulated.
  2. Normalize paths so repeated separators and trailing dots collapse before any decision is made.
  3. Turn directory listing off unless a route needs it, and deny by default.
  4. Use an allowlist of valid inputs and reject the rest.

Quick check

What is the difference from CWE-162?

CWE-162 is about a single trailing element. This one is about many in a row, which can slip past rules that only handle one.

Sources

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.