Skip to content

Potential open redirect vulnerability #2035

@Fushuling

Description

@Fushuling

Hello developer, I noticed at https://github.com/decred/dcrdata/blob/master/cmd/dcrdata/internal/explorer/explorermiddleware.go#L313 that user input is accepted and redirected here.

Image

Although the code strives to ensure that the redirect address is a relative address using URL.EscapedPath(), it's worth noting that this code logic can still be bypassed by attackers. For a URL like http://a.com//fushuling.com, the parsed EscapedPath would be //fushuling.com.

package main

import (
	"fmt"
	"net/url"
)

func main() {
	redirectURI := "http://a.com//fushuling.com"
	URL, _ := url.Parse(redirectURI)
	fmt.Println(URL.EscapedPath())
}
Image

In the actual redirection process, URLs like //fushuling.com will have their HTTP headers automatically completed, thus redirecting to an external address.

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions