Skip to content

[repo-monitor] Medium: Unbounded response body read — OOM risk on large HTTP responses #7

@Liohtml

Description

@Liohtml

Summary

resp.text().await reads the entire HTTP response body into memory with no size limit, allowing a server to cause OOM by returning a multi-gigabyte response.

Location

  • File: src/fetchers/client.rs
  • Line(s): 120

Severity

Medium

Details

let body_text = resp.text().await.unwrap_or_default();

There is no Content-Length check or maximum body size configured. A server returning a multi-gigabyte response would exhaust available RAM.

Suggested Fix

Add a size guard before reading:

const MAX_BODY: u64 = 50 * 1024 * 1024; // 50 MB
if let Some(len) = resp.content_length() {
    if len > MAX_BODY {
        return Err(FetcherError::RequestFailed("response too large".into()));
    }
}
let body_text = resp.text().await.unwrap_or_default();

Automated finding by repo-monitor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions