fix(router): restrict KB-scoped file proxy to exports/ paths

Borrowers with shared-KB read access could previously request any
owner-tenant storage path via /knowledge-bases/:id/files. Limit the
proxy to exports/ embedded images; raw knowledge uploads continue to
use /knowledge/:id/download.
This commit is contained in:
wizardchen
2026-07-13 12:12:09 +08:00
committed by lyingbug
parent 800cea0826
commit def92bb74f
4 changed files with 91 additions and 3 deletions
+2 -2
View File
@@ -1642,8 +1642,8 @@ func newKBScopedFileServeHandler(
return
}
if err := secutils.ValidateStoragePathTenant(filePath, ownerTenantID); err != nil {
logger.Warnf(ctx, "[Router] /knowledge-bases/:id/files denied path not owned by KB tenant: owner_tenant_id=%d file_path=%q err=%v",
if err := secutils.ValidateKBScopedStoragePath(filePath, ownerTenantID); err != nil {
logger.Warnf(ctx, "[Router] /knowledge-bases/:id/files denied path not allowed for KB proxy: owner_tenant_id=%d file_path=%q err=%v",
ownerTenantID, filePath, err)
c.JSON(http.StatusForbidden, gin.H{"error": "forbidden: file path not accessible"})
return