ollama - 💡(How to fix) Fix CORS file://* origin combined with AllowWildcard=true — any local HTML file can access API

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

The CORS configuration uses wildcard scheme origins including file://* and app://*. The file://* origin is especially dangerous because:

  1. Any HTML file opened from the local filesystem (via file:// protocol) can make authenticated cross-origin requests to Ollama
  2. Malicious HTML files (e.g., downloaded from email, messaging apps, or malicious sites) that are opened locally can access the Ollama API
  3. The AllowWildcard = true setting means credentials are sent with requests from any origin

Root Cause

Description

The CORS configuration uses wildcard scheme origins including file://* and app://*. The file://* origin is especially dangerous because:

Code Example

origins = append(origins,
    "app://*",
    "file://*",
    "tauri://*",
    "vscode-webview://*",
    "vscode-file://*",
)

---

corsConfig.AllowWildcard = true

---

// Remove file://* from allowed origins, or restrict to specific paths
// Consider requiring explicit opt-in for file:// origins
// At minimum, document the risk of file://* in the CORS configuration
origins = append(origins,
    "app://*",
    // "file://*",  // ← Remove this — too broad
    "tauri://*",
    "vscode-webview://*",
    "vscode-file://*",
)
RAW_BUFFERClick to expand / collapse

CWE-942: Overly Broad CORS Scheme Origins — file://, app://, tauri://*

Severity: MEDIUM (CVSS 5.3)

Location

envconfig/config.goAllowedOrigins():

origins = append(origins,
    "app://*",
    "file://*",
    "tauri://*",
    "vscode-webview://*",
    "vscode-file://*",
)

Combined with routes.go:

corsConfig.AllowWildcard = true

Description

The CORS configuration uses wildcard scheme origins including file://* and app://*. The file://* origin is especially dangerous because:

  1. Any HTML file opened from the local filesystem (via file:// protocol) can make authenticated cross-origin requests to Ollama
  2. Malicious HTML files (e.g., downloaded from email, messaging apps, or malicious sites) that are opened locally can access the Ollama API
  3. The AllowWildcard = true setting means credentials are sent with requests from any origin

Impact

A local attacker who can get a user to open an HTML file can:

  • List all models (/api/tags)
  • Run inference on any loaded model
  • Pull new models
  • Delete models
  • Access experimental web search (SSRF amplification)

Remediation

// Remove file://* from allowed origins, or restrict to specific paths
// Consider requiring explicit opt-in for file:// origins
// At minimum, document the risk of file://* in the CORS configuration
origins = append(origins,
    "app://*",
    // "file://*",  // ← Remove this — too broad
    "tauri://*",
    "vscode-webview://*",
    "vscode-file://*",
)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

ollama - 💡(How to fix) Fix CORS file://* origin combined with AllowWildcard=true — any local HTML file can access API