Skip to content

Commit 5719fd6

Browse files
committed
fix(security): add credentialId validation to wealthbox oauth route; fix null body override in pinnedFetch
1 parent e1a37d7 commit 5719fd6

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

apps/sim/app/api/auth/oauth/wealthbox/items/route.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { type NextRequest, NextResponse } from 'next/server'
33
import { wealthboxOAuthItemsContract } from '@/lib/api/contracts/selectors/wealthbox'
44
import { parseRequest } from '@/lib/api/server'
55
import { authorizeCredentialUse } from '@/lib/auth/credential-access'
6+
import { validatePathSegment } from '@/lib/core/security/input-validation'
67
import { generateRequestId } from '@/lib/core/utils/request'
78
import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
89
import { refreshAccessTokenIfNeeded } from '@/app/api/auth/oauth/utils'
@@ -32,6 +33,18 @@ export const GET = withRouteHandler(async (request: NextRequest) => {
3233
const { credentialId, type } = parsed.data.query
3334
const query = parsed.data.query.query ?? ''
3435

36+
const credentialIdValidation = validatePathSegment(credentialId, {
37+
paramName: 'credentialId',
38+
maxLength: 100,
39+
allowHyphens: true,
40+
allowUnderscores: true,
41+
allowDots: false,
42+
})
43+
if (!credentialIdValidation.isValid) {
44+
logger.warn(`[${requestId}] Invalid credentialId format: ${credentialId}`)
45+
return NextResponse.json({ error: credentialIdValidation.error }, { status: 400 })
46+
}
47+
3548
const authz = await authorizeCredentialUse(request, {
3649
credentialId,
3750
requireWorkflowIdForInternal: false,

apps/sim/lib/a2a/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export async function createA2AClient(agentUrl: string, apiKey?: string): Promis
9393
const text = await new Response(init.body as BodyInit).text()
9494
if (text) body = text
9595
}
96-
} else if (input instanceof Request && !input.bodyUsed) {
96+
} else if (init?.body === undefined && input instanceof Request && !input.bodyUsed) {
9797
const text = await input.text()
9898
if (text) body = text
9999
}

0 commit comments

Comments
 (0)