{"record":{"id":"a2fbc80a6b41fcbe","repo":"projectdiscovery/nuclei","slug":"prompt-not-found-read-cap-reached","errorCode":null,"errorMessage":"prompt not found (read cap reached)","messagePattern":"prompt not found \\(read cap reached\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/utils/telnetmini/telnet.go","lineNumber":350,"sourceCode":"\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\t// NOP for other commands (IAC NOP, GA, etc.)\n\t\t\t}\n\t\t\tcontinue\n\t\t}\n\n\t\t// regular data byte\n\t\tb.WriteByte(tmp[0])\n\t\tlower := strings.ToLower(b.String())\n\t\tfor i, n := range lowNeedles {\n\t\t\tif strings.Contains(lower, n) {\n\t\t\t\treturn needles[i], b.String(), nil\n\t\t\t}\n\t\t}\n\t\tif b.Len() > c.ReadCapBytes {\n\t\t\treturn \"\", b.String(), errors.New(\"prompt not found (read cap reached)\")\n\t\t}\n\t}\n}\n\nfunc (c *Client) setDeadlineFromCtx(ctx context.Context, write bool) {\n\tif ctx == nil {\n\t\treturn\n\t}\n\tif dl, ok := ctx.Deadline(); ok {\n\t\t_ = c.Conn.SetReadDeadline(dl)\n\t\tif write {\n\t\t\t_ = c.Conn.SetWriteDeadline(dl)\n\t\t}\n\t}\n}\n\nfunc preview(s string, n int) string {\n\tif len(s) <= n {","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/utils/telnetmini/telnet.go#L332-L368","documentation":"readUntil (pkg/utils/telnetmini/telnet.go:350) accumulates bytes and scans the lowercased buffer for the needles (prompts) you passed; if the buffer grows past Client.ReadCapBytes before any needle matches, it aborts with 'prompt not found (read cap reached)'. ReadCapBytes defaults to 64 KiB via Defaults() and is a memory safety cap for chatty endpoints. The partial text captured so far is returned with the error for diagnosis.","triggerScenarios":"Client.Exec(ctx, cmd, until...) where none of the `until` prompts appears in output; verbose commands (show-tech, large listings) exceeding 64 KiB; ReadCapBytes set small; prompt needles with different spacing/case than what the device prints (matching is on the lowercased accumulated string).","commonSituations":"Network templates running commands on devices with custom PS1 prompts; pager output ('--More--') interleaving; forgetting `terminal length 0`; banners repeating on every screen.","solutions":["Pass the exact prompt string(s) the device prints as the `until` arguments to Exec","Disable paging on the device first (e.g. `terminal length 0` on IOS) so output ends at the prompt","Raise Client.ReadCapBytes when legitimate output exceeds 64 KiB","Always set a ctx deadline so a truly missing prompt surfaces as context.DeadlineExceeded with partial output"],"exampleFix":"// before\nc.ReadCapBytes = 4 * 1024\nout, err := c.Exec(ctx, \"show version\", \"#\")\n\n// after\nc.ReadCapBytes = 512 * 1024\nout, err := c.Exec(ctx, \"terminal length 0\\nshow version\", \"router# \")","handlingStrategy":"validation","validationCode":"// sanity-check client config before issuing commands\nc.Defaults() // ensures ReadCapBytes == 64 KiB and non-empty prompts\nif len(c.ShellPrompts) == 0 {\n    return errors.New(\"no shell prompts configured; Exec will hit read cap\")\n}\nif c.ReadCapBytes < len(expectedOutput) {\n    c.ReadCapBytes = 2 * len(expectedOutput)\n}","typeGuard":null,"tryCatchPattern":"out, err := c.Exec(ctx, cmd, \"router# \")\nif err != nil {\n    if strings.Contains(err.Error(), \"read cap reached\") {\n        // partial output is in `out`: inspect it to find the real prompt, adjust needles, retry once\n        return retryWithPrompt(out)\n    }\n    return err\n}","preventionTips":["Pass the device's exact prompt (including trailing space) as the until needles","Disable paging (terminal length 0) before commands that produce long output","Size ReadCapBytes to the worst-case command output","Always give Exec a ctx deadline"],"tags":["go","nuclei","telnet","network","timeouts","configuration"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}