What changed, and why it matters
This patch fixes a time comparison bug in Monero's restricted RPC daemon. The old code constructed a clock time point from a user-supplied number of seconds, which could overflow or produce a wildly wrong date. It then compared that date to 'now' to decide whether the requested histogram cutoff was too old. The new code converts 'now' to a plain second count, subtracts the allowed restricted window, and compares the resulting boundary directly against the user's value. This avoids constructing a time point from untrusted input and makes the age check more reliable. The practical security effect is likely limited because the call is only relevant on restricted RPC endpoints and the worst outcome appears to be an incorrect rejection or acceptance of a histogram request, not direct loss of funds or remote code execution.
Treat as a low-to-moderate reliability/security hardening fix. Apply the patch, run existing RPC tests for get_output_histogram with boundary and large recent_cutoff values, and consider adding a regression test that exercises the maximum uint64_t recent_cutoff case on restricted RPC.
Security signals we found
integer/time representation overflow in cutoff validation
restricted RPC input used to construct chrono time_point
comparison logic rewritten to avoid epoch-second wraparound
patch is small and defensive, not a full feature change
Evidence from the diff
In src/rpc/daemon_handler.cpp the get_output_histogram handler validates req.recent_cutoff when m_restricted is true. Previously it built a system_clock::time_point from std::chrono::seconds{req.recent_cutoff} and compared clock::now() - cutoff against restricted_histogram_cutoff. Because req.recent_cutoff is a uint64_t interpreted as seconds since epoch, very large values wrap around the time_point representation, causing undefined/implementation-defined behavior and an unreliable age check. The patch instead casts clock::now().time_since_epoch() to seconds, subtracts restricted_histogram_cutoff, and compares req.recent_cutoff against that oldest allowed cutoff. This keeps the comparison in the integer domain of the request and prevents time_point overflow.
Changed components
src/rpc/daemon_handler.cppMonero daemon restricted RPCget_output_histogram RPC methodInspect captured patch +3 / −2
### src/rpc/daemon_handler.cpp
@@ -848,8 +848,9 @@ namespace rpc
}
using clock = std::chrono::system_clock;
- const clock::time_point cutoff{std::chrono::seconds{req.recent_cutoff}};
- if (m_restricted && clock::now() - cutoff > restricted_histogram_cutoff)
+ const auto now = std::chrono::duration_cast<std::chrono::seconds>(clock::now().time_since_epoch());
+ const std::uint64_t oldest_cutoff = std::chrono::seconds{now - restricted_histogram_cutoff}.count();
+ if (m_restricted && req.recent_cutoff > 0 && req.recent_cutoff < oldest_cutoff)
{
res.status = Message::STATUS_FAILED;
res.error_details = "Recent cutoff is too old";Why this scored 50/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.