{"record":{"id":"9e677a12b13f4468","repo":"projectdiscovery/nuclei","slug":"no-new-line-found-at-the-end-of-host-header","errorCode":null,"errorMessage":"no new line found at the end of host header","messagePattern":"no new line found at the end of host header","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/protocols/http/raw/raw.go","lineNumber":339,"sourceCode":"\t\t// attempt to locate next newline\n\t\tnewLineIndex := bytes.Index(unsafeBytes[hostHeaderIndex:], []byte(\"\\r\\n\"))\n\t\tif newLineIndex > 0 {\n\t\t\tnewLineIndex += hostHeaderIndex + 2\n\t\t\t// insert custom headers\n\t\t\tbuf := bufferPool.Get().(*bytes.Buffer)\n\t\t\tbuf.Reset()\n\t\t\tbuf.Write(r.UnsafeRawBytes[:newLineIndex])\n\t\t\tfor _, header := range headers {\n\t\t\t\tbuf.WriteString(header)\n\t\t\t\tbuf.WriteString(\"\\r\\n\")\n\t\t\t}\n\t\t\tbuf.Write(r.UnsafeRawBytes[newLineIndex:])\n\t\t\tr.UnsafeRawBytes = append([]byte(nil), buf.Bytes()...)\n\t\t\tbuf.Reset()\n\t\t\tbufferPool.Put(buf)\n\t\t\treturn nil\n\t\t}\n\t\treturn errors.New(\"no new line found at the end of host header\")\n\t}\n\n\treturn errors.New(\"no host header found\")\n}\n\n// ApplyAuthStrategy applies the auth strategy to the request\nfunc (r *Request) ApplyAuthStrategy(strategy authx.AuthStrategy) {\n\tif strategy == nil {\n\t\treturn\n\t}\n\tswitch s := strategy.(type) {\n\tcase *authx.QueryAuthStrategy:\n\t\tparsed, err := urlutil.Parse(r.FullURL)\n\t\tif err != nil {\n\t\t\tgologger.Error().Msgf(\"auth strategy failed to parse url: %s got %v\", r.FullURL, err)\n\t\t\treturn\n\t\t}\n\t\tfor _, p := range s.Data.Params {","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/protocols/http/raw/raw.go#L321-L357","documentation":"When nuclei splices rewritten headers into a raw request (e.g. host-header based injection), it locates the Host header line and needs its trailing newline to know where to insert. If the Host header exists but no newline terminates that line — the request text simply ends or continues without CRLF/LF — this error is returned.","triggerScenarios":"A hand-written raw request in a template where the Host line is the last line with no trailing \\r\\n, or line endings were collapsed to spaces when copy-pasting from curl/terminal. The Host header must be terminated by a newline for the rewrite to proceed.","commonSituations":"YAML block scalars losing the final CRLF; requests pasted from Burp where the blank line before the body was dropped; editors normalizing CRLF to nothing.","solutions":["Terminate the Host header line with \\r\\n and keep the standard blank line separating headers from body (\\r\\n\\r\\n)","Write raw requests with explicit CRLF endings exactly as they go on the wire","Run `nuclei -t tpl.yaml -validate` and prefer building raw requests in Burp/hitbcapture then pasting with headers intact"],"exampleFix":"# before\n- raw:\n    - |\n      GET / HTTP/1.1\n      Host: {{Hostname}}\n\n# after\n- raw:\n    - |\n      GET / HTTP/1.1\n      Host: {{Hostname}}\n\n","handlingStrategy":"validation","validationCode":"// validate raw request text has a newline-terminated Host header\nfunc hostHeaderTerminated(raw string) bool {\n    i := strings.Index(strings.ToLower(raw), \"host:\")\n    if i < 0 { return false }\n    rest := raw[i:]\n    return strings.Contains(rest, \"\\r\\n\") || strings.Contains(rest, \"\\n\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always write raw requests as complete on-the-wire HTTP: headers each ending \\r\\n plus the blank line before the body","Prefer capturing requests from Burp ('Copy as raw') over hand-typing them","Run nuclei -validate, which parses raw requests and flags malformed header blocks"],"tags":["http","raw-request","parsing","template"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}