CWE-73: External Control of File Name or Path | Codefreex Skip to content

Security weakness

CWE-73 External Control of File Name or Path

A base-level weakness that can lead to private data exposed, data, pages or code changed and downtime and lost sales. Here is what it is, what it can cost you and how to close it.

  • Senior security engineers
  • 540+ projects delivered
  • Reply within one business day

Quick answer

What is CWE-73?

External Control of File Name or Path: The product allows user input to control or influence paths or file names that are used in filesystem operations.

Business impact

What CWE-73 could cost your business

MITRE documents what this weakness can do. Here is what that means for a website, store or app.

Confidentiality

Private data exposed

Customer records, credentials, orders or internal files can be read by people who should never see them.

  • Read Files or Directories
  • Modify Files or Directories
  • Execute Unauthorized Code or Commands

Integrity

Data, pages or code changed

Prices, orders, content or the code your site runs can be altered without your approval.

  • Read Files or Directories
  • Modify Files or Directories
  • Execute Unauthorized Code or Commands

Availability

Downtime and lost sales

Crashes, slowdowns or exhausted resources can take your site, store or app offline.

  • Modify Files or Directories
  • Execute Unauthorized Code or Commands
  • DoS: Crash, Exit, or Restart

Free security check

Is CWE-73 hiding in your site?

A senior engineer checks your site, store or app for this weakness and the rest of the CWE Top 25, then sends a prioritized fix plan within one business day. No obligation.

Official definition

How MITRE defines CWE-73

External Control of File Name or Path

The product allows user input to control or influence paths or file names that are used in filesystem operations.

Weakness ID
CWE-73
Type
Base
Status
Draft
Likelihood of exploit
High
Applies to
Unix, Windows, macOS
Introduced during
Architecture and Design, Implementation

Prevention

How to fix CWE-73, phase by phase

Every mitigation from the CWE entry, in the order a project runs: plan, build, test, operate.

  1. 01

    Architecture and Design

    • When the set of filenames is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames, and reject all other inputs. For example, ID 1 could map to "inbox.txt" and ID 2 could map to "profile.txt". Features such as the ESAPI AccessReferenceMap provide this capability.
    • Run your code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict all access to files within a particular directory. Examples include the Unix chroot jail and AppArmor. In general, managed code may provide some protection. This may not be a feasible solution, and it only limits.
    • For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the.
  2. 02

    Implementation

    • Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does. When performing input validation, consider all potentially relevant properties, including length, type of.
    • Use a built-in path canonicalization function (such as realpath() in C) that produces the canonical version of the pathname, which effectively removes ".." sequences and symbolic links (CWE-23, CWE-59).
    • If you are using PHP, configure your application so that it does not use register_globals. During implementation, develop your application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.
  3. 03

    Testing

    • Use tools and techniques that require manual (human) analysis, such as penetration testing, threat modeling, and interactive tools that allow the tester to record and modify an active session. These may be more effective than strictly automated techniques. This is especially the case with weaknesses that are related to design and business rules.
  4. 04

    Installation

    • Use OS-level permissions and run as a low-privileged user to limit the scope of any successful attack.

Detection and evidence

How CWE-73 is found, and where it has hit

The testing methods MITRE recommends, and real vulnerabilities this weakness has caused.

How it is detected

  • Automated Static AnalysisThe external control or influence of filenames can often be detected using automated static analysis that models data flow within the product. Automated static analysis might not be able to recognize when proper input validation is being performed, leading to false positives – i.e., warnings that do.

Real vulnerabilities it caused

  • CVE-2022-45918Chain: a learning management tool debugger uses external input to locate previous session logs (CWE-73) and does not properly validate the given path (CWE-20), allowing for filesystem path traversal using "../" sequences.
  • CVE-2008-5748Chain: external control of values for user’s desired language and theme enables path traversal.
  • CVE-2008-5764Chain: external control of user’s target language enables remote file inclusion.

How we fix it

From finding to fixed: how Codefreex closes CWE-73

  1. Scan and confirm

    We test your site, store or app for this weakness and the rest of the CWE Top 25 with automated scanning and manual review, and confirm what is actually exploitable.

  2. Fix at the source

    We change the code, configuration or dependency that causes it, not just the symptom, and plan the changes to avoid downtime.

  3. Verify the fix

    We retest every finding, check that nothing else broke and hand you a short report you can share with your team, client or auditor.

  4. Keep it fixed

    Updates, monitoring and maintenance so the weakness does not return with the next plugin, theme, app or code change.

FAQ

CWE-73: FAQs

Short answers for owners and developers. Not sure whether your site is affected? Ask us to check.

What is CWE-73?

CWE-73, “External Control of File Name or Path”, is a software weakness catalogued by MITRE in the Common Weakness Enumeration. The product allows user input to control or influence paths or file names that are used in filesystem operations.

How serious is CWE-73?

MITRE rates the likelihood of exploit as High. It can affect integrity, confidentiality, availability, with impacts such as read files or directories, modify files or directories, execute unauthorized code or commands. The real risk depends on where the weakness sits and what data or functions it exposes.

How do you prevent CWE-73?

When the set of filenames is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames, and reject all other inputs. For example, ID 1 could map to “inbox.txt” and ID 2 could map to “profile.txt”. Run your code in a “jail” or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict all access to files within a.

Can Codefreex check my site for CWE-73?

Yes. A senior engineer reviews your site, store or app for CWE-73 and the rest of the CWE Top 25, confirms what is exploitable and sends a prioritized fix plan within one business day. Start with the free security check form on this page.

Which technologies does CWE-73 affect?

MITRE lists it as applicable to Unix, Windows, macOS. In practice any software that matches the weakness description can be affected, including custom code, plugins, themes and third-party libraries.

Free security check

Find out if CWE-73 affects your site

Send your URL. A senior engineer checks for this weakness and the rest of the CWE Top 25, and replies within one business day with what to fix first.

  • A senior strategist reviews your request, not a sales bot
  • Clear scope, timeline and estimate within one business day
  • Free 30-minute discovery call, no obligation
  • NDA available on request

Weakness data from the Common Weakness Enumeration (CWE®) version 5.0, Copyright © 2006–2026, The MITRE Corporation. CWE is free to use by any organization or individual for any research, development, and/or commercial purposes under the CWE Terms of Use. CWE is a registered trademark of The MITRE Corporation. The business impact, risk profile and plain-English guidance on this page are written by Codefreex and are general information, not a security assessment of your system.