Skip to content

Commit a3c93ee

Browse files
committed
fix(microsoft-excel): validate driveId in files route
Add regex validation for driveId query param in the Microsoft OAuth files route to prevent path traversal, matching the drives route.
1 parent 6162253 commit a3c93ee

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

  • apps/sim/app/api/auth/oauth/microsoft/files

apps/sim/app/api/auth/oauth/microsoft/files/route.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ export async function GET(request: NextRequest) {
7575

7676
// When driveId is provided (SharePoint), search within that specific drive.
7777
// Otherwise, search the user's personal OneDrive.
78+
if (driveId && !/^[\w-]+$/.test(driveId)) {
79+
return NextResponse.json({ error: 'Invalid drive ID format' }, { status: 400 })
80+
}
7881
const drivePath = driveId ? `drives/${driveId}` : 'me/drive'
7982

8083
const response = await fetch(

0 commit comments

Comments
 (0)