CWE-22
Weakness Allowed-with-ReviewImproper Limitation of a Pathname to a Restricted Directory
Abstraction: Base · Status: Stable
The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.
Many file operations are intended to take place within a restricted directory. By using special elements such as ".." and "/" separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the "../" sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as "/usr/local/bin" to access unexpected files. This is referred to as absolute path traversal.
Mapping guidance
This CWE entry might have children that would be more appropriate.
Examine children of this entry to see if there is a better fit. Consider children such as CWE-23 (or its descendants) for relative path traversal, or CWE-36 for absolute path traversal.
Relationships and members
Modes of introduction
Detection methods
Automated Static Analysis
Automated techniques can find areas where path traversal weaknesses exist. However, tuning or customization may be required to remove or de-prioritize path-traversal problems that are only exploitable by the product's administrator - or other privileged users - and thus potentially valid behavior or, at worst, a bug instead of a vulnerability.
Effectiveness: High
Manual Static Analysis
Manual white box techniques may be able to provide sufficient code coverage and reduction of false positives if all file access operations can be assessed within limited time constraints.
Effectiveness: High
Automated Static Analysis - Binary or Bytecode
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Bytecode Weakness Analysis - including disassembler + source code weakness analysis
Cost effective for partial coverage:
Binary Weakness Analysis - including disassembler + source code weakness analysis
Effectiveness: High
Manual Static Analysis - Binary or Bytecode
According to SOAR [REF-1479], the following detection techniques may be useful:
Cost effective for partial coverage:
Binary / Bytecode disassembler - then use manual analysis for vulnerabilities & anomalies
Effectiveness: SOAR Partial
Dynamic Analysis with Automated Results Interpretation
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Web Application Scanner
Web Services Scanner
Database Scanners
Effectiveness: High
Dynamic Analysis with Manual Results Interpretation
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Fuzz Tester
Framework-based Fuzzer
Effectiveness: High
Manual Static Analysis - Source Code
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Manual Source Code Review (not inspections)
Cost effective for partial coverage:
Focused Manual Spotcheck - Focused manual analysis of source
Effectiveness: High
Automated Static Analysis - Source Code
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Source code Weakness Analyzer
Context-configured Source Code Weakness Analyzer
Effectiveness: High
Architecture or Design Review
According to SOAR [REF-1479], the following detection techniques may be useful:
Highly cost effective:
Formal Methods / Correct-By-Construction
Cost effective for partial coverage:
Inspection (IEEE 1028 standard) (can apply to requirements, design, source code, etc.)
Effectiveness: High
Notes
Other
In many programming languages, the injection of a null byte (the 0 or NUL) may allow an attacker to truncate a generated filename to apply to a wider range of files. For example, the product may add ".txt" to any pathname, thus limiting the attacker to text files, but a null injection may effectively remove this restriction.
Relationship
Pathname equivalence can be regarded as a type of canonicalization error.
Relationship
Some pathname equivalence issues are not directly related to directory traversal, rather are used to bypass security-relevant checks for whether a file/directory can be accessed by the attacker (e.g. a trailing "/" on a filename could bypass access rules that don't expect a trailing /, causing a server to provide the file when it normally would not).
Terminology
Like other weaknesses, terminology is often based on the types of manipulations used, instead of the underlying weaknesses. Some people use "directory traversal" only to refer to the injection of ".." and equivalent sequences whose specific meaning is to traverse directories.
Other variants like "absolute pathname" and "drive letter" have the *effect* of directory traversal, but some people may not call it such, since it doesn't involve ".." or equivalent.
Research Gap
Many variants of path traversal attacks are probably under-studied with respect to root cause. CWE-790 and CWE-182 begin to cover part of this gap.
Research Gap
Incomplete diagnosis or reporting of vulnerabilities can make it difficult to know which variant is affected. For example, a researcher might say that "..\" is vulnerable, but not test "../" which may also be vulnerable.
Any combination of directory separators ("/", "\", etc.) and numbers of "." (e.g. "....") can produce unique variants; for example, the "//../" variant is not listed (CVE-2004-0325). See this entry's children and lower-level descendants.
Content history
Identified weakness in Perl demonstrative example
Provided diagram to improve CWE usability
Identified weakness in "good code" for Python demonstrative example
Provided a demonstrative example in PHP
updated Potential_Mitigations, Time_of_Introduction
Suggested OWASP Top Ten 2004 mapping
updated Alternate_Terms, Relationships, Other_Notes, Relationship_Notes, Relevant_Properties, Taxonomy_Mappings, Weakness_Ordinalities
updated Description
updated Relationships, Taxonomy_Mappings
updated Potential_Mitigations
updated Alternate_Terms, Applicable_Platforms, Common_Consequences, Demonstrative_Examples, Description, Detection_Factors, Likelihood_of_Exploit, Name, Observed_Examples, Other_Notes, Potential_Mitigations, References, Related_Attack_Patterns, Relationship_Notes, Relationships, Research_Gaps, Taxonomy_Mappings, Terminology_Notes, Time_of_Introduction, Weakness_Ordinalities
updated Common_Consequences, Demonstrative_Examples, Description, Detection_Factors, Potential_Mitigations, References, Relationships
updated Potential_Mitigations
updated Potential_Mitigations
updated Potential_Mitigations
updated Relationships
updated Potential_Mitigations, References, Relationships, Taxonomy_Mappings
updated Demonstrative_Examples, References, Relationships
updated Potential_Mitigations
updated Observed_Examples
updated Related_Attack_Patterns, Relationships
updated Other_Notes, Research_Gaps
updated Detection_Factors, Relationships, Taxonomy_Mappings
updated Relationships
updated Related_Attack_Patterns
updated Demonstrative_Examples
updated Affected_Resources, Causal_Nature, Likelihood_of_Exploit, References, Relationships, Relevant_Properties, Taxonomy_Mappings
updated References, Relationships
updated References, Related_Attack_Patterns, Relationships, Taxonomy_Mappings
updated Related_Attack_Patterns, Relationships, Type
updated Relationships
updated Potential_Mitigations, Relationships
updated Demonstrative_Examples, Potential_Mitigations
updated Relationships
updated Potential_Mitigations, Relationships
updated Demonstrative_Examples, Relationships
updated Relationships
updated Observed_Examples, Relationships
updated Observed_Examples, Relationships
updated Observed_Examples, References
updated Common_Consequences, Description, Detection_Factors
updated Demonstrative_Examples, References, Relationships, Time_of_Introduction
updated Mapping_Notes, Relationships
updated Observed_Examples
updated Common_Consequences, Description, Diagram, Observed_Examples, Other_Notes, References
updated Demonstrative_Examples, Relationships
updated Relationships
updated Applicable_Platforms, Detection_Factors, Observed_Examples, Potential_Mitigations, References
updated Mapping_Notes, Relationships
updated Alternate_Terms, Applicable_Platforms, Demonstrative_Examples, Relationships
updated Applicable_Platforms, Common_Consequences, Name, References, Relationships, Taxonomy_Mappings
16185 vulnerabilities reference this CWE, most recent first.
GHSA-8289-X38R-723C
Vulnerability from github – Published: 2023-09-01 00:30 – Updated: 2024-01-01 06:30Zoho ManageEngine ADManager Plus through 7202 allows admin users to download any file from the server machine via directory traversal.
{
"affected": [],
"aliases": [
"CVE-2023-39912"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2023-08-31T23:15:26Z",
"severity": "MODERATE"
},
"details": "Zoho ManageEngine ADManager Plus through 7202 allows admin users to download any file from the server machine via directory traversal.",
"id": "GHSA-8289-x38r-723c",
"modified": "2024-01-01T06:30:40Z",
"published": "2023-09-01T00:30:41Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-39912"
},
{
"type": "WEB",
"url": "https://manageengine.com"
},
{
"type": "WEB",
"url": "https://www.manageengine.com/products/ad-manager/admanager-kb/cve-2023-39912.html"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-8298-7W39-FVV4
Vulnerability from github – Published: 2026-10-29 18:31 – Updated: 2026-10-29 18:31Improper limitation of a pathname to a restricted directory in Progress Software WS_FTP Server versions prior to 2024.0.7 and 2025.0.4 on Windows could allow an unauthenticated attacker to affect files outside the intended directory.
{
"affected": [],
"aliases": [
"CVE-2026-90871"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-10-29T16:20:05Z",
"severity": "MODERATE"
},
"details": "Improper limitation of a pathname to a restricted directory in Progress Software WS_FTP Server versions prior to 2024.0.7 and 2025.0.4 on Windows could allow an unauthenticated attacker to affect files outside the intended directory.",
"id": "GHSA-8298-7w39-fvv4",
"modified": "2026-10-29T18:31:07Z",
"published": "2026-10-29T18:31:07Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-90871"
},
{
"type": "WEB",
"url": "https://progress.lightning.force.com/lightning/r/Knowledge__kav/ka7Pb000001vl86IAA/view"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-82CG-3HV7-74GC
Vulnerability from github – Published: 2026-06-19 21:15 – Updated: 2026-06-19 21:15Summary
The built-in HTTP server started by allure serve and allure open is vulnerable to path traversal. The server resolves request URI paths directly against the report directory without normalizing or validating that the resolved path stays within the report directory. An attacker who can reach the server can read any file accessible to the Allure process by sending a request containing ../ sequences.
Details
When allure serve or allure open is executed, Commands.setUpServer() creates an HTTP server with a handler that serves files from the report directory:
allure-commandline/src/main/java/io/qameta/allure/Commands.java:325-339
protected HttpServer setUpServer(final String host, final int port, final Path reportDirectory) throws IOException {
final HttpServer server = HttpServer
.create(new InetSocketAddress(Objects.isNull(host) ? "localhost" : host, port), 0);
server.createContext("/", exchange -> {
final Path resolve = reportDirectory.resolve("." + exchange.getRequestURI().getPath()); // line 330
if (Files.isDirectory(resolve)) {
serveFile(exchange, resolve.resolve("index.html"));
} else {
serveFile(exchange, resolve);
}
});
return server;
}
On line 330, the handler constructs a file path by concatenating "." with the raw request URI path and resolving it against reportDirectory. For a request to /../../../etc/passwd:
exchange.getRequestURI().getPath()returns"/../../../etc/passwd"- String concatenation produces
"./../../../etc/passwd" reportDirectory.resolve("./../../../etc/passwd")resolves to e.g./tmp/allure-report/./../../../etc/passwd- The OS resolves this to
/etc/passwd
There is no call to .normalize() followed by a .startsWith(reportDirectory) containment check. The serveFile() method (line 341) reads and returns any regular file without further validation.
Additionally, URI.getPath() returns the percent-decoded path, so %2e%2e is decoded to .., enabling traversal via /%2e%2e/%2e%2e/etc/passwd which bypasses clients that normalize .. in raw form.
The server defaults to binding on localhost (line 327), which limits remote exploitation. However, the --host option allows users to bind to any interface (e.g., --host 0.0.0.0), which is commonly used in CI/CD and containerized environments. Even when bound to localhost, the vulnerability is exploitable by:
- Other local users on shared/multi-tenant systems
- DNS rebinding attacks from malicious web pages visited by the user
- Adjacent containers in CI/CD environments that share a network namespace
PoC
Step 1: Start the Allure server (simulating a typical CI/CD scenario with network binding):
allure serve ./test-results --host 0.0.0.0 --port 9090
Step 2: Read /etc/passwd via path traversal:
curl --path-as-is 'http://localhost:9090/../../../etc/passwd'
Step 3: Alternative using percent-encoded traversal (works even with clients that normalize ..):
curl 'http://localhost:9090/%2e%2e/%2e%2e/%2e%2e/etc/passwd'
Step 4: Read sensitive application files (e.g., environment variables, SSH keys):
curl --path-as-is 'http://localhost:9090/../../../home/user/.ssh/id_rsa'
curl --path-as-is 'http://localhost:9090/../../../proc/self/environ'
Each command returns the full contents of the requested file if readable by the Allure process.
Impact
An attacker who can reach the Allure HTTP server can read any file on the system that the Allure process has permissions to access. This includes:
- System credentials:
/etc/shadow(if running as root), SSH private keys, cloud provider credentials - Application secrets: Environment variables via
/proc/self/environ, configuration files, API keys - Source code and data: Any file on the filesystem accessible to the running user
In CI/CD environments where Allure is commonly used, this could expose build secrets, deployment credentials, and other sensitive CI/CD artifacts. The lack of authentication means any client that can reach the server's port can exploit this vulnerability.
Recommended Fix
Normalize the resolved path and verify it remains within the report directory before serving:
server.createContext("/", exchange -> {
final Path resolve = reportDirectory.resolve("." + exchange.getRequestURI().getPath()).normalize();
if (!resolve.startsWith(reportDirectory.normalize())) {
exchange.sendResponseHeaders(403, 0);
exchange.getResponseBody().close();
return;
}
if (Files.isDirectory(resolve)) {
serveFile(exchange, resolve.resolve("index.html"));
} else {
serveFile(exchange, resolve);
}
});
The .normalize() call collapses .. sequences, and the .startsWith() check ensures the resolved path is still within the report directory. Requests attempting traversal receive a 403 Forbidden response.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 2.38.1"
},
"package": {
"ecosystem": "Maven",
"name": "io.qameta.allure:allure-commandline"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "2.39.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-55846"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2026-06-19T21:15:50Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "## Summary\n\nThe built-in HTTP server started by `allure serve` and `allure open` is vulnerable to path traversal. The server resolves request URI paths directly against the report directory without normalizing or validating that the resolved path stays within the report directory. An attacker who can reach the server can read any file accessible to the Allure process by sending a request containing `../` sequences.\n\n## Details\n\nWhen `allure serve` or `allure open` is executed, `Commands.setUpServer()` creates an HTTP server with a handler that serves files from the report directory:\n\n**`allure-commandline/src/main/java/io/qameta/allure/Commands.java:325-339`**\n```java\nprotected HttpServer setUpServer(final String host, final int port, final Path reportDirectory) throws IOException {\n final HttpServer server = HttpServer\n .create(new InetSocketAddress(Objects.isNull(host) ? \"localhost\" : host, port), 0);\n\n server.createContext(\"/\", exchange -\u003e {\n final Path resolve = reportDirectory.resolve(\".\" + exchange.getRequestURI().getPath()); // line 330\n if (Files.isDirectory(resolve)) {\n serveFile(exchange, resolve.resolve(\"index.html\"));\n } else {\n serveFile(exchange, resolve);\n }\n });\n\n return server;\n}\n```\n\nOn line 330, the handler constructs a file path by concatenating `\".\"` with the raw request URI path and resolving it against `reportDirectory`. For a request to `/../../../etc/passwd`:\n\n1. `exchange.getRequestURI().getPath()` returns `\"/../../../etc/passwd\"`\n2. String concatenation produces `\"./../../../etc/passwd\"`\n3. `reportDirectory.resolve(\"./../../../etc/passwd\")` resolves to e.g. `/tmp/allure-report/./../../../etc/passwd`\n4. The OS resolves this to `/etc/passwd`\n\nThere is no call to `.normalize()` followed by a `.startsWith(reportDirectory)` containment check. The `serveFile()` method (line 341) reads and returns any regular file without further validation.\n\nAdditionally, `URI.getPath()` returns the percent-decoded path, so `%2e%2e` is decoded to `..`, enabling traversal via `/%2e%2e/%2e%2e/etc/passwd` which bypasses clients that normalize `..` in raw form.\n\nThe server defaults to binding on `localhost` (line 327), which limits remote exploitation. However, the `--host` option allows users to bind to any interface (e.g., `--host 0.0.0.0`), which is commonly used in CI/CD and containerized environments. Even when bound to localhost, the vulnerability is exploitable by:\n- Other local users on shared/multi-tenant systems\n- DNS rebinding attacks from malicious web pages visited by the user\n- Adjacent containers in CI/CD environments that share a network namespace\n\n## PoC\n\n**Step 1:** Start the Allure server (simulating a typical CI/CD scenario with network binding):\n```bash\nallure serve ./test-results --host 0.0.0.0 --port 9090\n```\n\n**Step 2:** Read `/etc/passwd` via path traversal:\n```bash\ncurl --path-as-is \u0027http://localhost:9090/../../../etc/passwd\u0027\n```\n\n**Step 3:** Alternative using percent-encoded traversal (works even with clients that normalize `..`):\n```bash\ncurl \u0027http://localhost:9090/%2e%2e/%2e%2e/%2e%2e/etc/passwd\u0027\n```\n\n**Step 4:** Read sensitive application files (e.g., environment variables, SSH keys):\n```bash\ncurl --path-as-is \u0027http://localhost:9090/../../../home/user/.ssh/id_rsa\u0027\ncurl --path-as-is \u0027http://localhost:9090/../../../proc/self/environ\u0027\n```\n\nEach command returns the full contents of the requested file if readable by the Allure process.\n\n## Impact\n\nAn attacker who can reach the Allure HTTP server can read any file on the system that the Allure process has permissions to access. This includes:\n\n- **System credentials:** `/etc/shadow` (if running as root), SSH private keys, cloud provider credentials\n- **Application secrets:** Environment variables via `/proc/self/environ`, configuration files, API keys\n- **Source code and data:** Any file on the filesystem accessible to the running user\n\nIn CI/CD environments where Allure is commonly used, this could expose build secrets, deployment credentials, and other sensitive CI/CD artifacts. The lack of authentication means any client that can reach the server\u0027s port can exploit this vulnerability.\n\n## Recommended Fix\n\nNormalize the resolved path and verify it remains within the report directory before serving:\n\n```java\nserver.createContext(\"/\", exchange -\u003e {\n final Path resolve = reportDirectory.resolve(\".\" + exchange.getRequestURI().getPath()).normalize();\n if (!resolve.startsWith(reportDirectory.normalize())) {\n exchange.sendResponseHeaders(403, 0);\n exchange.getResponseBody().close();\n return;\n }\n if (Files.isDirectory(resolve)) {\n serveFile(exchange, resolve.resolve(\"index.html\"));\n } else {\n serveFile(exchange, resolve);\n }\n});\n```\n\nThe `.normalize()` call collapses `..` sequences, and the `.startsWith()` check ensures the resolved path is still within the report directory. Requests attempting traversal receive a 403 Forbidden response.",
"id": "GHSA-82cg-3hv7-74gc",
"modified": "2026-06-19T21:15:50Z",
"published": "2026-06-19T21:15:50Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/allure-framework/allure2/security/advisories/GHSA-82cg-3hv7-74gc"
},
{
"type": "PACKAGE",
"url": "https://github.com/allure-framework/allure2"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
],
"summary": "Allure Report: Path Traversal in HTTP Server Allows Arbitrary File Read"
}
GHSA-82FW-GWWQ-J7X9
Vulnerability from github – Published: 2026-09-08 20:46 – Updated: 2026-09-08 20:46Summary
@vitest/mocker registers a redirect mock's target path without validating it
against the dev server's file-serving allowlist. An attacker who can reach the
dev server's WebSocket can register a redirect mock pointing outside the project
root; when the mocked module is requested, the plugin's load hook returns
readFile(<attacker path>) as the module source, disclosing local files.
This is exploitable without authentication only through the public
mockerPlugin / standalone interceptorPlugin exports (used by third-party dev
servers), which register the handler on Vite's unauthenticated HMR socket.
Vitest's own browser mode registers mocks over a token-authenticated RPC and
is not remotely reachable by default (see Scope).
Affected code
packages/mocker/src/node/interceptorPlugin.ts.
The load hook is the file-read sink:
if (mock.type === 'redirect') {
return readFile(mock.redirect, 'utf-8')
}
mock.redirect is derived from client input at registration time with no
boundary check:
if (event.type === 'redirect') {
const redirectUrl = new URL(event.redirect)
event.redirect = join(server.config.root, redirectUrl.pathname)
}
registry.register(event)
There is no server.fs.allow / server.fs.deny check and no assertion that the
resolved path stays within the project root.
Registration paths and trust boundaries
- Public
mockerPlugin/interceptorPlugin(unauthenticated). InconfigureServer, the plugin registersserver.ws.on('vitest:interceptor:register', …)on Vite's HMR WebSocket. That socket performs no token, Origin, or same-origin check, so any client that can reach it can register a redirect mock. This is the path the "unauthenticated" impact applies to. - Vitest browser mode (authenticated). Mocks register over the browser RPC
(
registerMock), which sits behind a per-run token (isValidApiRequest, a randomapi.token). The interceptor'sconfigureServersocket is not used for registration here (in v5 it does not run at all, as the plugin is injected per environment). The same missing boundary check exists on the authenticated RPC path, but reaching it requires the token, so it is not a remote-unauthenticated read.
Path handling
new URL(redirect).pathname combined with join(root, pathname) does not
confine reads to the root:
- Special/hierarchical schemes (
file:,http:) are normalized by WHATWG URL, so..segments are collapsed and the result stays under the root. Payloads of the formfile:///../../etc/passwddo not escape. - A non-special (opaque) scheme preserves
..inpathname, sojoin(root, "../../…/etc/passwd")resolves outside the root and reads an arbitrary file.
Even without escaping the root, the missing server.fs check allows reading any
in-root file the dev server would otherwise refuse to serve (for example an
in-root .env or source that is denied by server.fs.deny).
Scope / preconditions
- This is a development-server issue. The dev server binds to
localhostby default and is not reachable from the network unless the developer exposes it (server.host/0.0.0.0, a LAN bind, or a proxy). - A raw (non-browser) client against a reachable server bypasses browser origin and CORS protections entirely and can both register the mock and read the response.
- A browser-based drive-by against a localhost server is substantially mitigated
by Vite defaults: the default CORS origin allowlist is limited to
localhostorigins, andserver.allowedHostsblocks DNS-rebinding, so a cross-origin page cannot read the file contents back.
Impact
Disclosure of local files readable by the dev-server process (source, in-root
.env/secrets, and, via the opaque-scheme payload, files outside the project
root). No integrity or availability impact.
Affected versions
Present since @vitest/mocker was introduced.
- Affected:
@vitest/mocker>= 2.1.0 (shipped invitestand@vitest/browser>= 2.1.0), through 4.1.x and the 5.0.0 pre-releases. - Fixed: Vitest 4.1.11 and 5.0.0. Older majors (2.1.x, 3.x) are not maintained and are not planned to receive the fix.
Fix
Validate the resolved redirect target against Vite's file-serving allowlist
(isFileLoadingAllowed) before registering it, at every registration site, and
stop registering the interceptor WebSocket events in Vitest's browser mode
(mocks there flow through the authenticated RPC).
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "@vitest/mocker"
},
"ranges": [
{
"events": [
{
"introduced": "2.1.0"
},
{
"fixed": "4.1.11"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "npm",
"name": "vitest"
},
"ranges": [
{
"events": [
{
"introduced": "2.1.0"
},
{
"fixed": "4.1.11"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "npm",
"name": "vitest"
},
"ranges": [
{
"events": [
{
"introduced": "5.0.0-beta.1"
},
{
"fixed": "5.0.0-rc.2"
}
],
"type": "ECOSYSTEM"
}
]
},
{
"package": {
"ecosystem": "npm",
"name": "@vitest/mocker"
},
"ranges": [
{
"events": [
{
"introduced": "5.0.0-beta.1"
},
{
"fixed": "5.0.0-rc.2"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-84373"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2026-09-08T20:46:45Z",
"nvd_published_at": "2026-09-01T22:17:19Z",
"severity": "MODERATE"
},
"details": "## Summary\n`@vitest/mocker` registers a redirect mock\u0027s target path without validating it\nagainst the dev server\u0027s file-serving allowlist. An attacker who can reach the\ndev server\u0027s WebSocket can register a redirect mock pointing outside the project\nroot; when the mocked module is requested, the plugin\u0027s `load` hook returns\n`readFile(\u003cattacker path\u003e)` as the module source, disclosing local files.\n\nThis is exploitable **without authentication** only through the public\n`mockerPlugin` / standalone `interceptorPlugin` exports (used by third-party dev\nservers), which register the handler on Vite\u0027s unauthenticated HMR socket.\nVitest\u0027s own browser mode registers mocks over a **token-authenticated** RPC and\nis not remotely reachable by default (see Scope).\n\n## Affected code\n`packages/mocker/src/node/interceptorPlugin.ts`.\n\nThe `load` hook is the file-read sink:\n\n```ts\nif (mock.type === \u0027redirect\u0027) {\n return readFile(mock.redirect, \u0027utf-8\u0027)\n}\n```\n\n`mock.redirect` is derived from client input at registration time with no\nboundary check:\n\n```ts\nif (event.type === \u0027redirect\u0027) {\n const redirectUrl = new URL(event.redirect)\n event.redirect = join(server.config.root, redirectUrl.pathname)\n}\nregistry.register(event)\n```\n\nThere is no `server.fs.allow` / `server.fs.deny` check and no assertion that the\nresolved path stays within the project root.\n\n## Registration paths and trust boundaries\n- **Public `mockerPlugin` / `interceptorPlugin` (unauthenticated).** In\n `configureServer`, the plugin registers `server.ws.on(\u0027vitest:interceptor:register\u0027, \u2026)`\n on Vite\u0027s HMR WebSocket. That socket performs no token, Origin, or same-origin\n check, so any client that can reach it can register a redirect mock. This is\n the path the \"unauthenticated\" impact applies to.\n- **Vitest browser mode (authenticated).** Mocks register over the browser RPC\n (`registerMock`), which sits behind a per-run token (`isValidApiRequest`, a\n random `api.token`). The interceptor\u0027s `configureServer` socket is not used for\n registration here (in v5 it does not run at all, as the plugin is injected per\n environment). The same missing boundary check exists on the authenticated RPC\n path, but reaching it requires the token, so it is not a remote-unauthenticated\n read.\n\n## Path handling\n`new URL(redirect).pathname` combined with `join(root, pathname)` does **not**\nconfine reads to the root:\n\n- Special/hierarchical schemes (`file:`, `http:`) are normalized by WHATWG URL,\n so `..` segments are collapsed and the result stays under the root. Payloads of\n the form `file:///../../etc/passwd` do **not** escape.\n- A non-special (opaque) scheme preserves `..` in `pathname`, so\n `join(root, \"../../\u2026/etc/passwd\")` resolves outside the root and reads an\n arbitrary file.\n\nEven without escaping the root, the missing `server.fs` check allows reading any\nin-root file the dev server would otherwise refuse to serve (for example an\nin-root `.env` or source that is denied by `server.fs.deny`).\n\n## Scope / preconditions\n- This is a **development-server** issue. The dev server binds to `localhost` by\n default and is not reachable from the network unless the developer exposes it\n (`server.host` / `0.0.0.0`, a LAN bind, or a proxy).\n- A raw (non-browser) client against a reachable server bypasses browser origin\n and CORS protections entirely and can both register the mock and read the\n response.\n- A browser-based drive-by against a localhost server is substantially mitigated\n by Vite defaults: the default CORS origin allowlist is limited to `localhost`\n origins, and `server.allowedHosts` blocks DNS-rebinding, so a cross-origin page\n cannot read the file contents back.\n\n## Impact\nDisclosure of local files readable by the dev-server process (source, in-root\n`.env`/secrets, and, via the opaque-scheme payload, files outside the project\nroot). No integrity or availability impact.\n\n## Affected versions\nPresent since `@vitest/mocker` was introduced.\n\n- **Affected: `@vitest/mocker` \u003e= 2.1.0** (shipped in `vitest` and\n `@vitest/browser` \u003e= 2.1.0), through 4.1.x and the 5.0.0 pre-releases.\n- **Fixed:** Vitest 4.1.11 and 5.0.0. Older majors (2.1.x, 3.x) are not\n maintained and are not planned to receive the fix.\n\n## Fix\nValidate the resolved redirect target against Vite\u0027s file-serving allowlist\n(`isFileLoadingAllowed`) before registering it, at every registration site, and\nstop registering the interceptor WebSocket events in Vitest\u0027s browser mode\n(mocks there flow through the authenticated RPC).",
"id": "GHSA-82fw-gwwq-j7x9",
"modified": "2026-09-08T20:46:45Z",
"published": "2026-09-08T20:46:45Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/vitest-dev/vitest/security/advisories/GHSA-82fw-gwwq-j7x9"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-84373"
},
{
"type": "WEB",
"url": "https://github.com/vitest-dev/vitest/pull/10972"
},
{
"type": "WEB",
"url": "https://github.com/vitest-dev/vitest/pull/10974"
},
{
"type": "WEB",
"url": "https://github.com/vitest-dev/vitest/commit/51edf2b072902aec6d30c90ebaafd8f121c6f9d8"
},
{
"type": "WEB",
"url": "https://github.com/vitest-dev/vitest/commit/8ff9b9a9efca7c6cfd5243569440de8d7a33aec4"
},
{
"type": "WEB",
"url": "https://github.com/vitest-dev/vitest/commit/fe5a11d3ceac5ec10d6d7d21a46d4caca132c48f"
},
{
"type": "PACKAGE",
"url": "https://github.com/vitest-dev/vitest"
},
{
"type": "WEB",
"url": "https://github.com/vitest-dev/vitest/releases/tag/v4.1.11"
},
{
"type": "WEB",
"url": "https://github.com/vitest-dev/vitest/releases/tag/v5.0.0-rc.2"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
],
"summary": "Vitest: Path Traversal / Arbitrary File Read via @vitest/mocker Redirect Mock"
}
GHSA-82H5-9GW3-Q456
Vulnerability from github – Published: 2024-06-14 18:31 – Updated: 2024-08-07 18:30Directory Traversal vulnerability in Mgt-commerce CloudPanel v.2.0.0 thru v.2.4.0 allows a remote attacker to obtain sensitive information and execute arbitrary code via the service parameter of the load-logfiles function.
{
"affected": [],
"aliases": [
"CVE-2024-24320"
],
"database_specific": {
"cwe_ids": [
"CWE-120",
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2024-06-14T18:15:27Z",
"severity": "HIGH"
},
"details": "Directory Traversal vulnerability in Mgt-commerce CloudPanel v.2.0.0 thru v.2.4.0 allows a remote attacker to obtain sensitive information and execute arbitrary code via the service parameter of the load-logfiles function.",
"id": "GHSA-82h5-9gw3-q456",
"modified": "2024-08-07T18:30:40Z",
"published": "2024-06-14T18:31:45Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-24320"
},
{
"type": "WEB",
"url": "https://datack.my/cloudpanel-v2-0-0-v2-4-0-authenticated-user-session-hijacking-cve-2024-24320"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-82HX-PVJJ-2M99
Vulnerability from github – Published: 2022-05-24 16:50 – Updated: 2024-04-04 01:17Citrix SD-WAN 10.2.x before 10.2.3 and NetScaler SD-WAN 10.0.x before 10.0.8 allow Directory Traversal.
{
"affected": [],
"aliases": [
"CVE-2019-12990"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2019-07-16T18:15:00Z",
"severity": "CRITICAL"
},
"details": "Citrix SD-WAN 10.2.x before 10.2.3 and NetScaler SD-WAN 10.0.x before 10.0.8 allow Directory Traversal.",
"id": "GHSA-82hx-pvjj-2m99",
"modified": "2024-04-04T01:17:08Z",
"published": "2022-05-24T16:50:28Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2019-12990"
},
{
"type": "WEB",
"url": "https://support.citrix.com/search?searchQuery=%2A\u0026lang=en\u0026sort=relevance\u0026prod=\u0026pver=\u0026ct=Security+Bulletin"
},
{
"type": "WEB",
"url": "https://support.citrix.com/search?searchQuery=*\u0026lang=en\u0026sort=relevance\u0026prod=\u0026pver=\u0026ct=Security+Bulletin"
},
{
"type": "WEB",
"url": "https://www.tenable.com/security/research/tra-2019-31"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/109133"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-82J3-HF72-7X93
Vulnerability from github – Published: 2024-11-04 23:23 – Updated: 2024-11-04 23:23Summary
Reposilite v3.5.10 is affected by an Arbitrary File Read vulnerability via path traversal while serving expanded javadoc files.
Details
The problem lies in the way how the expanded javadoc files are served. The GET /javadoc/{repository}/<gav>/raw/<resource> route uses the <resource> path parameter to find the file in the javadocUnpackPath directory and returns it's content to the user.
fun findRawJavadocResource(request: JavadocRawRequest): Result<JavadocRawResponse, ErrorResponse> =
with (request) {
mavenFacade.canAccessResource(accessToken, repository, gav)
.flatMap { javadocContainerService.loadContainer(accessToken, repository, gav) }
.filter({ Files.exists(it.javadocUnpackPath.resolve(resource.toString())) }, { notFound("Resource $resource not found") })
.map {
JavadocRawResponse(
contentType = supportedExtensions[resource.getExtension()] ?: ContentType.APPLICATION_OCTET_STREAM,
content = Files.newInputStream(it.javadocUnpackPath.resolve(resource.toString()))
)
}
}
In this case, the <resource> path parameter can contain path traversal characters such as /../../. Since the path is concatenated with the main directory, it opens the possibility to read files outside the javadocUnpackPath directory.
Impact
This issue may lead to Arbitrary File Read on the server. A potential attacker can read some sensitive file, such as reposilite.db, that contains the sqlite database used by Reposilite. This database contains the sensitive information used by Reposilite, including passwords and hashes of issued tokens. Also, the configuration.cdn file can be read, which contains other sensitive properties.
Steps to reproduce
- Start the Reposilite instance on http://localhost:8080/
- Find at least one javadoc file in the hosted repositories. For example, the default test workspace contains the
/releases/javadoc/1.0.0/javadoc-1.0.0-javadoc.jararchive that is suitable for our attack. - Send a GET request to http://127.0.0.1:8080/javadoc/releases/javadoc/1.0.0/raw/%2e%2e%5c%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2freposilite.db
When this request is processed on the server, Reposilite tries to unpack the
/repositories/releases/javadoc/1.0.0/javadoc-1.0.0-javadoc.jarfile into the/javadocs/releases/javadoc/1.0.0/.cache/unpackfolder. Then, it tries to read the../../../../../../reposilite.dbfile from this folder, which triggers the path traversal attack.
Remediation
Normalize (remove all occurrences of /../) the <resource> path parameter before using it when reading the file. For example:
content = Files.newInputStream(it.javadocUnpackPath.resolve(resource.toPath()))
Changing resource.toString() to resource.toPath() is enough here as the com.reposilite.storage.api.Location#toPath method normalizes the string internally.
{
"affected": [
{
"package": {
"ecosystem": "Maven",
"name": "com.reposilite:reposilite-backend"
},
"ranges": [
{
"events": [
{
"introduced": "3.3.0"
},
{
"fixed": "3.5.12"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2024-11-04T23:23:08Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "### Summary\nReposilite v3.5.10 is affected by an Arbitrary File Read vulnerability via path traversal while serving expanded javadoc files.\n\n### Details\nThe problem lies in the way how the expanded javadoc files are served. The `GET /javadoc/{repository}/\u003cgav\u003e/raw/\u003cresource\u003e` route uses the `\u003cresource\u003e` path parameter to find the file in the `javadocUnpackPath` directory and returns it\u0027s content to the user.\n\n[JavadocFacade.kt#L77](https://github.com/dzikoysk/reposilite/blob/68b73f19dc9811ccf10936430cf17f7b0e622bd6/reposilite-backend/src/main/kotlin/com/reposilite/javadocs/JavadocFacade.kt#L77):\n\n```kotlin\nfun findRawJavadocResource(request: JavadocRawRequest): Result\u003cJavadocRawResponse, ErrorResponse\u003e =\n with (request) {\n mavenFacade.canAccessResource(accessToken, repository, gav)\n .flatMap { javadocContainerService.loadContainer(accessToken, repository, gav) }\n .filter({ Files.exists(it.javadocUnpackPath.resolve(resource.toString())) }, { notFound(\"Resource $resource not found\") })\n .map {\n JavadocRawResponse(\n contentType = supportedExtensions[resource.getExtension()] ?: ContentType.APPLICATION_OCTET_STREAM,\n content = Files.newInputStream(it.javadocUnpackPath.resolve(resource.toString()))\n )\n }\n }\n```\n\nIn this case, the `\u003cresource\u003e` path parameter can contain path traversal characters such as `/../../`. Since the path is concatenated with the main directory, it opens the possibility to read files outside the `javadocUnpackPath` directory.\n\n#### Impact\n\nThis issue may lead to Arbitrary File Read on the server. A potential attacker can read some sensitive file, such as `reposilite.db`, that contains the sqlite database used by Reposilite. This database contains the sensitive information used by Reposilite, including passwords and hashes of issued tokens. Also, the `configuration.cdn` file can be read, which contains other sensitive properties.\n\n### Steps to reproduce\n\n1. Start the Reposilite instance on http://localhost:8080/\n2. Find at least one javadoc file in the hosted repositories. For example, the default test workspace contains the `/releases/javadoc/1.0.0/javadoc-1.0.0-javadoc.jar` archive that is suitable for our attack.\n3. Send a GET request to http://127.0.0.1:8080/javadoc/releases/javadoc/1.0.0/raw/%2e%2e%5c%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2f%2e%2e%2freposilite.db\nWhen this request is processed on the server, Reposilite tries to unpack the `/repositories/releases/javadoc/1.0.0/javadoc-1.0.0-javadoc.jar` file into the `/javadocs/releases/javadoc/1.0.0/.cache/unpack` folder. Then, it tries to read the `../../../../../../reposilite.db` file from this folder, which triggers the path traversal attack.\n\n\n\n### Remediation\n\nNormalize (remove all occurrences of `/../`) the `\u003cresource\u003e` path parameter before using it when reading the file. For example:\n\n```kotlin\ncontent = Files.newInputStream(it.javadocUnpackPath.resolve(resource.toPath()))\n```\n\nChanging `resource.toString()` to `resource.toPath()` is enough here as the `com.reposilite.storage.api.Location#toPath` method normalizes the string internally.\n",
"id": "GHSA-82j3-hf72-7x93",
"modified": "2024-11-04T23:23:08Z",
"published": "2024-11-04T23:23:08Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/dzikoysk/reposilite/security/advisories/GHSA-82j3-hf72-7x93"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2024-36117"
},
{
"type": "WEB",
"url": "https://github.com/dzikoysk/reposilite/commit/e172ae4b539c822d0d6e04cf090713c7202a79d6"
},
{
"type": "PACKAGE",
"url": "https://github.com/dzikoysk/reposilite"
},
{
"type": "WEB",
"url": "https://github.com/dzikoysk/reposilite/releases/tag/3.5.12"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N",
"type": "CVSS_V3"
},
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:L/VA:L/SC:N/SI:N/SA:N",
"type": "CVSS_V4"
}
],
"summary": "Reposilite vulnerable to path traversal while serving javadoc expanded files (arbitrary file read) (`GHSL-2024-074`)"
}
GHSA-82JV-F4JX-8R27
Vulnerability from github – Published: 2026-01-09 09:31 – Updated: 2026-03-05 21:30A security issue was discovered in GNU Wget2 when handling Metalink documents. The application fails to properly validate file paths provided in Metalink elements. An attacker can abuse this behavior to write files to unintended locations on the system. This can lead to data loss or potentially allow further compromise of the user’s environment.
{
"affected": [],
"aliases": [
"CVE-2025-69194"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-01-09T08:15:57Z",
"severity": "HIGH"
},
"details": "A security issue was discovered in GNU Wget2 when handling Metalink documents. The application fails to properly validate file paths provided in Metalink \u003cfile name\u003e elements. An attacker can abuse this behavior to write files to unintended locations on the system. This can lead to data loss or potentially allow further compromise of the user\u2019s environment.",
"id": "GHSA-82jv-f4jx-8r27",
"modified": "2026-03-05T21:30:24Z",
"published": "2026-01-09T09:31:20Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-69194"
},
{
"type": "WEB",
"url": "https://access.redhat.com/security/cve/CVE-2025-69194"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=2425773"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-82MH-4377-P289
Vulnerability from github – Published: 2022-05-17 04:38 – Updated: 2022-05-17 04:38Directory traversal vulnerability in the Tom M8te (tom-m8te) plugin 1.5.3 for WordPress allows remote attackers to read arbitrary files via the file parameter to tom-download-file.php.
{
"affected": [],
"aliases": [
"CVE-2014-5187"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2014-08-06T19:55:00Z",
"severity": "MODERATE"
},
"details": "Directory traversal vulnerability in the Tom M8te (tom-m8te) plugin 1.5.3 for WordPress allows remote attackers to read arbitrary files via the file parameter to tom-download-file.php.",
"id": "GHSA-82mh-4377-p289",
"modified": "2022-05-17T04:38:31Z",
"published": "2022-05-17T04:38:31Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2014-5187"
},
{
"type": "WEB",
"url": "http://codevigilant.com/disclosure/wp-plugin-tom-m8te-local-file-inclusion"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-82P2-CCRF-WXW5
Vulnerability from github – Published: 2026-02-12 00:31 – Updated: 2026-08-21 03:31A path handling issue was addressed with improved validation. This issue is fixed in iOS 26.3 and iPadOS 26.3, macOS Tahoe 26.3, macOS Sonoma 14.8.4, visionOS 26.3. An app may be able to gain root privileges.
{
"affected": [],
"aliases": [
"CVE-2026-20615"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-02-11T23:16:05Z",
"severity": "HIGH"
},
"details": "A path handling issue was addressed with improved validation. This issue is fixed in iOS 26.3 and iPadOS 26.3, macOS Tahoe 26.3, macOS Sonoma 14.8.4, visionOS 26.3. An app may be able to gain root privileges.",
"id": "GHSA-82p2-ccrf-wxw5",
"modified": "2026-08-21T03:31:21Z",
"published": "2026-02-12T00:31:04Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-20615"
},
{
"type": "WEB",
"url": "https://support.apple.com/en-us/126346"
},
{
"type": "WEB",
"url": "https://support.apple.com/en-us/126348"
},
{
"type": "WEB",
"url": "https://support.apple.com/en-us/126349"
},
{
"type": "WEB",
"url": "https://support.apple.com/en-us/126350"
},
{
"type": "WEB",
"url": "https://support.apple.com/en-us/126353"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
]
}
Mitigation MIT-5.1
Strategy: Input Validation
- 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 input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."
- Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
- When validating filenames, use stringent allowlists that limit the character set to be used. If feasible, only allow a single "." character in the filename to avoid weaknesses such as CWE-23, and exclude directory separators such as "/" to avoid CWE-36. Use a list of allowable file extensions, which will help to avoid CWE-434.
- Do not rely exclusively on a filtering mechanism that removes potentially dangerous characters. This is equivalent to a denylist, which may be incomplete (CWE-184). For example, filtering "/" is insufficient protection if the filesystem also supports the use of "\" as a directory separator. Another possible error could occur when the filtering is applied in a way that still produces dangerous data (CWE-182). For example, if "../" sequences are removed from the ".../...//" string in a sequential fashion, two instances of "../" would be removed from the original string, but the remaining characters would still form the "../" string.
Mitigation MIT-15
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 server.
Mitigation MIT-20.1
Strategy: Input Validation
- Inputs should be decoded and canonicalized to the application's current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.
- 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). This includes:
- realpath() in C
- getCanonicalPath() in Java
- GetFullPath() in ASP.NET
- realpath() or abs_path() in Perl
- realpath() in PHP
Mitigation MIT-4
Strategy: Libraries or Frameworks
Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].
Mitigation MIT-29
Strategy: Firewall
Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].
Mitigation MIT-17
Strategy: Environment Hardening
Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
Mitigation MIT-21.1
Strategy: Enforcement by Conversion
- When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, 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 [REF-185] provide this capability.
Mitigation MIT-22
Strategy: Sandbox or Jail
- Run the code in a "jail" or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software.
- OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations.
- This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise.
- Be careful to avoid CWE-243 and other weaknesses related to jails.
Mitigation MIT-34
Strategy: Attack Surface Reduction
- Store library, include, and utility files outside of the web document root, if possible. Otherwise, store them in a separate directory and use the web server's access control capabilities to prevent attackers from directly requesting them. One common practice is to define a fixed constant in each calling program, then check for the existence of the constant in the library/include file; if the constant does not exist, then the file was directly requested, and it can exit immediately.
- This significantly reduces the chance of an attacker being able to bypass any protection mechanisms that are in the base program but not in the include files. It will also reduce the attack surface.
Mitigation MIT-39
- Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success.
- If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files.
- Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not.
- In the context of path traversal, error messages which disclose path information can help attackers craft the appropriate attack strings to move through the file system hierarchy.
Mitigation MIT-16
Strategy: Environment Hardening
When using PHP, configure the application so that it does not use register_globals. During implementation, develop the 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.
CAPEC-126: Path Traversal
An adversary uses path manipulation methods to exploit insufficient input validation of a target to obtain access to data that should be not be retrievable by ordinary well-formed requests. A typical variety of this attack involves specifying a path to a desired file together with dot-dot-slash characters, resulting in the file access API or function traversing out of the intended directory structure and into the root file system. By replacing or modifying the expected path information the access function or API retrieves the file desired by the attacker. These attacks either involve the attacker providing a complete path to a targeted file or using control characters (e.g. path separators (/ or \) and/or dots (.)) to reach desired directories or files.
CAPEC-64: Using Slashes and URL Encoding Combined to Bypass Validation Logic
This attack targets the encoding of the URL combined with the encoding of the slash characters. An attacker can take advantage of the multiple ways of encoding a URL and abuse the interpretation of the URL. A URL may contain special character that need special syntax handling in order to be interpreted. Special characters are represented using a percentage character followed by two digits representing the octet code of the original character (%HEX-CODE). For instance US-ASCII space character would be represented with %20. This is often referred as escaped ending or percent-encoding. Since the server decodes the URL from the requests, it may restrict the access to some URL paths by validating and filtering out the URL requests it received. An attacker will try to craft an URL with a sequence of special characters which once interpreted by the server will be equivalent to a forbidden URL. It can be difficult to protect against this attack since the URL can contain other format of encoding such as UTF-8 encoding, Unicode-encoding, etc.
CAPEC-76: Manipulating Web Input to File System Calls
An attacker manipulates inputs to the target software which the target software passes to file system calls in the OS. The goal is to gain access to, and perhaps modify, areas of the file system that the target software did not intend to be accessible.
CAPEC-78: Using Escaped Slashes in Alternate Encoding
This attack targets the use of the backslash in alternate encoding. An adversary can provide a backslash as a leading character and causes a parser to believe that the next character is special. This is called an escape. By using that trick, the adversary tries to exploit alternate ways to encode the same character which leads to filter problems and opens avenues to attack.
CAPEC-79: Using Slashes in Alternate Encoding
This attack targets the encoding of the Slash characters. An adversary would try to exploit common filtering problems related to the use of the slashes characters to gain access to resources on the target host. Directory-driven systems, such as file systems and databases, typically use the slash character to indicate traversal between directories or other container components. For murky historical reasons, PCs (and, as a result, Microsoft OSs) choose to use a backslash, whereas the UNIX world typically makes use of the forward slash. The schizophrenic result is that many MS-based systems are required to understand both forms of the slash. This gives the adversary many opportunities to discover and abuse a number of common filtering problems. The goal of this pattern is to discover server software that only applies filters to one version, but not the other.