[PR #15871] fix: add URL validation in openai.go #77631

Open
opened 2026-05-05 10:18:17 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/15871
Author: @orbisai0security
Created: 4/29/2026
Status: 🔄 Open

Base: mainHead: fix-v-002-prompt-injection-middleware-openai


📝 Commits (1)

  • 215136b fix: V-002 security vulnerability

📊 Changes

1 file changed (+17 additions, -6 deletions)

View changed files

📝 middleware/openai.go (+17 -6)

📄 Description

Summary

Fix high severity security issue in middleware/openai.go.

Vulnerability

Field Value
ID V-002
Severity HIGH
Scanner multi_agent_ai
Rule V-002
File middleware/openai.go:761
CWE CWE-918

Description: The Prompt field at middleware/openai.go:763 is read directly from FormValue("prompt") and passed to the LLM without any sanitization, validation, or length limits. An attacker can inject adversarial instructions that override system prompts, invoke registered tools (e.g., web_fetch) with attacker-controlled parameters, or cause the model to exfiltrate conversation history and system context. This vulnerability is particularly dangerous when combined with V-001 (SSRF), as injected prompts can trigger web_fetch calls to cloud metadata endpoints.

Changes

  • middleware/openai.go

Verification

  • Build passes
  • Scanner re-scan confirms fix
  • LLM code review passed

Automated security fix by OrbisAI Security


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/15871 **Author:** [@orbisai0security](https://github.com/orbisai0security) **Created:** 4/29/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix-v-002-prompt-injection-middleware-openai` --- ### 📝 Commits (1) - [`215136b`](https://github.com/ollama/ollama/commit/215136be0d52f428b68a98eded829a9e754d4700) fix: V-002 security vulnerability ### 📊 Changes **1 file changed** (+17 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `middleware/openai.go` (+17 -6) </details> ### 📄 Description ## Summary Fix high severity security issue in `middleware/openai.go`. ## Vulnerability | Field | Value | |-------|-------| | **ID** | V-002 | | **Severity** | HIGH | | **Scanner** | multi_agent_ai | | **Rule** | `V-002` | | **File** | `middleware/openai.go:761` | | **CWE** | CWE-918 | **Description**: The Prompt field at middleware/openai.go:763 is read directly from FormValue("prompt") and passed to the LLM without any sanitization, validation, or length limits. An attacker can inject adversarial instructions that override system prompts, invoke registered tools (e.g., web_fetch) with attacker-controlled parameters, or cause the model to exfiltrate conversation history and system context. This vulnerability is particularly dangerous when combined with V-001 (SSRF), as injected prompts can trigger web_fetch calls to cloud metadata endpoints. ## Changes - `middleware/openai.go` ## Verification - [x] Build passes - [x] Scanner re-scan confirms fix - [x] LLM code review passed --- *Automated security fix by [OrbisAI Security](https://orbisappsec.com)* --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-05 10:18:17 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#77631