security: image MCP fails closed when the member's own key is absent
This commit is contained in:
1 parent
14b61e24da
commit
69ba4346cf
3 files changed
+31
-19
No files matched your search
@@ -322,14 +322,14 @@ needed.
|
|||||||
is deliberately NOT in the chat picker (image models are not chat models;
|
is deliberately NOT in the chat picker (image models are not chat models;
|
||||||
chat-calling it was the source of the old 500s).
|
chat-calling it was the source of the old 500s).
|
||||||
- **Image generation — two paths**:
|
- **Image generation — two paths**:
|
||||||
1. **MCP tool (default, no key ever)**: `inference-image` server (tool
|
1. **MCP tool (default)**: `inference-image` server (tool `generate_image`)
|
||||||
`generate_image`) — members select it in the composer's **+** palette
|
— members select it in the composer's **+** palette and just ask.
|
||||||
and just ask. Per-member billing via `customUserVars.IC_API_KEY` (seeded
|
Per-member billing via `customUserVars.IC_API_KEY` (seeded from the
|
||||||
from the portal) + `env: IC_API_KEY: "{{IC_API_KEY}}"`; a system-key
|
portal) + `env: IC_API_KEY: "{{IC_API_KEY}}"`. **Fail-closed:** the co-op
|
||||||
fallback (`system-image-fallback`, $5/30d) covers the rare empty-value
|
system key is not passed into per-user MCP processes at all, so a missing
|
||||||
case. The `customUserVars` gate blocks a not-yet-seeded member until the
|
member key returns a message pointing at the dashboard instead of billing
|
||||||
next sync (≤10 min) — accepted as a short delay over billing everything
|
the co-op account. The `customUserVars` gate blocks a not-yet-seeded
|
||||||
to the system account.
|
member until the next sync (≤10 min).
|
||||||
2. **Agent tool**: LibreChat's built-in "OpenAI Image Tools" (env
|
2. **Agent tool**: LibreChat's built-in "OpenAI Image Tools" (env
|
||||||
`IMAGE_GEN_OAI_BASEURL`/`IMAGE_GEN_OAI_MODEL` → gateway; no admin key,
|
`IMAGE_GEN_OAI_BASEURL`/`IMAGE_GEN_OAI_MODEL` → gateway; no admin key,
|
||||||
members paste their own). Note LibreChat v0.8.8 renders the generated
|
members paste their own). Note LibreChat v0.8.8 renders the generated
|
||||||
|
|||||||
+3
-1
@@ -236,5 +236,7 @@ mcpServers:
|
|||||||
description: "Auto-loaded from your membership — no action needed."
|
description: "Auto-loaded from your membership — no action needed."
|
||||||
sensitive: true
|
sensitive: true
|
||||||
env:
|
env:
|
||||||
|
# ONLY the member's own key. The co-op system key is deliberately not
|
||||||
|
# passed into per-user MCP processes: a missing member key must fail
|
||||||
|
# closed, never bill image spend to the co-op account.
|
||||||
IC_API_KEY: "{{IC_API_KEY}}"
|
IC_API_KEY: "{{IC_API_KEY}}"
|
||||||
SYSTEM_IMAGE_KEY: "${SYSTEM_IMAGE_KEY}"
|
|
||||||
+20
-10
@@ -37,16 +37,26 @@ def log(msg):
|
|||||||
|
|
||||||
|
|
||||||
def tool_generate_image(args):
|
def tool_generate_image(args):
|
||||||
# Seamless: use the member's own key if LibreChat injected one; otherwise
|
# FAIL CLOSED: image spend bills to the member's own LiteLLM team budget.
|
||||||
# fall back to the co-op's SYSTEM key (so a member who has never been
|
# LibreChat injects IC_API_KEY per user (customUserVars + env). If it is
|
||||||
# seeded — e.g. right after first login — still generates an image,
|
# missing — the member has not been seeded yet, or their key was never
|
||||||
# billed to the system account). Only if both are absent send keyless.
|
# saved — refuse rather than falling back to a co-op account key. A silent
|
||||||
key = (
|
# fallback would charge the co-op for a member action and hide the missing
|
||||||
os.environ.get("IC_API_KEY")
|
# key from the person who can fix it.
|
||||||
or os.environ.get("SYSTEM_IMAGE_KEY")
|
key = (os.environ.get("IC_API_KEY") or "").strip()
|
||||||
or ""
|
if not key:
|
||||||
).strip()
|
return {
|
||||||
auth_header = {"Authorization": f"Bearer {key}"} if key else {}
|
"content": [{
|
||||||
|
"type": "text",
|
||||||
|
"text": (
|
||||||
|
"No co-op API key is attached to this session yet. "
|
||||||
|
f"Create one at {DASHBOARD_URL}, save it in the MCP panel, "
|
||||||
|
"then try again."
|
||||||
|
),
|
||||||
|
}],
|
||||||
|
"isError": True,
|
||||||
|
}
|
||||||
|
auth_header = {"Authorization": f"Bearer {key}"}
|
||||||
|
|
||||||
prompt = str(args.get("prompt") or "").strip()
|
prompt = str(args.get("prompt") or "").strip()
|
||||||
if not prompt:
|
if not prompt:
|
||||||
|
|||||||
Reference in new issue
Block a user