Bug 1734756 (CVE-2017-7189)

Summary: CVE-2017-7189 php: misparsing fsockopen calls in main/streams/xp_socket.c leads to information disclosure
Product: [Other] Security Response Reporter: Marian Rehak <mrehak>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: fedora, hhorak, jorton, mbenatto, rcollet
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-10-27 10:47:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1734757, 1737474, 1737475, 1737476, 1737477, 1737478    
Bug Blocks: 1734759    

Description Marian Rehak 2019-07-31 11:14:35 UTC
main/streams/xp_socket.c in PHP 7.x before 2017-03-07 misparses fsockopen calls, such as by interpreting fsockopen('127.0.0.1:80', 443) as if the address/port were 127.0.0.1:80:443, which is later truncated to 127.0.0.1:80. This behavior has a security risk if the explicitly provided port number (i.e., 443 in this example) is hardcoded into an application as a security policy, but the hostname argument (i.e., 127.0.0.1:80 in this example) is obtained from untrusted input.

Upstream Commit:

https://github.com/php/php-src/commit/bab0b99f376dac9170ac81382a5ed526938d595a

Comment 1 Marian Rehak 2019-07-31 11:14:45 UTC
Created php tracking bugs for this issue:

Affects: fedora-all [bug 1734757]

Comment 5 Marco Benatto 2019-08-05 13:29:56 UTC
Statement:

This issue affects the php version as shipped with Red Hat Enterprise Linux 5, 6, 7, 8 and it was rated as having a security impact of 'Moderate'. It also affects the versions rh-php71-php, rh-php70-php, rh-php72-php distributed with Red Hat Software Collection 3.

Comment 6 Marco Benatto 2019-08-05 13:57:36 UTC
There's an issue with parse_ip_address_ex() used by PHP function fsockopen(). The fsockopen() function is used to open a new socket, two of its parameters are the hostname and port. When passing the host name in the format of "<hostname>:<port>", parse_ip_address_ex() function ignores the port function's parameter and tries to connect to the one informed in the hostname string. This would allow an attacker to force a connection to other port then the expected if the hostname parameter is controlled by the user or obtained from an untrusted source.

Comment 7 Marco Benatto 2019-08-05 14:02:06 UTC
There's an issue with parse_ip_address_ex() used by PHP function fsockopen(). The fsockopen() function is used to open a new socket, two of its parameters are the hostname and port. When passing the host name in the format of "<hostname>:<port>", parse_ip_address_ex() function ignores the port function's parameter and tries to connect to the one informed in the hostname string. This would allow an attacker to force a connection to other port then the expected if the hostname parameter is controlled by the user or obtained from an untrusted source.