Skip to content

html: open stack of elements exceeds 512 nodes #2329

@alonek1

Description

@alonek1

httpx crashes with a Go HTML parser panic when scanning a specific URL.
The crash occurs inside the PageTypeClassifier (htmlToText) when encountering deeply nested or minified HTML-like content (in this case, a large JS file).
url causing the panic:

url

command used

echo  https://unpkg.com/[email protected]/build/three.min.js | httpx  -title -tech-detect -status-code -location -content-length -cname -web-server -follow-redirects -websocket

Panic Output

panic: html: open stack of elements exceeds 512 nodes

goroutine 3033 [running]:
github.com/projectdiscovery/httpx/common/pagetypeclassifier.htmlToText(...)
        /home/runner/work/httpx/httpx/common/pagetypeclassifier/pagetypeclassifier.go:36
github.com/projectdiscovery/httpx/common/pagetypeclassifier.(*PageTypeClassifier).Classify(0xc0096fb488, {0xc00f0d6000?, 0xc?})
        /home/runner/work/httpx/httpx/common/pagetypeclassifier/pagetypeclassifier.go:26 +0x6f
github.com/projectdiscovery/httpx/runner.(*Runner).analyze(_, _, {_, _}, {{0xc00b60e200, 0x32}, {0x0, 0x0}, {0x0, 0x0}}, ...)
        /home/runner/work/httpx/httpx/runner/runner.go:2349 +0x7555
github.com/projectdiscovery/httpx/runner.(*Runner).process.func1({{0xc00b60e200, 0x32}, {0x0, 0x0}, {0x0, 0x0}}, {0x1686161?, 0x0?}, {0xc00b60e200, 0x5})
        /home/runner/work/httpx/httpx/runner/runner.go:1444 +0x125
created by github.com/projectdiscovery/httpx/runner.(*Runner).process in goroutine 1
        /home/runner/work/httpx/httpx/runner/runner.go:1442 +0x8a6

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugInconsistencies or issues which will cause an issue or problem for users or implementors.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions