Safeguard
Application Security•

CWE-43 Multiple Trailing Dot Path Equivalence

Stack several dots on the end of a path and some servers return a directory listing. A practical look at CWE-43 and its fixes.

Safeguard Security Team
3 min read

If one trailing dot can confuse a path check, several can too. CWE-43 covers input shaped like filedir.... accepted without appropriate validation, leading to ambiguous path resolution. It is a sibling of CWE-42, the single dot form, and sits under the general path equivalence class, CWE-41.

It matters for any server or application that makes a decision from the text of a path before the file system gets a chance to normalize it.

How it happens

A protection rule is written against a canonical name. The request arrives with extra dots appended. The rule compares strings and sees no match, so it neither blocks nor routes the request as intended. A later layer strips the dots, as some platforms do, and resolves to the protected object.

Sanitizers add a second way in. A filter that removes one trailing dot, or removes dots in a single pass, can be beaten by input with more of them. MITRE warns more generally against relying on filtering that removes dangerous characters, because it behaves like a denylist and can be incomplete.

The record has one example: multiple trailing dots allowed a directory listing (CVE-2004-0281). A directory listing is a quiet leak. It shows which files exist, including backups and old versions, and tells the attacker where to aim next.

// Vulnerable: strips exactly one trailing dot, once
String p = requested.endsWith(".") ? requested.substring(0, requested.length() - 1) : requested;
if (isProtected(p)) deny();
// "dir...." becomes "dir..." and is no longer matched

What an attacker gains

MITRE lists reading and modifying files and directories as the impact, so confidentiality and integrity are both in play. Directory listings and source disclosure are the typical first results.

How to find it

Test protected paths and directories with several trailing dots in a staging copy, and compare responses with the clean request. Include listings: ask for a directory with extra dots and see if an index appears.

How to fix it

  • Canonicalize with the platform API, then decide. Do not hand write the stripping.
  • Reject any name that ends in a dot or a space, rather than trying to clean it.
  • Turn off automatic directory listings unless they are required.
  • Apply least privilege on the file system so that a bypass still reveals little.
Path real = docRoot.resolve(requested).normalize();
if (requested.endsWith(".") || !real.startsWith(docRoot)) throw new SecurityException();
if (isProtected(real)) deny();

If the bug is in a web server you run rather than code you wrote, patching is the fix. The free scan at gold.safeguard.sh/scan checks a dependency file in your browser, no login.

Quick check

Why is stripping one dot not enough?

The attacker can add more. Single pass cleanup leaves residual dots and the mismatch remains. Reject the form or canonicalize through the platform API.

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.