Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/app/api/validate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ export async function POST(req: NextRequest) {
);
}

// Validate inputs to prevent path traversal attacks
const safePathPattern = /^[a-zA-Z0-9_-]+$/;
if (!safePathPattern.test(upgradeId) || !safePathPattern.test(userType)) {
return NextResponse.json(
{ message: 'Invalid parameters: upgradeId and userType must only contain alphanumeric characters, underscores, and hyphens' },
{ status: 400 }
);
}

const trimmedUpgradeId = upgradeId.trim();
const trimmedUserType = userType.trim();
const normalizedNetwork = network.trim().toLowerCase();
Expand Down