From 3fe829acc2d51020ed93a241f5c237abcce81d00 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 27 Jul 2026 07:51:29 +0200 Subject: [PATCH] fix: strip model params for read-only callers in the model list endpoint (#27004) The per-id model endpoint (GET /api/v1/models/model) strips params, the system prompt and other curated model config, for callers who only have read access. The list endpoint (GET /api/v1/models/list) did not: it returned each read-accessible model's full params, so a read-shared model exposed its params.system to non-owner read-grant holders. Mirror the per-id behaviour: compute write_access per item and drop params before serialising when the caller lacks write access (not the owner, not an admin under BYPASS_ADMIN_ACCESS_CONTROL and holding no write grant). The model-card list UI does not render params, so this does not change functionality. Co-authored-by: bogdancherniy11-sudo <229690748+bogdancherniy11-sudo@users.noreply.github.com> --- backend/open_webui/routers/models.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/open_webui/routers/models.py b/backend/open_webui/routers/models.py index b2ed9e9531..e2137d6654 100644 --- a/backend/open_webui/routers/models.py +++ b/backend/open_webui/routers/models.py @@ -189,16 +189,16 @@ async def get_models( data = add_chat_variables_schema(model.model_dump()) if data.get('meta'): data['meta'].pop('profile_image_url', None) - items.append( - ModelAccessResponse( - **data, - write_access=( - (user.role == 'admin' and BYPASS_ADMIN_ACCESS_CONTROL) - or user.id == model.user_id - or model.id in writable_model_ids - ), - ) + write_access = ( + (user.role == 'admin' and BYPASS_ADMIN_ACCESS_CONTROL) + or user.id == model.user_id + or model.id in writable_model_ids ) + # Strip params (system prompt and other curated config) for read-only + # callers, mirroring the per-id endpoint. + if not write_access: + data['params'] = {} + items.append(ModelAccessResponse(**data, write_access=write_access)) return ModelAccessListResponse( items=items,