Bug #68920 [NEW]: php_x509_fingerprint_match need stricter checks

From: Date: Tue, 27 Jan 2015 12:51:34 +0000
Subject: Bug #68920 [NEW]: php_x509_fingerprint_match need stricter checks
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-190245@lists.php.net to get a copy of this message
From:             erik at datahack dot se
Operating system: 
PHP version:      5.6.5
Package:          OpenSSL related
Bug Type:         Bug
Bug description:php_x509_fingerprint_match need stricter checks

Description:
------------
In php_x509_fingerprint_match() and its caller, due to its logic the
"SSL context" option 'peer_fingerprint' may pass and establish the
connection with or without a warning, if set to an invalid value
(specifically data type).

Test script:
---------------
<?php

error_reporting(E_ALL);

// pass, warning
var_dump(stream_socket_client("ssl://php.net:443", $errno, $errstr, 30,
STREAM_CLIENT_CONNECT, stream_context_create([
        'ssl' => ['verify_peer'=> false, 'peer_fingerprint'
=> true]
        ])));

// pass, no warning
var_dump(stream_socket_client("ssl://php.net:443", $errno, $errstr, 30,
STREAM_CLIENT_CONNECT, stream_context_create([
        'ssl' => ['verify_peer'=> false, 'peer_fingerprint'
=> null]
        ])));

// pass, no warning
var_dump(stream_socket_client("ssl://php.net:443", $errno, $errstr, 30,
STREAM_CLIENT_CONNECT, stream_context_create([
        'ssl' => ['verify_peer'=> false, 'peer_fingerprint'
=> []]
        ])));

// pass, no warning
var_dump(stream_socket_client("ssl://php.net:443", $errno, $errstr, 30,
STREAM_CLIENT_CONNECT, stream_context_create([
        'ssl' => ['verify_peer'=> false, 'peer_fingerprint'
=> ['foo']]
        ])));


Expected result:
----------------
All these connections should fail or at least give a warning.

Actual result:
--------------
Connection is established in all cases...

-- 
Edit bug report at https://bugs.php.net/bug.php?id=68920&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=68920&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=68920&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=68920&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=68920&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=68920&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=68920&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=68920&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=68920&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=68920&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=68920&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=68920&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=68920&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=68920&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=68920&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=68920&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=68920&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=68920&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=68920&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=68920&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=68920&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#190245) next »