github-vet / github-vet/rangeloop-pointer-findings
projectdiscovery/httpx: internal/runner/runner.go; 56 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [projectdiscovery/httpx](https://www.github.com/projectdiscovery/httpx) at [internal/runner/runner.go](https://github.com/projectdiscovery/httpx/blob/41a6ed4fe15967c78a1c28afa4e0d3f00b1a5bde/internal/runner/runner.go#L374-L429)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first issue it finds, so please do not limit your consideration to the contents of the below message.
> range-loop variable target used in defer or goroutine at line 415
[Click here to see the code in its original context.](https://github.com/projectdiscovery/httpx/blob/41a6ed4fe15967c78a1c28afa4e0d3f00b1a5bde/internal/runner/runner.go#L374-L429)
Click here to show the 56 line(s) of Go which triggered the analyzer.
```go
for target := range targets(stringz.TrimProtocol(t)) {
// if no custom ports specified then test the default ones
if len(customport.Ports) == 0 {
for _, method := range scanopts.Methods {
for _, prot := range protocols {
wg.Add()
go func(target, method, protocol string) {
defer wg.Done()
r := analyze(hp, protocol, target, 0, method, scanopts)
output <- r
if scanopts.TLSProbe && r.TLSData != nil {
scanopts.TLSProbe = false
for _, tt := range r.TLSData.DNSNames {
process(tt, wg, hp, protocol, scanopts, output)
}
for _, tt := range r.TLSData.CommonName {
process(tt, wg, hp, protocol, scanopts, output)
}
}
if scanopts.CSPProbe && r.CSPData != nil {
scanopts.CSPProbe = false
for _, tt := range r.CSPData.Domains {
process(tt, wg, hp, protocol, scanopts, output)
}
}
}(target, method, prot)
}
}
}
// the host name shouldn't have any semicolon - in case remove the port
semicolonPosition := strings.LastIndex(target, ":")
if semicolonPosition > 0 {
target = target[:semicolonPosition]
}
for port, wantedProtocol := range customport.Ports {
for _, method := range scanopts.Methods {
wg.Add()
go func(port int, method, protocol string) {
defer wg.Done()
r := analyze(hp, protocol, target, port, method, scanopts)
output <- r
if scanopts.TLSProbe && r.TLSData != nil {
scanopts.TLSProbe = false
for _, tt := range r.TLSData.DNSNames {
process(tt, wg, hp, protocol, scanopts, output)
}
for _, tt := range r.TLSData.CommonName {
process(tt, wg, hp, protocol, scanopts, output)
}
}
}(port, method, wantedProtocol)
}
}
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 41a6ed4fe15967c78a1c28afa4e0d3f00b1a5bde
Contributor guide
No contributing guide indexed for this repository
Research direction
Read internal/runner/runner.go lines 374-429 at commit 41a6ed4 and inspect the goroutines created inside the range loops. Determine whether the reported range-loop capture can affect the arguments used by analyze, then classify the finding with the requested reaction as Bug, Mitigated, or Desirable Behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100