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
16162 vulnerabilities reference this CWE, most recent first.
GHSA-9G7V-8WXV-MWXP
Vulnerability from github – Published: 2025-11-28 15:30 – Updated: 2025-12-02 00:09Duplicate Advisory
This advisory has been withdrawn because it is a duplicate of GHSA-hjqc-jx6g-rwp9. This link is maintained to preserve external references.
Original Description
Keras version 3.11.3 is affected by a path traversal vulnerability in the keras.utils.get_file() function when extracting tar archives. The vulnerability arises because the function uses Python's tarfile.extractall() method without the security-critical filter='data' parameter. Although Keras attempts to filter unsafe paths using filter_safe_paths(), this filtering occurs before extraction, and a PATH_MAX symlink resolution bug triggers during extraction. This bug causes symlink resolution to fail due to path length limits, resulting in a security bypass that allows files to be written outside the intended extraction directory. This can lead to arbitrary file writes outside the cache directory, enabling potential system compromise or malicious code execution. The vulnerability affects Keras installations that process tar archives with get_file() and does not affect versions where this extraction method is secured with the appropriate filter parameter.
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "Keras"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "3.12.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2025-12638"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2025-12-02T00:09:26Z",
"nvd_published_at": "2025-11-28T15:16:00Z",
"severity": "HIGH"
},
"details": "### Duplicate Advisory\nThis advisory has been withdrawn because it is a duplicate of GHSA-hjqc-jx6g-rwp9. This link is maintained to preserve external references.\n\n### Original Description\nKeras version 3.11.3 is affected by a path traversal vulnerability in the keras.utils.get_file() function when extracting tar archives. The vulnerability arises because the function uses Python\u0027s tarfile.extractall() method without the security-critical filter=\u0027data\u0027 parameter. Although Keras attempts to filter unsafe paths using filter_safe_paths(), this filtering occurs before extraction, and a PATH_MAX symlink resolution bug triggers during extraction. This bug causes symlink resolution to fail due to path length limits, resulting in a security bypass that allows files to be written outside the intended extraction directory. This can lead to arbitrary file writes outside the cache directory, enabling potential system compromise or malicious code execution. The vulnerability affects Keras installations that process tar archives with get_file() and does not affect versions where this extraction method is secured with the appropriate filter parameter.",
"id": "GHSA-9g7v-8wxv-mwxp",
"modified": "2025-12-02T00:09:26Z",
"published": "2025-11-28T15:30:30Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2025-12638"
},
{
"type": "WEB",
"url": "https://github.com/keras-team/keras/commit/47fcb397ee4caffd5a75efd1fa3067559594e951"
},
{
"type": "PACKAGE",
"url": "https://github.com/keras-team/keras"
},
{
"type": "WEB",
"url": "https://huntr.com/bounties/f94f5beb-54d8-4e6a-8bac-86d9aee103f4"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:L/UI:R/S:U/C:H/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "Duplicate Advisory: Keras keras.utils.get_file API is vulnerable to a path traversal attack",
"withdrawn": "2025-12-02T00:09:26Z"
}
GHSA-9G84-3XHQ-4HWG
Vulnerability from github – Published: 2026-09-27 06:30 – Updated: 2026-09-28 03:30The WebFacing™ WordPress plugin before 5.4 does not restrict access to one of its bundled scripts and does not validate a user-supplied path before using it to include a local file, allowing unauthenticated users to perform Local File Inclusion.
{
"affected": [],
"aliases": [
"CVE-2026-84069"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2026-09-27T06:17:06Z",
"severity": "MODERATE"
},
"details": "The WebFacing\u2122 WordPress plugin before 5.4 does not restrict access to one of its bundled scripts and does not validate a user-supplied path before using it to include a local file, allowing unauthenticated users to perform Local File Inclusion.",
"id": "GHSA-9g84-3xhq-4hwg",
"modified": "2026-09-28T03:30:25Z",
"published": "2026-09-27T06:30:21Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-84069"
},
{
"type": "WEB",
"url": "https://wpscan.com/vulnerability/04965370-b4f4-4629-a9b1-7450fcf6aeee"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-9G8W-PJPR-PRR4
Vulnerability from github – Published: 2022-05-13 01:36 – Updated: 2022-11-04 20:36hawtio before versions 2.0-beta-1, 2.0-beta-2, 2.0-m1, 2.0-m2, 2.0-m3, and 1.5 are vulnerable to a path traversal that leads to a NullPointerException with a full stacktrace. An attacker could use this flaw to gather undisclosed information from within hawtio's root.
{
"affected": [
{
"package": {
"ecosystem": "Maven",
"name": "io.hawt:project"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.5.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2017-2594"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2022-11-04T20:36:05Z",
"nvd_published_at": "2018-05-08T17:29:00Z",
"severity": "HIGH"
},
"details": "hawtio before versions 2.0-beta-1, 2.0-beta-2, 2.0-m1, 2.0-m2, 2.0-m3, and 1.5 are vulnerable to a path traversal that leads to a NullPointerException with a full stacktrace. An attacker could use this flaw to gather undisclosed information from within hawtio\u0027s root.",
"id": "GHSA-9g8w-pjpr-prr4",
"modified": "2022-11-04T20:36:05Z",
"published": "2022-05-13T01:36:55Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2017-2594"
},
{
"type": "WEB",
"url": "https://access.redhat.com/errata/RHSA-2017:1832"
},
{
"type": "WEB",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=CVE-2017-2594"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
],
"summary": "Path Traversal in io.hawt:project"
}
GHSA-9G92-WHV2-G846
Vulnerability from github – Published: 2025-01-08 03:30 – Updated: 2025-01-08 03:30Path traversal vulnerability in the Medialibrary module Impact: Successful exploitation of this vulnerability will affect integrity and confidentiality.
{
"affected": [],
"aliases": [
"CVE-2023-52953"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2025-01-08T03:15:07Z",
"severity": "MODERATE"
},
"details": "Path traversal vulnerability in the Medialibrary module\nImpact: Successful exploitation of this vulnerability will affect integrity and confidentiality.",
"id": "GHSA-9g92-whv2-g846",
"modified": "2025-01-08T03:30:23Z",
"published": "2025-01-08T03:30:23Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-52953"
},
{
"type": "WEB",
"url": "https://consumer.huawei.com/en/support/bulletin/2025/1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
]
}
GHSA-9GCQ-4H5G-5WX6
Vulnerability from github – Published: 2022-05-02 06:14 – Updated: 2022-05-02 06:14Directory traversal vulnerability in index.php in ZeusCMS 0.2 allows remote attackers to include and execute arbitrary local files via directory traversal sequences in the page parameter.
{
"affected": [],
"aliases": [
"CVE-2010-0680"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2010-02-22T21:30:00Z",
"severity": "HIGH"
},
"details": "Directory traversal vulnerability in index.php in ZeusCMS 0.2 allows remote attackers to include and execute arbitrary local files via directory traversal sequences in the page parameter.",
"id": "GHSA-9gcq-4h5g-5wx6",
"modified": "2022-05-02T06:14:43Z",
"published": "2022-05-02T06:14:43Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2010-0680"
},
{
"type": "WEB",
"url": "http://www.exploit-db.com/exploits/11437"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/38237"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-9GF6-9V36-2VFV
Vulnerability from github – Published: 2022-05-17 19:57 – Updated: 2024-04-04 00:00Absolute path traversal vulnerability in tools/pdfViewer.pl in Koha before 3.8.23, 3.10.x before 3.10.13, 3.12.x before 3.12.10, and 3.14.x before 3.14.3 allows remote attackers to read arbitrary files via unspecified vectors.
{
"affected": [],
"aliases": [
"CVE-2014-1922"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2020-01-24T17:15:00Z",
"severity": "HIGH"
},
"details": "Absolute path traversal vulnerability in tools/pdfViewer.pl in Koha before 3.8.23, 3.10.x before 3.10.13, 3.12.x before 3.12.10, and 3.14.x before 3.14.3 allows remote attackers to read arbitrary files via unspecified vectors.",
"id": "GHSA-9gf6-9v36-2vfv",
"modified": "2024-04-04T00:00:35Z",
"published": "2022-05-17T19:57:17Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2014-1922"
},
{
"type": "WEB",
"url": "http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11660"
},
{
"type": "WEB",
"url": "http://koha-community.org/security-release-february-2014"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2014/02/07/10"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2014/02/10/3"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
]
}
GHSA-9GFJ-28HW-JCHP
Vulnerability from github – Published: 2026-09-25 19:32 – Updated: 2026-09-25 19:32Overview
Verified. Multiple Unrestricted Path Traversal vulnerabilities exist in the Knowns MCP docs and memory tools, allowing arbitrary file read, write, and deletion operations outside the project sandbox. The storage layer functions (Get, Create, Update, Rename, Delete) in both doc_store.go and memory_store.go concatenate user-controlled paths with filepath.Join() without any containment validation.
Additionally, the docs.update action with a newPath parameter performs a file deletion via Rename(), but is classified as CapWrite in the permission registry rather than CapDelete. This allows an attacker with a read-write-no-delete preset to bypass deletion restrictions and destroy arbitrary files outside the project root.
Affected paths
| File Path | Role | Vulnerability & Execution Impact |
|---|---|---|
internal/storage/doc_store.go |
Vulnerable Sink (Docs) | Path Traversal in File Operations (CWE-22): Get(), Create(), Update(), Rename(), Delete() join user-controlled path with filepath.Join(ds.docsDir(), ...) without validating path containment. |
internal/storage/memory_store.go |
Vulnerable Sink (Memory) | Path Traversal in Memory Operations (CWE-22): GetInLayer(), Create(), Update(), Delete() join user-controlled id with filepath.Join(dir, models.MemoryFileName(id)) without validation. |
internal/mcp/handlers/doc.go |
Pass-Through Handler | Unsanitized Input Propagation: MCP handlers pass user-supplied path, folder, newPath directly to storage layer without sanitization. |
internal/mcp/handlers/memory.go |
Pass-Through Handler | Unsanitized Input Propagation: MCP handlers pass user-supplied id directly to storage layer without sanitization. |
internal/permissions/registry.go |
Authorization Bypass | Capability Misclassification (CWE-863): docs.update with newPath performs file deletion but is classified as CapWrite, bypassing CapDelete restrictions. |
Root Cause
Missing Path Containment in DocStore
In internal/storage/doc_store.go, all file operations use filepath.Join() to construct absolute paths without validating that the resolved path remains within docsDir():
// Get retrieves a doc by its relative path (without .md extension).
func (ds *DocStore) Get(path string) (*models.Doc, error) {
path = strings.TrimPrefix(path, "/")
path = strings.TrimSuffix(path, ".md")
// VULNERABLE: No containment check
absPath := filepath.Join(ds.docsDir(), filepath.FromSlash(path)+".md")
if _, err := os.Stat(absPath); err == nil {
// ...
return ds.parseFile(absPath, path, folder, false, "")
}
// ...
}
// Create writes a new doc to .knowns/docs/{path}.md.
func (ds *DocStore) Create(doc *models.Doc) error {
if doc.Path == "" {
return fmt.Errorf("doc path is required")
}
// VULNERABLE: No containment check
absPath := filepath.Join(ds.docsDir(), filepath.FromSlash(doc.Path)+".md")
if err := os.MkdirAll(filepath.Dir(absPath), 0755); err != nil {
return fmt.Errorf("create doc dir: %w", err)
}
return ds.writeFile(absPath, doc)
}
// Rename rewrites a doc to a new path and removes the old file.
func (ds *DocStore) Rename(oldPath string, doc *models.Doc) error {
// ...
oldAbsPath := filepath.Join(ds.docsDir(), filepath.FromSlash(strings.TrimSuffix(oldPath, ".md"))+".md")
newAbsPath := filepath.Join(ds.docsDir(), filepath.FromSlash(strings.TrimSuffix(doc.Path, ".md"))+".md")
// ...
if err := ds.writeFile(newAbsPath, doc); err != nil {
return err
}
if oldAbsPath != newAbsPath {
// VULNERABLE: Deletes file at oldAbsPath (can be outside docsDir)
if err := os.Remove(oldAbsPath); err != nil && !os.IsNotExist(err) {
return err
}
}
return nil
}
// Delete removes a doc file.
func (ds *DocStore) Delete(path string) error {
path = strings.TrimSuffix(path, ".md")
// VULNERABLE: No containment check
absPath := filepath.Join(ds.docsDir(), filepath.FromSlash(path)+".md")
return os.Remove(absPath)
}
Critical Flaws:
- filepath.Join resolves ../ sequences natively
- No post-Join prefix check (e.g., strings.HasPrefix(absPath, ds.docsDir()))
- No rejection of absolute paths or path traversal sequences
- Rename() performs file deletion via os.Remove(oldAbsPath), which can target files outside the docs directory
Missing Path Containment in MemoryStore
In internal/storage/memory_store.go, memory operations similarly lack path validation:
// GetInLayer retrieves a memory entry by ID from a specific layer only.
func (ms *MemoryStore) GetInLayer(id, layer string) (*models.MemoryEntry, error) {
// ...
dir, err := ms.dirForLayer(layer)
if err != nil {
return nil, err
}
// VULNERABLE: No containment check for id containing "../"
absPath := filepath.Join(dir, models.MemoryFileName(id))
if _, err := os.Stat(absPath); err != nil {
return nil, fmt.Errorf("memory %q not found in %s layer", id, layer)
}
return ms.parseFile(absPath, layer)
}
// Create writes a new memory entry to the appropriate layer directory.
func (ms *MemoryStore) Create(entry *models.MemoryEntry) error {
// ...
dir, err := ms.dirForLayer(entry.Layer)
if err != nil {
return err
}
if err := os.MkdirAll(dir, 0755); err != nil {
return fmt.Errorf("create memory dir: %w", err)
}
// VULNERABLE: No containment check for entry.ID containing "../"
absPath := filepath.Join(dir, models.MemoryFileName(entry.ID))
return atomicWrite(absPath, []byte(renderMemory(entry)))
}
// Delete removes a memory entry by ID.
func (ms *MemoryStore) Delete(id string) error {
// ...
filename := models.MemoryFileName(id)
dirs := []string{ms.projectDir(), ms.globalDir()}
for _, dir := range dirs {
// VULNERABLE: No containment check
absPath := filepath.Join(dir, filename)
if _, err := os.Stat(absPath); err == nil {
return os.Remove(absPath)
}
}
return fmt.Errorf("memory %q not found", id)
}
Authorization Bypass via Rename-as-Delete
In internal/mcp/handlers/doc.go, the handleDocUpdate() function accepts a newPath parameter that triggers a rename operation:
func handleDocUpdate(getStore func() *storage.Store, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {
// ...
if v, ok := stringArg(args, "newPath"); ok && strings.TrimSpace(v) != "" {
doc.Path = strings.Trim(strings.TrimSuffix(v, ".md"), "/")
}
// ...
if oldPath != doc.Path {
if err := store.Docs.Rename(oldPath, doc); err != nil {
return errFailed("rename doc", err)
}
// ...
}
// ...
}
The Rename() function in doc_store.go performs file deletion:
if oldAbsPath != newAbsPath {
if err := os.Remove(oldAbsPath); err != nil && !os.IsNotExist(err) {
return err
}
}
However, in internal/permissions/registry.go, docs.update is classified as CapWrite:
"docs.update": {Capability: CapWrite, Target: TargetDoc, Risk: RiskMedium},
This allows an attacker with a read-write-no-delete preset (which permits CapWrite but denies CapDelete) to delete files by using docs.update with a newPath parameter.
Attack Vector
| Phase | Request / Action | Effect |
|---|---|---|
| 1. Arbitrary File Read | docs.get with path="../../../victim/secret" |
Server reads file outside project root via path traversal in DocStore.Get(). |
| 2. Arbitrary File Write | docs.create with folder="../../../victim" |
Server writes file outside project root via path traversal in DocStore.Create(). |
| 3. Arbitrary File Delete | docs.update with path="../outside/secret.md" and newPath="../../../victim/renamed.md" |
Server deletes file outside project root via path traversal in DocStore.Rename(). Bypasses CapDelete restriction because docs.update is classified as CapWrite. |
| 4. Memory File Read/Write | memory.update with id="x/../../../../victim/secret" |
Server reads and overwrites file outside project root via path traversal in MemoryStore.Update(). |
Analysis
Classic Path Traversal Pattern
Both DocStore and MemoryStore follow the same vulnerable pattern: user-controlled input is concatenated with a base directory using filepath.Join(), then passed directly to file system operations (os.ReadFile, os.WriteFile, os.Remove, os.Stat) without any validation.
absPath := filepath.Join(baseDir, filepath.FromSlash(userInput))
// No containment check: strings.HasPrefix(absPath, baseDir)
// No rejection of ".." or absolute paths
filepath.Join resolves ../ sequences, allowing attackers to escape the intended directory:
- Input: "../../../etc/passwd"
- Result: /project/.knowns/docs/../../../etc/passwd → /etc/passwd
Rename-as-Delete Authorization Bypass
The Rename() function performs two operations:
1. Write the file to the new location (newAbsPath)
2. Delete the file from the old location (oldAbsPath)
Both paths are vulnerable to traversal. An attacker can:
- Set path to a file outside the project (e.g., "../../../victim/target.md")
- Set newPath to another location outside the project
- The Rename() function will delete the file at path (outside the project)
Because docs.update is classified as CapWrite rather than CapDelete, this operation bypasses deletion restrictions in read-write-no-delete presets.
Compounding Factor - Unauthenticated Access
Due to the previously identified Auth Bypass vulnerability, all MCP tools are accessible without credentials when the server is started without a password, making this a zero-credential attack.
Fix
Patch is available right now at New Release.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 0.29.1"
},
"package": {
"ecosystem": "npm",
"name": "knowns"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "0.30.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-86439"
],
"database_specific": {
"cwe_ids": [
"CWE-22",
"CWE-306",
"CWE-863"
],
"github_reviewed": true,
"github_reviewed_at": "2026-09-25T19:32:05Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "## Overview\n\nVerified. Multiple **Unrestricted Path Traversal** vulnerabilities exist in the Knowns MCP `docs` and `memory` tools, allowing arbitrary file read, write, and deletion operations outside the project sandbox. The storage layer functions (`Get`, `Create`, `Update`, `Rename`, `Delete`) in both `doc_store.go` and `memory_store.go` concatenate user-controlled paths with `filepath.Join()` without any containment validation. \n\nAdditionally, the `docs.update` action with a `newPath` parameter performs a file deletion via `Rename()`, but is classified as `CapWrite` in the permission registry rather than `CapDelete`. This allows an attacker with a `read-write-no-delete` preset to bypass deletion restrictions and destroy arbitrary files outside the project root.\n\n## Affected paths\n\n| File Path | Role | Vulnerability \u0026 Execution Impact |\n| :--- | :--- | :--- |\n| **`internal/storage/doc_store.go`** | Vulnerable Sink (Docs) | **Path Traversal in File Operations (CWE-22):** `Get()`, `Create()`, `Update()`, `Rename()`, `Delete()` join user-controlled `path` with `filepath.Join(ds.docsDir(), ...)` without validating path containment. |\n| **`internal/storage/memory_store.go`** | Vulnerable Sink (Memory) | **Path Traversal in Memory Operations (CWE-22):** `GetInLayer()`, `Create()`, `Update()`, `Delete()` join user-controlled `id` with `filepath.Join(dir, models.MemoryFileName(id))` without validation. |\n| **`internal/mcp/handlers/doc.go`** | Pass-Through Handler | **Unsanitized Input Propagation:** MCP handlers pass user-supplied `path`, `folder`, `newPath` directly to storage layer without sanitization. |\n| **`internal/mcp/handlers/memory.go`** | Pass-Through Handler | **Unsanitized Input Propagation:** MCP handlers pass user-supplied `id` directly to storage layer without sanitization. |\n| **`internal/permissions/registry.go`** | Authorization Bypass | **Capability Misclassification (CWE-863):** `docs.update` with `newPath` performs file deletion but is classified as `CapWrite`, bypassing `CapDelete` restrictions. |\n\n## Root Cause\n\n### Missing Path Containment in DocStore\n\nIn `internal/storage/doc_store.go`, all file operations use `filepath.Join()` to construct absolute paths without validating that the resolved path remains within `docsDir()`:\n\n```go\n// Get retrieves a doc by its relative path (without .md extension).\nfunc (ds *DocStore) Get(path string) (*models.Doc, error) {\n path = strings.TrimPrefix(path, \"/\")\n path = strings.TrimSuffix(path, \".md\")\n\n // VULNERABLE: No containment check\n absPath := filepath.Join(ds.docsDir(), filepath.FromSlash(path)+\".md\")\n if _, err := os.Stat(absPath); err == nil {\n // ...\n return ds.parseFile(absPath, path, folder, false, \"\")\n }\n // ...\n}\n\n// Create writes a new doc to .knowns/docs/{path}.md.\nfunc (ds *DocStore) Create(doc *models.Doc) error {\n if doc.Path == \"\" {\n return fmt.Errorf(\"doc path is required\")\n }\n // VULNERABLE: No containment check\n absPath := filepath.Join(ds.docsDir(), filepath.FromSlash(doc.Path)+\".md\")\n if err := os.MkdirAll(filepath.Dir(absPath), 0755); err != nil {\n return fmt.Errorf(\"create doc dir: %w\", err)\n }\n return ds.writeFile(absPath, doc)\n}\n\n// Rename rewrites a doc to a new path and removes the old file.\nfunc (ds *DocStore) Rename(oldPath string, doc *models.Doc) error {\n // ...\n oldAbsPath := filepath.Join(ds.docsDir(), filepath.FromSlash(strings.TrimSuffix(oldPath, \".md\"))+\".md\")\n newAbsPath := filepath.Join(ds.docsDir(), filepath.FromSlash(strings.TrimSuffix(doc.Path, \".md\"))+\".md\")\n // ...\n if err := ds.writeFile(newAbsPath, doc); err != nil {\n return err\n }\n if oldAbsPath != newAbsPath {\n // VULNERABLE: Deletes file at oldAbsPath (can be outside docsDir)\n if err := os.Remove(oldAbsPath); err != nil \u0026\u0026 !os.IsNotExist(err) {\n return err\n }\n }\n return nil\n}\n\n// Delete removes a doc file.\nfunc (ds *DocStore) Delete(path string) error {\n path = strings.TrimSuffix(path, \".md\")\n // VULNERABLE: No containment check\n absPath := filepath.Join(ds.docsDir(), filepath.FromSlash(path)+\".md\")\n return os.Remove(absPath)\n}\n```\n\n**Critical Flaws:**\n- `filepath.Join` resolves `../` sequences natively\n- No post-Join prefix check (e.g., `strings.HasPrefix(absPath, ds.docsDir())`)\n- No rejection of absolute paths or path traversal sequences\n- `Rename()` performs file deletion via `os.Remove(oldAbsPath)`, which can target files outside the docs directory\n\n### Missing Path Containment in MemoryStore\n\nIn `internal/storage/memory_store.go`, memory operations similarly lack path validation:\n\n```go\n// GetInLayer retrieves a memory entry by ID from a specific layer only.\nfunc (ms *MemoryStore) GetInLayer(id, layer string) (*models.MemoryEntry, error) {\n // ...\n dir, err := ms.dirForLayer(layer)\n if err != nil {\n return nil, err\n }\n // VULNERABLE: No containment check for id containing \"../\"\n absPath := filepath.Join(dir, models.MemoryFileName(id))\n if _, err := os.Stat(absPath); err != nil {\n return nil, fmt.Errorf(\"memory %q not found in %s layer\", id, layer)\n }\n return ms.parseFile(absPath, layer)\n}\n\n// Create writes a new memory entry to the appropriate layer directory.\nfunc (ms *MemoryStore) Create(entry *models.MemoryEntry) error {\n // ...\n dir, err := ms.dirForLayer(entry.Layer)\n if err != nil {\n return err\n }\n if err := os.MkdirAll(dir, 0755); err != nil {\n return fmt.Errorf(\"create memory dir: %w\", err)\n }\n\n // VULNERABLE: No containment check for entry.ID containing \"../\"\n absPath := filepath.Join(dir, models.MemoryFileName(entry.ID))\n return atomicWrite(absPath, []byte(renderMemory(entry)))\n}\n\n// Delete removes a memory entry by ID.\nfunc (ms *MemoryStore) Delete(id string) error {\n // ...\n filename := models.MemoryFileName(id)\n\n dirs := []string{ms.projectDir(), ms.globalDir()}\n for _, dir := range dirs {\n // VULNERABLE: No containment check\n absPath := filepath.Join(dir, filename)\n if _, err := os.Stat(absPath); err == nil {\n return os.Remove(absPath)\n }\n }\n\n return fmt.Errorf(\"memory %q not found\", id)\n}\n```\n\n### Authorization Bypass via Rename-as-Delete\n\nIn `internal/mcp/handlers/doc.go`, the `handleDocUpdate()` function accepts a `newPath` parameter that triggers a rename operation:\n\n```go\nfunc handleDocUpdate(getStore func() *storage.Store, req mcp.CallToolRequest) (*mcp.CallToolResult, error) {\n // ...\n if v, ok := stringArg(args, \"newPath\"); ok \u0026\u0026 strings.TrimSpace(v) != \"\" {\n doc.Path = strings.Trim(strings.TrimSuffix(v, \".md\"), \"/\")\n }\n // ...\n if oldPath != doc.Path {\n if err := store.Docs.Rename(oldPath, doc); err != nil {\n return errFailed(\"rename doc\", err)\n }\n // ...\n }\n // ...\n}\n```\n\nThe `Rename()` function in `doc_store.go` performs file deletion:\n\n```go\nif oldAbsPath != newAbsPath {\n if err := os.Remove(oldAbsPath); err != nil \u0026\u0026 !os.IsNotExist(err) {\n return err\n }\n}\n```\n\nHowever, in `internal/permissions/registry.go`, `docs.update` is classified as `CapWrite`:\n\n```go\n\"docs.update\": {Capability: CapWrite, Target: TargetDoc, Risk: RiskMedium},\n```\n\nThis allows an attacker with a `read-write-no-delete` preset (which permits `CapWrite` but denies `CapDelete`) to delete files by using `docs.update` with a `newPath` parameter.\n\n## Attack Vector\n\n| Phase | Request / Action | Effect |\n| :--- | :--- | :--- |\n| **1. Arbitrary File Read** | `docs.get` with `path=\"../../../victim/secret\"` | Server reads file outside project root via path traversal in `DocStore.Get()`. |\n| **2. Arbitrary File Write** | `docs.create` with `folder=\"../../../victim\"` | Server writes file outside project root via path traversal in `DocStore.Create()`. |\n| **3. Arbitrary File Delete** | `docs.update` with `path=\"../outside/secret.md\"` and `newPath=\"../../../victim/renamed.md\"` | Server deletes file outside project root via path traversal in `DocStore.Rename()`. Bypasses `CapDelete` restriction because `docs.update` is classified as `CapWrite`. |\n| **4. Memory File Read/Write** | `memory.update` with `id=\"x/../../../../victim/secret\"` | Server reads and overwrites file outside project root via path traversal in `MemoryStore.Update()`. |\n\n## Analysis\n\n### Classic Path Traversal Pattern\n\nBoth `DocStore` and `MemoryStore` follow the same vulnerable pattern: user-controlled input is concatenated with a base directory using `filepath.Join()`, then passed directly to file system operations (`os.ReadFile`, `os.WriteFile`, `os.Remove`, `os.Stat`) without any validation.\n\n```go\nabsPath := filepath.Join(baseDir, filepath.FromSlash(userInput))\n// No containment check: strings.HasPrefix(absPath, baseDir)\n// No rejection of \"..\" or absolute paths\n```\n\n`filepath.Join` resolves `../` sequences, allowing attackers to escape the intended directory:\n- Input: `\"../../../etc/passwd\"`\n- Result: `/project/.knowns/docs/../../../etc/passwd` \u2192 `/etc/passwd`\n\n### Rename-as-Delete Authorization Bypass\n\nThe `Rename()` function performs two operations:\n1. Write the file to the new location (`newAbsPath`)\n2. Delete the file from the old location (`oldAbsPath`)\n\nBoth paths are vulnerable to traversal. An attacker can:\n- Set `path` to a file outside the project (e.g., `\"../../../victim/target.md\"`)\n- Set `newPath` to another location outside the project\n- The `Rename()` function will delete the file at `path` (outside the project)\n\nBecause `docs.update` is classified as `CapWrite` rather than `CapDelete`, this operation bypasses deletion restrictions in `read-write-no-delete` presets.\n\n### Compounding Factor - Unauthenticated Access\n\nDue to the previously identified **Auth Bypass** vulnerability, all MCP tools are accessible without credentials when the server is started without a password, making this a zero-credential attack.\n\n## Fix\n\n*Patch is available right now at [New Release](https://github.com/knowns-dev/knowns/releases).*",
"id": "GHSA-9gfj-28hw-jchp",
"modified": "2026-09-25T19:32:05Z",
"published": "2026-09-25T19:32:05Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/knowns-dev/knowns/security/advisories/GHSA-9gfj-28hw-jchp"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-86439"
},
{
"type": "WEB",
"url": "https://github.com/knowns-dev/knowns/commit/09c5a96fd5817b941dc86669278c1a17db10ed4e"
},
{
"type": "PACKAGE",
"url": "https://github.com/knowns-dev/knowns"
},
{
"type": "WEB",
"url": "https://github.com/knowns-dev/knowns/blob/v0.29.1/internal/storage/doc_store.go#L124-L129"
},
{
"type": "WEB",
"url": "https://github.com/knowns-dev/knowns/blob/v0.29.1/internal/storage/memory_store.go#L203-L211"
},
{
"type": "WEB",
"url": "https://github.com/knowns-dev/knowns/releases/tag/v0.30.0"
},
{
"type": "WEB",
"url": "https://www.vulncheck.com/advisories/knowns-before-0.30.0-path-traversal-via-mcp-doc-and-memory-tools"
}
],
"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"
}
],
"summary": "Knowns Unrestricted Path Traversal leading to out-of-bounds arbitrary .md file read, write, and deletion in MCP Docs + Memory Tools"
}
GHSA-9GFM-WP7R-H4WP
Vulnerability from github – Published: 2022-05-17 00:19 – Updated: 2022-05-17 00:19Directory traversal vulnerability in edituser.php in ImpressCMS 1.2.x before 1.2.7 Final and 1.3.x before 1.3.1 Final allows remote authenticated users to include and execute arbitrary local files via a .. (dot dot) in the icmsConfigPlugins[sanitizer_plugins][] parameter.
{
"affected": [],
"aliases": [
"CVE-2012-0987"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": false,
"github_reviewed_at": null,
"nvd_published_at": "2012-10-06T21:55:00Z",
"severity": "MODERATE"
},
"details": "Directory traversal vulnerability in edituser.php in ImpressCMS 1.2.x before 1.2.7 Final and 1.3.x before 1.3.1 Final allows remote authenticated users to include and execute arbitrary local files via a .. (dot dot) in the icmsConfigPlugins[sanitizer_plugins][] parameter.",
"id": "GHSA-9gfm-wp7r-h4wp",
"modified": "2022-05-17T00:19:31Z",
"published": "2022-05-17T00:19:31Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2012-0987"
},
{
"type": "WEB",
"url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/72146"
},
{
"type": "WEB",
"url": "https://www.htbridge.com/advisory/HTB23064"
},
{
"type": "WEB",
"url": "http://archives.neohapsis.com/archives/bugtraq/2012-01/0022.html"
},
{
"type": "WEB",
"url": "http://community.impresscms.org/modules/smartsection/item.php?itemid=579"
},
{
"type": "WEB",
"url": "http://secunia.com/advisories/47448"
},
{
"type": "WEB",
"url": "http://www.osvdb.org/78143"
},
{
"type": "WEB",
"url": "http://www.securityfocus.com/bid/51268"
}
],
"schema_version": "1.4.0",
"severity": []
}
GHSA-9GGW-H9MF-4JH7
Vulnerability from github – Published: 2023-10-25 18:32 – Updated: 2023-11-02 16:50Jenkins CloudBees CD Plugin temporarily copies files from an agent workspace to the controller in preparation for publishing them in the 'CloudBees CD - Publish Artifact' post-build step.
CloudBees CD Plugin 1.1.32 and earlier follows symbolic links to locations outside of the temporary directory on the controller when collecting the list of files to publish.
This allows attackers able to configure jobs to publish arbitrary files from the Jenkins controller file system to the previously configured CloudBees CD server.
CloudBees CD Plugin 1.1.33 ensures that only files located within the expected directory are published.
{
"affected": [
{
"package": {
"ecosystem": "Maven",
"name": "org.jenkins-ci.plugins:electricflow"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.1.33"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2023-46655"
],
"database_specific": {
"cwe_ids": [
"CWE-22",
"CWE-59"
],
"github_reviewed": true,
"github_reviewed_at": "2023-10-30T15:02:06Z",
"nvd_published_at": "2023-10-25T18:17:40Z",
"severity": "MODERATE"
},
"details": "Jenkins CloudBees CD Plugin temporarily copies files from an agent workspace to the controller in preparation for publishing them in the \u0027CloudBees CD - Publish Artifact\u0027 post-build step.\n\nCloudBees CD Plugin 1.1.32 and earlier follows symbolic links to locations outside of the temporary directory on the controller when collecting the list of files to publish.\n\nThis allows attackers able to configure jobs to publish arbitrary files from the Jenkins controller file system to the previously configured CloudBees CD server.\n\nCloudBees CD Plugin 1.1.33 ensures that only files located within the expected directory are published.",
"id": "GHSA-9ggw-h9mf-4jh7",
"modified": "2023-11-02T16:50:54Z",
"published": "2023-10-25T18:32:25Z",
"references": [
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2023-46655"
},
{
"type": "WEB",
"url": "https://github.com/jenkinsci/electricflow-plugin/commit/e45ca8428ae45f45ca07611e802eaa0f1484ab50"
},
{
"type": "PACKAGE",
"url": "https://github.com/jenkinsci/electricflow-plugin"
},
{
"type": "WEB",
"url": "https://www.jenkins.io/security/advisory/2023-10-25/#SECURITY-3238"
},
{
"type": "WEB",
"url": "http://www.openwall.com/lists/oss-security/2023/10/25/2"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
],
"summary": "Jenkins CloudBees CD Plugin vulnerable to arbitrary file read"
}
GHSA-9GH8-9R95-3FC3
Vulnerability from github – Published: 2025-09-02 17:12 – Updated: 2025-09-02 17:12Summary
The vulnerability allows any user to overwrite any files available under the account privileges of the running process.
Details
As part of static analysis, iOS MobSF supports loading and parsing statically linked libraries .a. When parsing such archives, the code extracts the embedded objects to the file system in the working directory of the analysis. The problem is that the current implementation does not prohibit absolute file names inside .a. If an archive item has a name like /abs/path/to/file, the resulting path is constructed as Path(dst) /name; for absolute paths, this leads to a complete substitution of the destination directory: writing occurs directly to the specified absolute directory. the path (outside the working directory).
Thus, an authenticated user who uploaded a specially prepared .a, can write arbitrary files to any directory writable by the user of the MobSF process (for example, /tmp, neighboring directories inside ~/.MobSF, etc.).
The key reason is that checking the "sliding" paths only takes into account the presence of .. (relative traversal), but does not take into account the absoluteness of the name and does not compare the normalized target path with the root directory of the extraction.
What exactly is vulnerable:
mobsf/StaticAnalyzer/views/common/shared_func.py
Function for extracting objects from .a — ar_extract
def ar_extract(checksum, src, dst):
"""Extract AR archive."""
...
ar = arpy.Archive(src)
ar.read_all_headers()
for a, val in ar.archived_files.items():
# Handle archive slip attacks
filtered = a.decode('utf-8', 'ignore')
if is_path_traversal(filtered):
msg = f'Zip slip detected. skipped extracting {filtered}'
logger.warning(msg)
append_scan_status(checksum, msg)
continue
out = Path(dst) / filtered
out.write_bytes(val.read())
- The “slip” check is limited to is_path_traversal(filtered), which looks only for traversal patterns like
..,%2e%2e,%252e. - Therefore, if the .a archive contains a member named '/tmp/pwned.txt', MobSF will write it to
/tmp/pwned.txt, outside the intended working directory.
ar_extract is called from: mobsf/StaticAnalyzer/views/common/a.py
def extract_n_get_files(checksum, src, dst):
dst = Path(dst) / 'static_objects'
dst.mkdir(parents=True, exist_ok=True)
ar_extract(checksum, src, dst.as_posix())
The expectation is that extraction happens only under the static_objects subdirectory, but absolute file names inside the .a break this assumption by directing writes outside that directory.
Attack Scenario
- The attacker creates a valid AR archive.a, in which the name of one of the members is the absolute path (as an example) /home/mobsf/.MobSF/db.sqlite3. This is done by the standard AR (GNU long filename table) mechanism.
- It downloads this one via the web interface or the Static library loading API
.ain MobSF. - During the analysis, MobSF extracts the contents: due to the absolute name, the resulting path becomes /home/mobsf/.MobSF/db.sqlite3, and the file is created/overwritten outside the working directory.
- In our case, the database file was overwritten, which caused MobSF to malfunction.
PoC
-
Using the script, create a file with the payload. In the example, this is "/home/mobsf/.MobSF/db.sqlite3"
-
Connect to the container and verify that the db.sqlite3 file is a database. The scan has not been performed yet.
-
Upload the file for scanning and then update the page to get a server error.
-
Check the file structure after scanning and see that the file has been overwritten.
-
There is a database error in the MobSF log.
Impact
- Arbitrary writing/overwriting of files within the rights of the MobSF process (for example, /tmp, directories with analysis results, logs).
- Distortion of analysis results (substitution of artifacts) and undermining the integrity of reports.
- Implementation of a system malfunction (overwriting the db.sqlite3 file).
- Compromise of the UI (if you have write rights to statics/templates): Stored XSS by overwriting the plug-in.js/template.
- Potential escalation of risks with lax configuration of containers/rights (for example, writing to system paths inside the container if the process is running with excessive privileges).
Mitigation
Reject absolute paths and normalize before writing.
Please, assign all credits to Vasily Leshchenko (Solar AppSec)
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 4.4.0"
},
"package": {
"ecosystem": "PyPI",
"name": "mobsf"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "4.4.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2025-58162"
],
"database_specific": {
"cwe_ids": [
"CWE-22"
],
"github_reviewed": true,
"github_reviewed_at": "2025-09-02T17:12:52Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "### Summary\nThe vulnerability allows any user to overwrite any files available under the account privileges of the running process.\n\n### Details\nAs part of static analysis, iOS MobSF supports loading and parsing statically linked libraries `.a`. When parsing such archives, the code extracts the embedded objects to the file system in the working directory of the analysis. The problem is that the current implementation does not prohibit absolute file names inside `.a`. If an archive item has a name like /abs/path/to/file, the resulting path is constructed as Path(dst) /name; for absolute paths, this leads to a complete substitution of the destination directory: writing occurs directly to the specified absolute directory. the path (outside the working directory).\n\nThus, an authenticated user who uploaded a specially prepared `.a`, can write arbitrary files to any directory writable by the user of the MobSF process (for example, `/tmp`, neighboring directories inside `~/.MobSF`, etc.).\n\nThe key reason is that checking the \"sliding\" paths only takes into account the presence of `..` (relative traversal), but does not take into account the absoluteness of the name and does not compare the normalized target path with the root directory of the extraction.\n\n### What exactly is vulnerable:\n**mobsf/StaticAnalyzer/views/common/shared_func.py**\nFunction for extracting objects from `.a` \u2014 ar_extract\n```\ndef ar_extract(checksum, src, dst):\n \"\"\"Extract AR archive.\"\"\"\n ...\n ar = arpy.Archive(src)\n ar.read_all_headers()\n for a, val in ar.archived_files.items():\n # Handle archive slip attacks\n filtered = a.decode(\u0027utf-8\u0027, \u0027ignore\u0027)\n if is_path_traversal(filtered):\n msg = f\u0027Zip slip detected. skipped extracting {filtered}\u0027\n logger.warning(msg)\n append_scan_status(checksum, msg)\n continue\n out = Path(dst) / filtered\n out.write_bytes(val.read())\n```\n- The \u201cslip\u201d check is limited to is_path_traversal(filtered), which looks only for traversal patterns like `..`, `%2e%2e`, `%252e`.\n- Therefore, if the .a archive contains a member named \u0027/tmp/pwned.txt\u0027, MobSF will write it to `/tmp/pwned.txt`, outside the intended working directory.\n\nar_extract is called from:\n**mobsf/StaticAnalyzer/views/common/a.py**\n```\ndef extract_n_get_files(checksum, src, dst):\n dst = Path(dst) / \u0027static_objects\u0027\n dst.mkdir(parents=True, exist_ok=True)\n ar_extract(checksum, src, dst.as_posix())\n```\nThe expectation is that extraction happens only under the static_objects subdirectory, but absolute file names inside the `.a` break this assumption by directing writes outside that directory.\n\n### Attack Scenario\n1. The attacker creates a valid AR archive.a, in which the name of one of the members is the absolute path (as an example) /home/mobsf/.MobSF/db.sqlite3. This is done by the standard AR (GNU long filename table) mechanism.\n2. It downloads this one via the web interface or the Static library loading API `.a` in MobSF.\n3. During the analysis, MobSF extracts the contents: due to the absolute name, the resulting path becomes /home/mobsf/.MobSF/db.sqlite3, and the file is created/overwritten outside the working directory.\n4. In our case, the database file was overwritten, which caused MobSF to malfunction.\n### PoC\n1. Using the script, create a file with the payload. In the example, this is \"/home/mobsf/.MobSF/db.sqlite3\"\n\u003cimg width=\"786\" height=\"342\" alt=\"image\" src=\"https://github.com/user-attachments/assets/0b7aee5c-6938-45cc-b668-9ad19f48c2c5\" /\u003e\n\n2. Connect to the container and verify that the db.sqlite3 file is a database. The scan has not been performed yet.\n\u003cimg width=\"2535\" height=\"1507\" alt=\"image\" src=\"https://github.com/user-attachments/assets/0cc92da7-91c0-453f-b1ed-080c9cfaa7f1\" /\u003e\n\n3. Upload the file for scanning and then update the page to get a server error.\n\u003cimg width=\"2559\" height=\"1476\" alt=\"image\" src=\"https://github.com/user-attachments/assets/a5b84ace-b853-46ad-9e2e-afad59ed058a\" /\u003e\n\n4. Check the file structure after scanning and see that the file has been overwritten.\n\u003cimg width=\"797\" height=\"213\" alt=\"image\" src=\"https://github.com/user-attachments/assets/758ba3da-ae25-4c8d-bd8b-932573ca2306\" /\u003e\n\n5. There is a database error in the MobSF log.\n\u003cimg width=\"1724\" height=\"1476\" alt=\"image\" src=\"https://github.com/user-attachments/assets/cd4211b1-2896-45e0-9934-9425b6035f2a\" /\u003e\n\n### Impact\n1. Arbitrary writing/overwriting of files within the rights of the MobSF process (for example, /tmp, directories with analysis results, logs).\n2. Distortion of analysis results (substitution of artifacts) and undermining the integrity of reports.\n3. Implementation of a system malfunction (overwriting the db.sqlite3 file).\n4. Compromise of the UI (if you have write rights to statics/templates): Stored XSS by overwriting the plug-in.js/template.\n5. Potential escalation of risks with lax configuration of containers/rights (for example, writing to system paths inside the container if the process is running with excessive privileges).\n\n\n### Mitigation\nReject absolute paths and normalize before writing. \n\n\n\n### **Please, assign all credits to Vasily Leshchenko (Solar AppSec)**",
"id": "GHSA-9gh8-9r95-3fc3",
"modified": "2025-09-02T17:12:52Z",
"published": "2025-09-02T17:12:52Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/MobSF/Mobile-Security-Framework-MobSF/security/advisories/GHSA-9gh8-9r95-3fc3"
},
{
"type": "WEB",
"url": "https://github.com/MobSF/Mobile-Security-Framework-MobSF/commit/7f3bc086c028c1b50889cab8a15f7b59b7abdaf9"
},
{
"type": "PACKAGE",
"url": "https://github.com/MobSF/Mobile-Security-Framework-MobSF"
},
{
"type": "WEB",
"url": "https://github.com/MobSF/Mobile-Security-Framework-MobSF/releases/tag/v4.4.1"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:N/I:H/A:H",
"type": "CVSS_V3"
}
],
"summary": "MobSF Vulnerable to Arbitrary File Write (AR-Slip) via Absolute Path in .a Extraction"
}
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.