Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 14:30 UTC
Fix SSRF vulnerability - restrict proxy to backend.composio.dev only
Sushmithamallesh committed
Jan 22, 2026 at 13:46 UTC
7b76a0be0a54dd5eeeee24aa29f22478579f29a8
1 file changed
+18
docs/app/api/proxy/route.ts
+18
@@ -20,6 +20,8 @@ export async function PATCH(request: NextRequest) {
20
return handleProxy(request);
21
}
22
23
+const ALLOWED_HOST = 'backend.composio.dev';
24
+
25
async function handleProxy(request: NextRequest) {
26
try {
27
const url = new URL(request.url);
@@ -29,6 +31,22 @@ async function handleProxy(request: NextRequest) {
31
return NextResponse.json({ error: 'Missing url parameter' }, { status: 400 });
32
}
33
34
+ // Validate the target URL to prevent SSRF
35
+ let parsedTarget: URL;
36
+ try {
37
+ parsedTarget = new URL(targetUrl);
38
+ } catch {
39
+ return NextResponse.json({ error: 'Invalid URL' }, { status: 400 });
40
+ }
41
+
42
+ if (parsedTarget.hostname !== ALLOWED_HOST) {
43
+ return NextResponse.json({ error: 'URL not allowed' }, { status: 403 });
44
+ }
45
+
46
+ if (parsedTarget.protocol !== 'https:') {
47
+ return NextResponse.json({ error: 'Only HTTPS allowed' }, { status: 403 });
48
+ }
49
+
50
// Get request body for non-GET requests
51
let body: string | undefined;
52
if (request.method !== 'GET' && request.method !== 'HEAD') {