Skip to content

Security Issues: Command Execution Risks #61

Description

@mingijunggrape
package main

import (
	"fmt"
	"github.com/pkg/browser"
)

func main() {
	url := "calc"
	err := browser.OpenURL(url)
	if err != nil {
		fmt.Println("Error opening URL:", err)
	} else {
		fmt.Println("URL opened successfully.")
	}
}

If a command is passed instead of a URL, the corresponding application will be executed. This means that the intended behavior of only opening a browser can be bypassed, and it could be used to run malicious code.

Therefore, you shouldn't simply use the received URL as-is; instead, you should pass the URL directly to the browser to ensure it is handled safely.

It seems that you need to structure the command like xdg-open [browser path] [URL] on Linux or start [browser path] [URL] on Windows.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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