ollama - 💡(How to fix) Fix Gin DebugMode is the default — error stack traces leak internal paths to API clients

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…

Ollama's HTTP server defaults to Gin's DebugMode. In debug mode, Gin returns detailed error pages containing:

  • Full stack traces with file paths and line numbers
  • Internal server paths (e.g., /home/user/.ollama/...)
  • Framework internals

Every panic or unhandled error leaks implementation details to any client making requests. There is no environment variable to switch to ReleaseMode — the mode variable is hardcoded.

Error Message

Ollama's HTTP server defaults to Gin's DebugMode. In debug mode, Gin returns detailed error pages containing: Every panic or unhandled error leaks implementation details to any client making requests. There is no environment variable to switch to ReleaseMode — the mode variable is hardcoded.

Root Cause

Ollama's HTTP server defaults to Gin's DebugMode. In debug mode, Gin returns detailed error pages containing:

  • Full stack traces with file paths and line numbers
  • Internal server paths (e.g., /home/user/.ollama/...)
  • Framework internals

Every panic or unhandled error leaks implementation details to any client making requests. There is no environment variable to switch to ReleaseMode — the mode variable is hardcoded.

Code Example

var mode string = gin.DebugMode

---

// Set mode based on environment
if os.Getenv("OLLAMA_DEBUG") == "" {
    mode = gin.ReleaseMode
}
// Or at minimum, make it configurable:
if v := os.Getenv("OLLAMA_GIN_MODE"); v != "" {
    mode = v
}
RAW_BUFFERClick to expand / collapse

CWE-209: Gin DebugMode Default — Information Leakage via Stack Traces

Severity: MEDIUM (CVSS 5.3)

Location

server/routes.go:

var mode string = gin.DebugMode

Description

Ollama's HTTP server defaults to Gin's DebugMode. In debug mode, Gin returns detailed error pages containing:

  • Full stack traces with file paths and line numbers
  • Internal server paths (e.g., /home/user/.ollama/...)
  • Framework internals

Every panic or unhandled error leaks implementation details to any client making requests. There is no environment variable to switch to ReleaseMode — the mode variable is hardcoded.

Impact

An attacker probing the API can:

  • Map internal filesystem paths
  • Identify Go version and Gin framework version from stack traces
  • Discover internal package structure
  • Use leaked paths for further path traversal or configuration file access

Remediation

// Set mode based on environment
if os.Getenv("OLLAMA_DEBUG") == "" {
    mode = gin.ReleaseMode
}
// Or at minimum, make it configurable:
if v := os.Getenv("OLLAMA_GIN_MODE"); v != "" {
    mode = v
}

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