Skip to content

Commit cf3a978

Browse files
committed
fix: prevent overriding req.Host in unsafe mode when CustomHeaders has Host
1 parent 7b8fd15 commit cf3a978

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

runner/runner.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,8 +1637,17 @@ retry:
16371637
return Result{URL: URL.String(), Input: origInput, Err: err}
16381638
}
16391639

1640+
// Don't override req.Host in unsafe mode if CustomHeaders has Host
1641+
// This allows AutomaticHostHeader(false) to work (see lines 244-251)
16401642
if target.CustomHost != "" {
1641-
req.Host = target.CustomHost
1643+
if scanopts.Unsafe {
1644+
// In unsafe mode, only set req.Host if no Host in CustomHeaders
1645+
if _, hasHost := hp.CustomHeaders["host"]; !hasHost {
1646+
req.Host = target.CustomHost
1647+
}
1648+
} else {
1649+
req.Host = target.CustomHost
1650+
}
16421651
}
16431652

16441653
if !scanopts.LeaveDefaultPorts {

0 commit comments

Comments
 (0)