ollama - 💡(How to fix) Fix [MEDIUM] Overly permissive CORS configuration allows wildcard origins

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 is highly permissive. The server sets AllowWildcard = true and the default AllowedOrigins() includes port wildcards and dangerous origins:

"http://127.0.0.1:*",      // PORT WILDCARD
"https://127.0.0.1:*",     // PORT WILDCARD
"http://0.0.0.0:*",        // PORT WILDCARD
"https://0.0.0.0:*",       // PORT WILDCARD
"app://*",
"file://*",                // ANY local HTML file
"tauri://*",
"vscode-webview://*",
"vscode-file://*",

Key concerns:

  1. Port wildcard * -- any local port is accepted as a valid CORS origin
  2. file://* -- any local HTML file opened in a browser can make cross-origin requests to the ollama API
  3. AllowWildcard = true combined with custom origins -- browser behavior can be unpredictable across versions

Root Cause

The CORS configuration is highly permissive. The server sets AllowWildcard = true and the default AllowedOrigins() includes port wildcards and dangerous origins:

"http://127.0.0.1:*",      // PORT WILDCARD
"https://127.0.0.1:*",     // PORT WILDCARD
"http://0.0.0.0:*",        // PORT WILDCARD
"https://0.0.0.0:*",       // PORT WILDCARD
"app://*",
"file://*",                // ANY local HTML file
"tauri://*",
"vscode-webview://*",
"vscode-file://*",

Key concerns:

  1. Port wildcard * -- any local port is accepted as a valid CORS origin
  2. file://* -- any local HTML file opened in a browser can make cross-origin requests to the ollama API
  3. AllowWildcard = true combined with custom origins -- browser behavior can be unpredictable across versions

Code Example

"http://127.0.0.1:*",      // PORT WILDCARD
"https://127.0.0.1:*",     // PORT WILDCARD
"http://0.0.0.0:*",        // PORT WILDCARD
"https://0.0.0.0:*",       // PORT WILDCARD
"app://*",
"file://*",                // ANY local HTML file
"tauri://*",
"vscode-webview://*",
"vscode-file://*",
RAW_BUFFERClick to expand / collapse

Severity: MEDIUM -- CVSS 5.3

Location: server/routes.go (GenerateRoutes), envconfig/config.go (AllowedOrigins) Category: CORS Misconfiguration Confidence: Certain CWE: CWE-942 MITRE ATT&CK: T1090.001, T1213

Description

The CORS configuration is highly permissive. The server sets AllowWildcard = true and the default AllowedOrigins() includes port wildcards and dangerous origins:

"http://127.0.0.1:*",      // PORT WILDCARD
"https://127.0.0.1:*",     // PORT WILDCARD
"http://0.0.0.0:*",        // PORT WILDCARD
"https://0.0.0.0:*",       // PORT WILDCARD
"app://*",
"file://*",                // ANY local HTML file
"tauri://*",
"vscode-webview://*",
"vscode-file://*",

Key concerns:

  1. Port wildcard * -- any local port is accepted as a valid CORS origin
  2. file://* -- any local HTML file opened in a browser can make cross-origin requests to the ollama API
  3. AllowWildcard = true combined with custom origins -- browser behavior can be unpredictable across versions

Impact

  • A local HTML file with embedded JavaScript (opened from downloads, email attachment) can make requests to the ollama API
  • Malicious browser extensions or Electron apps can exploit the permissive CORS to interact with ollama
  • Combined with the "no auth by default" finding, this enables silent model abuse from any local webpage

Remediation

  1. Remove port wildcards -- specify exact ports or use 127.0.0.1 without port
  2. Remove file://* origin -- it is almost never needed legitimately
  3. Set AllowWildcard = false when custom origins are specified
  4. Document that OLLAMA_ORIGINS should be set to specific origins in production

Found as part of a broader security audit of ollama/ollama.

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