Skip to content

Commit bb1d384

Browse files
committed
consolidate access, billing principals
1 parent 9f47c14 commit bb1d384

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

apps/sim/lib/knowledge/documents/service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)