projectdiscovery/nuclei · warning

could not parse hexdump

Error message

could not parse hexdump

What it means

Raised by toHighLightedHexDump in the terminal response highlighter (hexdump.go:49). It re-parses an already-rendered hexdump with a row regex; if no rows match, or the matched row count differs from the number of newlines in the input, the dump is considered malformed and the function logs a gologger warning and returns this error. It is a presentation-layer failure: the match data itself is fine, only the colored hexdump view could not be built.

Source

Thrown at pkg/protocols/common/helpers/responsehighlighter/hexdump.go:49

func (hexDump HighlightableHexDump) len() int {
	return len(hexDump.index)
}

func (hexDump HighlightableHexDump) String() string {
	var result string
	for i := 0; i < hexDump.len(); i++ {
		result += hexDump.index[i] + hexDump.hex[i] + "|" + hexDump.ascii[i] + "|\n"
	}
	return result
}

func toHighLightedHexDump(hexDump, snippetToHighlight string) (HighlightableHexDump, error) {
	hexDumpRowValues := hexDumpParsePattern.FindAllStringSubmatch(hexDump, -1)
	if hexDumpRowValues == nil || len(hexDumpRowValues) != strings.Count(hexDump, "\n") {
		message := "could not parse hexdump"
		gologger.Warning().Msg(message)

		return HighlightableHexDump{}, errors.New(message)
	}

	result := NewHighlightableHexDump(len(hexDumpRowValues))
	for _, currentHexDumpRowValues := range hexDumpRowValues {
		result.index = append(result.index, currentHexDumpRowValues[1])
		result.hex = append(result.hex, currentHexDumpRowValues[2])
		result.ascii = append(result.ascii, currentHexDumpRowValues[3])
	}
	return result.highlight(snippetToHighlight), nil
}

func (hexDump HighlightableHexDump) highlight(snippetToColor string) HighlightableHexDump {
	return highlightAsciiSection(highlightHexSection(hexDump, snippetToColor), snippetToColor)
}

func highlightHexSection(hexDump HighlightableHexDump, snippetToColor string) HighlightableHexDump {
	var snippetHexCharactersMatchPattern string
	for _, char := range snippetToColor {

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Treat the error as non-fatal: log it and fall back to printing the raw or plain-formatted response
  2. Ensure the hexdump passed in is the unmodified output of the package's own dumper
  3. Compare row count vs newline count yourself before highlighting if you build dumps manually

Example fix

// before
hd, err := responsehighlighter.toHighLightedHexDump(dump, marker)
if err != nil { return err }
// after
hd, err := responsehighlighter.toHighLightedHexDump(dump, marker)
if err != nil { hd = plainFallback(dump) } // degrade, do not fail
Defensive patterns

Strategy: fallback

Validate before calling

rows := hexDumpParsePattern.FindAllStringSubmatch(dump, -1)
if rows == nil || len(rows) != strings.Count(dump, "\n") { /* use plain rendering now */ }

Type guard

func isHexdumpParseFailure(err error) bool { return err != nil && err.Error() == "could not parse hexdump" }

Try / catch

hd, err := toHighLightedHexDump(dump, marker)
if err != nil { // presentation-only failure
    gologger.Debug().Err(err).Msg("hexdump highlight skipped")
    return dump // plain output
}

Prevention

When it happens

Trigger: Calling ResponseHighlighter on binary response content whose generated hexdump rows do not align with the parse pattern (e.g. rows with unusual offsets or truncated last lines), so FindAllStringSubmatch returns nil or a mismatched count.

Common situations: Viewing binary protocol responses in a terminal; truncated responses that cut a hexdump row in half; downstream code that mutates the dump string between render and highlight.

Related errors


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/fade6ab60553048a. Report an issue: GitHub.