Skip to content

readWithTimeout uses incorrect logic #16364

@MegaManSec

Description

@MegaManSec

Per-call readWithTimeout uses full timeout each iteration causing cumulative blocking in HTTPConnector::recv_message (DoS) (L351-L375) (medium) (Confidence: 8.5) (Severity: 9.2)

The function readWithTimeout defined in pdns/sstuff.hh (lines 357–369) calls waitForRWData(d_socket, true, timeout, 0) and therefore uses the supplied timeout as a per-call blocking wait. In modules/remotebackend/httpconnector.cc,
HTTPConnector::recv_message (lines 437–446) enforces an overall timeout by tracking time0 and looping, but inside that loop it repeatedly invokes d_socket->readWithTimeout(..., timeout) passing the original timeout each iteration. Because each call can block up to the full timeout, multiple iterations can cumulatively exceed the intended overall timeout, resulting in threads blocking for far longer than expected and risking resource exhaustion or denial of service.

This bug was found with ZeroPath.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions