Skip to content

Commit c11527f

Browse files
waleedlatif1claude
andcommitted
fix(tinybird): encode datasource/pipe names in URL paths to prevent traversal
A user-or-llm datasource/pipe name interpolated raw into the URL path (e.g. 'real_ds/../../other') is normalized by the WHATWG URL parser and can target a different endpoint. Wrap the path segment with encodeURIComponent in the truncate, delete, and query_pipe URLs. Events/append pass the name via URLSearchParams, which already encodes, so they were unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 4bd1957 commit c11527f

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

apps/sim/tools/tinybird/delete_datasource_rows.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const deleteDatasourceRowsTool: ToolConfig<
6262
request: {
6363
url: (params) => {
6464
const baseUrl = params.base_url.trim().replace(/\/+$/, '')
65-
return `${baseUrl}/v0/datasources/${params.datasource.trim()}/delete`
65+
return `${baseUrl}/v0/datasources/${encodeURIComponent(params.datasource.trim())}/delete`
6666
},
6767
method: 'POST',
6868
headers: (params) => ({

apps/sim/tools/tinybird/query_pipe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const queryPipeTool: ToolConfig<TinybirdQueryPipeParams, TinybirdQueryPip
8787
request: {
8888
url: (params) => {
8989
const baseUrl = params.base_url.trim().replace(/\/+$/, '')
90-
const url = new URL(`${baseUrl}/v0/pipes/${params.pipe.trim()}.json`)
90+
const url = new URL(`${baseUrl}/v0/pipes/${encodeURIComponent(params.pipe.trim())}.json`)
9191
if (params.q) {
9292
url.searchParams.set('q', params.q)
9393
}

apps/sim/tools/tinybird/truncate_datasource.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const truncateDatasourceTool: ToolConfig<
4747
request: {
4848
url: (params) => {
4949
const baseUrl = params.base_url.trim().replace(/\/+$/, '')
50-
return `${baseUrl}/v0/datasources/${params.datasource.trim()}/truncate`
50+
return `${baseUrl}/v0/datasources/${encodeURIComponent(params.datasource.trim())}/truncate`
5151
},
5252
method: 'POST',
5353
headers: (params) => ({

0 commit comments

Comments
 (0)