GHSA-WH3C-V55G-QFG8
Unauthenticated Remote Code Execution via REST API Path Traversal + LSP Binary Override
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-WH3C-V55G-QFG8 divulgada · CVSS 9.8 (GitHub) | |
| Remediación | Parche 0.30.0 | knowns · 0 d desde divulgación | |
| Divulgación | Modificada | Última actualización del registro | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Overview
Verified. A fully unauthenticated Remote Code Execution chain exists in the default deployment of Knowns, requiring exactly two HTTP requests. An attacker plants a malicious script into the filesystem via a path traversal in the import API (Flaw A), then overrides the LSP binary path to a malicious executable or shell (Flaw B). The LSP manager subsequently executes the overridden binary when starting or restarting the language server. The chain can be exploited end-to-end without credentials, prior access, or user interaction.
Affected paths
| File Path | Role | Vulnerability & Execution Impact |
| :--- | :--- | :--- |
| `internal/server/routes/imports.go` | Entry Point (Flaw A) | Import Name Path Traversal (CWE-22 / CWE-73): `filepath.Join(ir.importsDir(), name)` builds the clone/destination directory from an attacker-controlled `name` with no post-Join containment check. Allows writing files (including payload scripts) to arbitrary filesystem locations. |
| `internal/lsp/manager.go` | Execution Sink (Flaw B) | Unvalidated LSP Binary Override (CWE-78 / CWE-94): The manager accepts `BinaryOverride` via config and passes it to `exec.LookPath` and the server execution pipeline without allowlist or path validation. Setting the override to a planted script or `/bin/sh` causes the LSP process to execute the attacker's payload. |
| `internal/server/auth.go` | Compounding Factor | Authentication Disabled by Default (CWE-306): `AuthManager.Middleware` is a no-op when `!am.HasPassword()`. Both vulnerable endpoints are reachable without credentials if the server is started without a password. |
Root Cause
Flaw A - Import name path traversal
In `internal/server/routes/imports.go`, the destination directory is built with:
destBase := filepath.Join(ir.importsDir(), name) // In gitCloneImport
// OR
destDir := filepath.Join(ir.importsDir(), name) // In add() for non-git`name` is taken directly from the request body. `filepath.Join` resolves `../` sequences natively - it does not enforce that the final path remains inside `importsDir()`. There is no post-Join prefix check (e.g., `strings.HasPrefix`). Supplying a value such as `../../../../../tmp/knowns-lsp-workdir` writes the imported files to an arbitrary location outside the intended imports sandbox.
Flaw B - Unvalidated LSP binary override
The LSP manager accepts a binary override for a language and uses it to override the default binary candidates:
if override := m.config.BinaryOverride(langID); override != "" {
binaries = []BinaryCandidate{{Name: override}}
}
// ...
for _, b := range binaries {
path, err := exec.LookPath(b.Name)
// ...
cmd := ServerCommand{
Language: langID,
Name: b.Name,
Path: path,
// ...
}
return m.startCommand(ctx, langID, cmd)
}Setting the override to an absolute path of a planted script or a shell interpreter causes the LSP manager to execute it when the language server is started or restarted. Neither the config validation nor the manager rejects absolute paths, shell interpreters, or paths outside a managed binary directory.
Compounding factor - No authentication by default
When the password is not set, `AuthManager.Middleware` bypasses authentication entirely:
if am == nil || !am.HasPassword() {
next.ServeHTTP(w, r)
return
}Both vulnerable endpoints are fully reachable without credentials in the default deployment.
Attack Vector
| Phase | Request | Effect |
| :--- | :--- | :--- |
| 1. Plant | `POST /api/imports` with traversal `name` | Malicious script written into an arbitrary directory (e.g., LSP working directory or a known executable path) |
| 2. Configure | `PATCH /api/lsp/languages/{lang}/config` with `binary=/path/to/payload` | LSP binary overridden; language server restarts or starts |
| 3. Execute | Automatic | `StartLanguage` / `startCommand` invokes the overridden binary → payload executes |
Preconditions: Knowns running with default config (no password set); server network-reachable; attacker can host a git repository containing a payload script (for Flaw A) or write to a writable directory; LSP enabled for at least one language.
Analysis
Flaw A - `imports.go`
The handler takes `name` from the JSON body and passes it directly to `filepath.Join`:
// internal/server/routes/imports.go (vulnerable sink)
// `name` is attacker-controlled; no sanitization or containment check is performed.
destBase := filepath.Join(ir.importsDir(), name) // Used in gitCloneImport
// OR
destDir := filepath.Join(ir.importsDir(), name) // Used in add()
// filepath.Join resolves `../` natively - the traversal escapes importsDir() successfully.
// No strings.HasPrefix(dest, ir.importsDir()) guard exists before the clone/write is performed.Flaw B - `lsp/manager.go`
The config endpoint stores `BinaryOverride` and the manager applies it without validation:
// internal/lsp/manager.go (vulnerable sink)
// BinaryOverride is applied with no allowlist or path validation.
if override := m.config.BinaryOverride(langID); override != "" {
binaries = []BinaryCandidate{{Name: override}}
}
// The override is passed to exec.LookPath and executed as the LSP server.
// With override="/bin/sh" or a planted script, the shell/payload starts
// when the language server is launched or restarted.
// There is absolutely no containment guard between the attacker-supplied
// string and the ServerCommand execution.Compounding factor - `auth.go`
The middleware explicitly skips authentication checks if no password is configured:
// internal/server/auth.go
func (am *AuthManager) Middleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if am == nil || !am.HasPassword() {
next.ServeHTTP(w, r) // Bypasses auth completely
return
}
// ...Fix
*Patch is available right now at New Release https://github.com/knowns-dev/knowns/releases.*
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmknowns |
Corregida | 0.30.0 | 0 d | 0.35.0 no afectada |
0.30.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/knowns-dev/knowns/security/advisories/GHSA-wh3c-v55g-qfg8Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
