Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

Fix SSRF vulnerability - restrict proxy to backend.composio.dev only

Sushmithamallesh7b76a0be0a54
diff --git a/docs/app/api/proxy/route.ts b/docs/app/api/proxy/route.ts
index ed23413c4..1efc98108 100644
--- a/docs/app/api/proxy/route.ts
+++ b/docs/app/api/proxy/route.ts
@@ -20,6 +20,8 @@ export async function PATCH(request: NextRequest) {
return handleProxy(request);
}
+const ALLOWED_HOST = 'backend.composio.dev';
+
async function handleProxy(request: NextRequest) {
try {
const url = new URL(request.url);
@@ -29,6 +31,22 @@ async function handleProxy(request: NextRequest) {
return NextResponse.json({ error: 'Missing url parameter' }, { status: 400 });
}
+ // Validate the target URL to prevent SSRF
+ let parsedTarget: URL;
+ try {
+ parsedTarget = new URL(targetUrl);
+ } catch {
+ return NextResponse.json({ error: 'Invalid URL' }, { status: 400 });
+ }
+
+ if (parsedTarget.hostname !== ALLOWED_HOST) {
+ return NextResponse.json({ error: 'URL not allowed' }, { status: 403 });
+ }
+
+ if (parsedTarget.protocol !== 'https:') {
+ return NextResponse.json({ error: 'Only HTTPS allowed' }, { status: 403 });
+ }
+
// Get request body for non-GET requests
let body: string | undefined;
if (request.method !== 'GET' && request.method !== 'HEAD') {