ffuf/ffuf · error

could not read request: %s

Error message

could not read request: %s

What it means

After opening the raw request file, parseRawRequest reads the first line (the request line) with bufio.Reader.ReadString. Any read error — including EOF from a zero-byte or truncated file — is wrapped in this message and returned, since a request cannot be reconstructed without the method/URL line.

Source

Thrown at pkg/ffuf/optionsparser.go:742

	optsCopy.HTTP.Postflights = clonePreflights(parseOpts.HTTP.Postflights)
	conf.Options = &optsCopy
	return &conf, errs.ErrorOrNil()
}

func parseRawRequest(parseOpts *ConfigOptions, conf *Config) error {
	conf.RequestFile = parseOpts.Input.Request
	conf.RequestProto = parseOpts.Input.RequestProto
	file, err := os.Open(parseOpts.Input.Request)
	if err != nil {
		return fmt.Errorf("could not open request file: %s", err)
	}
	defer file.Close()

	r := bufio.NewReader(file)

	s, err := r.ReadString('\n')
	if err != nil {
		return fmt.Errorf("could not read request: %s", err)
	}
	parts := strings.Split(s, " ")
	if len(parts) < 3 {
		return fmt.Errorf("malformed request supplied")
	}
	// Set the request Method
	conf.Method = parts[0]

	for {
		line, err := r.ReadString('\n')
		line = strings.TrimSpace(line)

		if err != nil || line == "" {
			break
		}

		p := strings.SplitN(line, ":", 2)
		if len(p) != 2 {

View on GitHub (pinned to 33c67d28c8)

Solutions

  1. Ensure the file starts with a valid request line like 'GET /path HTTP/1.1' with a newline
  2. Re-export the request from the proxy (Burp/ZAP 'Copy as request file')
  3. Check the file is non-empty: wc -c <file>
  4. Read the file directly to confirm its first line is intact

Example fix

// before (empty or truncated req.txt)
(empty file)
// after (req.txt)
GET /dir/FUZZ HTTP/1.1
Host: example.com

Defensive patterns

Strategy: try-catch

Validate before calling

f, err := os.Open(opts.Input.Request)
if err != nil {
    return err
}
first, err := bufio.NewReader(f).ReadString('\n')
f.Close()
if err != nil || strings.TrimSpace(first) == "" {
    return errors.New("request file is empty or missing a request line")
}

Try / catch

err := ffuf.ConfigFromOptions(parseOpts)
if err != nil {
    if strings.Contains(err.Error(), "could not read request") {
        log.Fatalf("request file unreadable/empty: %v — re-export the raw request", err)
    }
    return err
}

Prevention

When it happens

Trigger: ConfigFromOptions -> parseRawRequest when the file opens but the first ReadString('\n') fails: an empty request file, a file whose first line has no trailing newline and hits EOF, a device/special file, or I/O errors on a broken mount.

Common situations: Saving an empty or truncated file from a proxy export; piping/copying a request that lost its content; capturing only headers without a request line; network filesystem issues making the file unreadable mid-read.

Related errors


AI-assisted analysis of ffuf/ffuf@33c67d28c8 (2026-09-04). Data as JSON: /api/errors/1db520ca7b9fa2b2. Report an issue: GitHub.