Skip to content

🛡️ Sentinel: [MEDIUM] Add timeout to external API calls and fix SSL context#604

Merged
rowan-m merged 6 commits intomainfrom
sentinel/add-timeouts-and-fix-ssl-context-11659096855075533595
Mar 24, 2026
Merged

🛡️ Sentinel: [MEDIUM] Add timeout to external API calls and fix SSL context#604
rowan-m merged 6 commits intomainfrom
sentinel/add-timeouts-and-fix-ssl-context-11659096855075533595

Conversation

@rowan-m
Copy link
Contributor

@rowan-m rowan-m commented Mar 24, 2026

🚨 Severity: MEDIUM

💡 Vulnerability: The Google reCAPTCHA PHP client makes outbound API requests (via cURL, file_get_contents(), and fsockopen()) without setting explicit timeouts. Additionally, the fallback Post stream method mistakenly sets verify_peer => true in the http context array rather than the ssl context array, inadvertently causing it to be ignored by PHP.

🎯 Impact: Requests to the reCAPTCHA API that hang indefinitely (e.g. from network instability or malicious "tarpit" behavior) will cause the requesting application thread to hang indefinitely, creating a Denial of Service (DoS) vulnerability. Furthermore, the misconfigured verify_peer option means stream requests may not correctly validate the peer certificate in some environments.

🔧 Fix:

  • Added a 60-second timeout to CURLOPT_TIMEOUT in CurlPost.php.
  • Added a 60-second timeout to the http context option in Post.php.
  • Fixed the verify_peer option in Post.php by moving it to the ssl stream context.
  • Added a 60-second timeout via stream_set_timeout($handle, 60) in SocketPost.php.
  • Updated all associated assertions and mock implementations in PostTest.php and SocketPostTest.php.

✅ Verification: The modifications have been tested via manual test scripts to confirm both timeout and verify_peer array configurations operate correctly. The namespace-scoped mock for stream_set_timeout guarantees test suite stability.


PR created automatically by Jules for task 11659096855075533595 started by @rowan-m

This patch sets a 60-second timeout to all three HTTP request strategies
(cURL, streams, and raw sockets) to mitigate the risk of Denial of Service (DoS)
from requests that hang indefinitely on poor connections or tarpit attacks.

Additionally, this patch moves the `verify_peer` option in `Post.php` out
of the `http` array context and into the `ssl` array context where it belongs,
ensuring SSL certificate verification functions as intended.

The corresponding tests have been updated, and `stream_set_timeout` has been
mocked in the `ReCaptcha\RequestMethod` namespace to ensure tests continue to pass.

Co-authored-by: rowan-m <108052+rowan-m@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coveralls
Copy link

coveralls commented Mar 24, 2026

Coverage Status

coverage: 100.0%. remained the same
when pulling a783541 on sentinel/add-timeouts-and-fix-ssl-context-11659096855075533595
into 132d9a5 on main.

@rowan-m rowan-m merged commit 72c583d into main Mar 24, 2026
7 checks passed
@rowan-m rowan-m deleted the sentinel/add-timeouts-and-fix-ssl-context-11659096855075533595 branch March 24, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants