Skip to content

SSRF vulnerability in /api/upload - client-controlled upload destination #5

Description

@BadAtCaptchas

Description

The /api/upload endpoint accepts a localUploadUrl from the client, allowing file uploads to arbitrary destinations.

Affected File

app/api/upload/route.ts

Current Behavior

const localUploadUrl = formData.get("localUploadUrl") as string || "http://localhost:9000"
const response = await fetch(`${localUploadUrl}/tost/${filename}`, {
  method: "PUT",
  body: file,
})

Security Impact

An attacker could upload files to internal services or overwrite data on accessible endpoints.

Suggested Fix

const LOCAL_UPLOAD_URL = process.env.LOCAL_UPLOAD_URL || 'http://localhost:9000';
// Don't accept localUploadUrl from client

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions