Skip to content

Commit 2496540

Browse files
Fix misplaced SSL stream context verify_peer option
Co-authored-by: rowan-m <108052+rowan-m@users.noreply.github.com>
1 parent c665d18 commit 2496540

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

.jules/sentinel.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
## 2024-05-18 - Misplaced SSL Context Options
2+
**Vulnerability:** The `verify_peer` stream context option was incorrectly placed inside the `http` array instead of the `ssl` array in `stream_context_create`.
3+
**Learning:** PHP's `file_get_contents` silently ignores invalid context options. Placing SSL-specific options inside the HTTP context means they are completely ignored, potentially leaving connections vulnerable to Man-In-The-Middle (MITM) attacks on older PHP versions or environments where the default stream context has `verify_peer` disabled.
4+
**Prevention:** Always verify that stream context options are placed in the correct protocol array (e.g., `ssl` for SSL/TLS options, `http` for HTTP options) as per the PHP documentation.

src/ReCaptcha/RequestMethod/Post.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public function submit(RequestParameters $params)
7777
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
7878
'method' => 'POST',
7979
'content' => $params->toQueryString(),
80+
],
81+
'ssl' => [
8082
// Force the peer to validate (not needed in 5.6.0+, but still works)
8183
'verify_peer' => true,
8284
],

0 commit comments

Comments
 (0)