File tree Expand file tree Collapse file tree
apps/sim/lib/knowledge/documents Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -515,7 +515,6 @@ export async function processDocumentAsync(
515515 // KB config + workspace billing + doc tags in one JOIN (was 3 SELECTs).
516516 const contextRows = await db
517517 . select ( {
518- userId : knowledgeBase . userId ,
519518 workspaceId : knowledgeBase . workspaceId ,
520519 chunkingConfig : knowledgeBase . chunkingConfig ,
521520 embeddingModel : knowledgeBase . embeddingModel ,
@@ -644,7 +643,12 @@ export async function processDocumentAsync(
644643 kbConfig . maxSize ,
645644 kbConfig . overlap ,
646645 kbConfig . minSize ,
647- ctx . userId ,
646+ // Authorize the source file (and run OCR/processing) as the billed
647+ // actor — the uploader when known, else the workspace billed account —
648+ // the same principal embeddings are billed to. Using the KB owner here
649+ // would authorize an attacker-supplied internal fileUrl against the
650+ // owner, letting a KB write-member ingest a file only the owner can read.
651+ billingUserId ,
648652 ctx . workspaceId ,
649653 rawConfig ?. strategy ,
650654 rawConfig ?. strategyOptions
You can’t perform that action at this time.
0 commit comments