Skip to content

Commit 6acb47e

Browse files
committed
fix(providers): clear forged file handles for inline providers too
attachLargeFileRemoteUrls early-returned for inline-strategy providers before clearing server-only handle fields, so a forged remoteUrl on an inline-provider file could still reach a builder (e.g. buildOpenAICompatibleChatContent for mistral/ollama). Clear the handles for every provider before the strategy check.
1 parent d28a752 commit 6acb47e

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

apps/sim/providers/file-attachments.server.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,26 @@ interface RemoteUrlContext {
3333
* threshold on a large-file-capable provider, storing it on `file.remoteUrl`. Providers
3434
* with a `remote-url` strategy use it directly; `files-api` providers upload from it later.
3535
* Requires cloud storage — without it large files fall back to the (capped) base64 path.
36+
*
37+
* The server-only handle fields are first cleared on every file for every provider
38+
* (including inline) so a forged handle on untrusted input can never reach a builder.
3639
*/
3740
export async function attachLargeFileRemoteUrls(
3841
files: UserFile[] | undefined,
3942
providerId: ProviderId | string,
4043
ctx: RemoteUrlContext
4144
): Promise<void> {
42-
if (!files?.length || getProviderFileStrategy(providerId) === 'inline') return
45+
if (!files?.length) return
4346

4447
for (const file of files) {
4548
file.providerFileId = undefined
4649
file.providerFileUri = undefined
4750
file.remoteUrl = undefined
51+
}
52+
53+
if (getProviderFileStrategy(providerId) === 'inline') return
4854

55+
for (const file of files) {
4956
if (!file.key || !shouldUseLargeFilePath(file, providerId)) continue
5057
if (!StorageService.hasCloudStorage()) continue
5158

0 commit comments

Comments
 (0)