Skip to content

Commit f18af3c

Browse files
committed
fix(microsoft-excel): validate driveId in getItemBasePath utility
Add regex validation for driveId at the shared utility level to prevent path traversal through the tool execution path, which bypasses the API route validators.
1 parent 780fa90 commit f18af3c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

apps/sim/tools/microsoft_excel/utils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const logger = createLogger('MicrosoftExcelUtils')
1010
*/
1111
export function getItemBasePath(spreadsheetId: string, driveId?: string): string {
1212
if (driveId) {
13+
if (!/^[\w-]+$/.test(driveId)) {
14+
throw new Error('Invalid drive ID format')
15+
}
1316
return `https://graph.microsoft.com/v1.0/drives/${driveId}/items/${spreadsheetId}`
1417
}
1518
return `https://graph.microsoft.com/v1.0/me/drive/items/${spreadsheetId}`

0 commit comments

Comments
 (0)