TlsHandshakePendingAccepted
warning native on by defaultGroup: Probable bugs
Identify stream_socket_enable_crypto result tested only !== false and followed by fwrite in accepted branch, with same stream proven nonblocking through successful stream_set_blocking(false). Only true confirms established handshake.
Detection
- Report stream_socket_enable_crypto result tested only !== false and followed by fwrite in accepted branch, with same stream proven nonblocking through successful stream_set_blocking(false). Only true confirms established handshake.
- Resolve builtin functions, classes, constants and methods, including imports and supported named arguments. Follow only bounded local facts within one lexical scope. Receiver and argument provenance must establish the specific API contract; variable names and comments never prove intent.
- Report one finding per violating operation. A reachable path, unchanged value identity and applicable API behavior are required. Intervening mutation, unknown calls involving tracked values, escaped aliases or exhausted analysis budgets invalidate proof.
- The write must sit in the accepted branch itself, outside nested conditionals, loops,
switch,tryand nested functions, and before any completion guard (E3). Switching the stream back to blocking mode does not finish a pending handshake, so it never clears the finding on its own.
Exceptions (no report)
- Exclude unresolved required symbols, user-defined lookalikes, incomplete syntax, unknown required values and unsupported versions.
- Both
@custos-ignore TlsHandshakePendingAcceptedand@noinspection TlsHandshakePendingAcceptedsuppress this native rule. - E3. A write placed after a completion guard is not reported. A completion guard is a test, written before the write in the accepted branch, proving that a further
stream_socket_enable_cryptocall on the same stream with a literal truthyenableargument returnedtrueon every path to the write:if (<handshake> !== true) { ... }whose body always leaves (return, throw, exit, break, continue),!<handshake>and<handshake> != true(each rejects bothfalseand the pending0),<handshake> === true or exit;, the body ofif (<handshake> === true), or any of these on a variable holding the result while it is not reassigned. A test of=== falseor!== false, a guard whose body can fall through, a guard on another stream or with a non-literal or falsyenableargument prove nothing. Writes located before the guard are still reported.
Fix
None. A repair requires a semantic decision or application error-handling policy.
PHP versions
Available in PHP 5.3–8.5 where the referenced API exists. Do not apply extension contracts when the resolved API is unavailable. Gate syntax and version-specific behavior to the configured target.
Configure
In custos.json:
json
{
"rules": {
"TlsHandshakePendingAccepted": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file):
php
// @custos-ignore TlsHandshakePendingAccepted