Bug 1734756 (CVE-2017-7189) - CVE-2017-7189 php: misparsing fsockopen calls in main/streams/xp_socket.c leads to information disclosure
Summary: CVE-2017-7189 php: misparsing fsockopen calls in main/streams/xp_socket.c lea...
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2017-7189
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1734757 1737474 1737475 1737476 1737477 1737478
Blocks: 1734759
TreeView+ depends on / blocked
 
Reported: 2019-07-31 11:14 UTC by Marian Rehak
Modified: 2021-10-27 10:47 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-10-27 10:47:02 UTC
Embargoed:


Attachments (Terms of Use)

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.


Note You need to log in before you can comment on or make changes to this bug.