mirror of
https://github.com/yusufipk/OpenFrame.git
synced 2026-09-11 17:46:06 +00:00
fix(api): add type validation to prevent type confusion attacks in video PATCH
Validates that title and description are strings before calling .trim() method to prevent type confusion attacks in the video update endpoint.
This commit is contained in:
@@ -126,10 +126,11 @@ export async function PATCH(request: NextRequest, { params }: RouteParams) {
|
||||
|
||||
const body = await request.json();
|
||||
const { title, description, position } = body;
|
||||
|
||||
|
||||
// Validate types before using string methods to prevent type confusion attacks
|
||||
const updateData: Record<string, unknown> = {};
|
||||
if (title !== undefined) updateData.title = title.trim();
|
||||
if (description !== undefined) updateData.description = description?.trim() || null;
|
||||
if (typeof title === 'string') updateData.title = title.trim();
|
||||
if (typeof description === 'string') updateData.description = description.trim() || null;
|
||||
if (position !== undefined) updateData.position = position;
|
||||
|
||||
const updatedVideo = await db.video.update({
|
||||
|
||||
Reference in New Issue
Block a user