mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-15 01:18:26 +08:00
Go and Python: fix IDOR issue of search completions (#16864)
### Summary In Go and python implementation, the dataset / KB id isn't validated if it is accessible by this user. --------- Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -25,6 +25,7 @@ from api.apps import current_user, login_required
|
||||
from api.constants import DATASET_NAME_LIMIT
|
||||
from api.db.db_models import DB
|
||||
from api.db.services import duplicate_name
|
||||
from api.db.services.knowledgebase_service import KnowledgebaseService
|
||||
from api.db.services.search_service import SearchService
|
||||
from api.db.services.user_service import TenantService, UserTenantService
|
||||
from common.misc_utils import get_uuid
|
||||
@@ -220,6 +221,11 @@ async def completion(search_id):
|
||||
if not kb_ids:
|
||||
return get_data_error_result(message="`kb_ids` is required.")
|
||||
|
||||
# check if the kb_ids is accessible for this user
|
||||
for kb_id in kb_ids:
|
||||
if not KnowledgebaseService.accessible(kb_id=kb_id, user_id=uid):
|
||||
return get_data_error_result(message=f"You don't own the dataset {kb_id}")
|
||||
|
||||
async def stream():
|
||||
nonlocal req, uid, kb_ids, search_config
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user