Skip to content

Commit ff82280

Browse files
fix(security): isolate opaque tool schemas
1 parent 89bc93c commit ff82280

2 files changed

Lines changed: 29 additions & 18 deletions

File tree

apps/sim/lib/workflows/search-replace/indexer.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ describe('indexWorkflowSearchMatches', () => {
3939
])
4040
})
4141

42+
it.each(['custom-tool', 'mcp'])(
43+
'keeps %s params non-authoritative when its tool ID collides with a built-in',
44+
(type) => {
45+
expect(
46+
getToolInputParamConfigs({
47+
tool: { type, toolId: 'gmail_send', params: { body: 'literal-secret' } },
48+
})
49+
).toEqual([
50+
expect.objectContaining({
51+
paramId: 'body',
52+
authoritative: false,
53+
value: 'literal-secret',
54+
}),
55+
])
56+
}
57+
)
58+
4259
it('finds plain text matches across nested subblock values', () => {
4360
const workflow = createSearchReplaceWorkflowFixture()
4461

apps/sim/lib/workflows/search-replace/indexer.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -698,10 +698,10 @@ export function getToolInputParamConfigs({
698698
credentialTypeById?: Record<string, string | undefined>
699699
blockConfigs?: WorkflowSearchIndexerOptions['blockConfigs']
700700
}): ResolvedToolInputParamConfig[] {
701-
const toolId =
702-
tool.type !== 'custom-tool' && tool.type !== 'mcp'
703-
? getToolIdForOperation(tool.type, tool.operation) || tool.toolId
704-
: tool.toolId
701+
const hasAuthoritativeRegistryDefinition = tool.type !== 'custom-tool' && tool.type !== 'mcp'
702+
const toolId = hasAuthoritativeRegistryDefinition
703+
? getToolIdForOperation(tool.type, tool.operation) || tool.toolId
704+
: undefined
705705
const toolParamValues = tool.params ?? {}
706706
const values = { operation: tool.operation, ...toolParamValues }
707707
const genericFallback = () =>
@@ -737,20 +737,14 @@ export function getToolInputParamConfigs({
737737
toolIndex,
738738
tool.type
739739
)
740-
const blockConfig =
741-
tool.type !== 'custom-tool' && tool.type !== 'mcp'
742-
? (blockConfigs?.[tool.type] ?? getBlock(tool.type))
743-
: null
744-
const subBlocksResult =
745-
tool.type !== 'custom-tool' && tool.type !== 'mcp'
746-
? getSubBlocksForToolInput(
747-
toolId,
748-
tool.type,
749-
values,
750-
scopedCanonicalModes,
751-
blockConfig?.subBlocks ? { subBlocks: blockConfig.subBlocks } : undefined
752-
)
753-
: null
740+
const blockConfig = blockConfigs?.[tool.type] ?? getBlock(tool.type)
741+
const subBlocksResult = getSubBlocksForToolInput(
742+
toolId,
743+
tool.type,
744+
values,
745+
scopedCanonicalModes,
746+
blockConfig?.subBlocks ? { subBlocks: blockConfig.subBlocks } : undefined
747+
)
754748
const toolParams = getToolParametersConfig(toolId, tool.type, values)
755749
const displayParams = toolParams?.userInputParameters ?? []
756750

0 commit comments

Comments
 (0)