/

CVE-2026-86542

Severity:

CRITICAL RISK

(9.1)

Path Traversal (CWE-22) in knowns Import Route Handler

CVE-2026-86542

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Arbitrary File Overwrite

Severity:

CRITICAL RISK

(9.1)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A critical path traversal vulnerability in knowns allows unauthenticated attackers to escape the intended imports directory by supplying crafted import names. Successful exploitation may let attackers overwrite arbitrary files that are writable by the server process.

Affected context

The vulnerability occurs in knowns import routes when user-controlled name parameters are used to construct filesystem paths without sufficient validation. It becomes risky when the application accepts unauthenticated requests, resolves paths relative to an imports directory, and runs with permission to modify files beyond that directory.

Exploit preconditions

  • Attack surface: The knowns import routes exposed by the application
  • Required access: No authentication may be required
  • Trigger point: Processing an import request containing a name parameter
  • Why exploitation is possible: Traversal sequences can cause the resolved path to escape the intended imports directory
  • Required environmental condition: The server process must have write permission for the targeted file

Why this happens

The underlying bug is insufficient validation and containment of a user-controlled filesystem path component. When an import name is incorporated into a path without canonicalization and verification that the final location remains within the permitted directory, traversal sequences can alter the resolved destination. This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal.

Potential impact

  • Attackers may overwrite files writable by the server process
  • Application availability could be disrupted through configuration or data corruption
  • Server behavior may be altered if executable or startup-related files are writable
  • Sensitive data could be damaged or replaced
  • The vulnerability could contribute to further compromise depending on process privileges and deployment controls

General mitigation guidance

Mitigation generally focuses on reducing trust in user-controlled path components and enforcing directory containment.

Common defensive patterns include:

  • Accepting only opaque identifiers or allowlisted filenames rather than arbitrary path-like names
  • Canonicalizing candidate paths and verifying that the resolved path remains beneath the intended imports directory
  • Rejecting traversal syntax, absolute paths, symlink escapes, and unexpected separators
  • Using filesystem APIs that support constrained directory operations where available
  • Running the service with the minimum filesystem permissions required
  • Separating import storage from sensitive application and system paths
  • Applying secure defaults that deny writes when path validation is ambiguous

How teams detect issues like this

Organizations can detect related weaknesses through:

  • Static analysis rules for string concatenation or interpolation used in filesystem paths
  • Code review checks for missing canonicalization and directory-containment validation
  • Tests covering traversal sequences, absolute paths, encoded separators, symlinks, and normalization edge cases
  • Runtime monitoring for unexpected write locations or anomalous import route activity
  • Policy enforcement that restricts server processes from writing outside designated data directories
  • Automated security review tools that flag user-controlled input reaching file APIs

Sources

SourceLink
github.comgithub.com/knowns-dev/knowns/blob/v0.29.1/internal/server/routes/imports.go#L376-L420
github.comgithub.com/knowns-dev/knowns/blob/v0.29.1/internal/server/routes/imports.go#L519-L551
github.comgithub.com/knowns-dev/knowns/commit/d3989829fb5095666d23d005b2f78a082832a396
github.comgithub.com/knowns-dev/knowns/releases/tag/v0.30.0
github.comgithub.com/knowns-dev/knowns/security/advisories/GHSA-wh3c-v55g-qfg8
vulncheck.comvulncheck.com/advisories/knowns-before-0.30.0-path-traversal-via-import-name

Frequently asked

questions

Yes. The issue can be remotely exploitable when the vulnerable import routes are reachable over the network and do not require authentication.

The attacker generally needs network access to the import endpoint, but does not need an account if the route is unauthenticated. The targeted file must also be writable by the server process.

Treat import names as untrusted identifiers, use strict allowlists, canonicalize resolved paths, and verify that they remain inside the designated imports directory before performing any write.

Combine secure path-handling APIs, least-privilege filesystem permissions, negative and boundary-focused tests, code review rules, and monitoring for writes outside approved storage locations.

Find out what's already
exploitable in your codebase.