High severity7.5NVD Advisory· Published Jan 23, 2017· Updated May 13, 2026
CVE-2016-4793
CVE-2016-4793
Description
The clientIp function in CakePHP 3.2.4 and earlier allows remote attackers to spoof their IP via the CLIENT-IP HTTP header.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
cakephp/cakephpPackagist | >= 1.2.0, < 2.6.13 | 2.6.13 |
cakephp/cakephpPackagist | >= 2.7.0-rc1, < 2.7.11 | 2.7.11 |
cakephp/cakephpPackagist | >= 2.8.0-rc1, < 2.8.2 | 2.8.2 |
cakephp/cakephpPackagist | >= 3.0.0-rc1, < 3.0.17 | 3.0.17 |
cakephp/cakephpPackagist | >= 3.1.0-beta1, < 3.1.12 | 3.1.12 |
cakephp/cakephpPackagist | >= 3.2.0-rc1, < 3.2.5 | 3.2.5 |
Affected products
1Patches
1908754649f70Don't trust Client-IP header unless behind a proxy
2 files changed · +9 −18
src/Network/Request.php+3 −12 modified@@ -523,21 +523,12 @@ public function clientIp() { if ($this->trustProxy && $this->env('HTTP_X_FORWARDED_FOR')) { $ipaddr = preg_replace('/(?:,.*)/', '', $this->env('HTTP_X_FORWARDED_FOR')); + } elseif ($this->trustProxy && $this->env('HTTP_CLIENT_IP')) { + $ipaddr = $this->env('HTTP_CLIENT_IP'); } else { - if ($this->env('HTTP_CLIENT_IP')) { - $ipaddr = $this->env('HTTP_CLIENT_IP'); - } else { - $ipaddr = $this->env('REMOTE_ADDR'); - } + $ipaddr = $this->env('REMOTE_ADDR'); } - if ($this->env('HTTP_CLIENTADDRESS')) { - $tmpipaddr = $this->env('HTTP_CLIENTADDRESS'); - - if (!empty($tmpipaddr)) { - $ipaddr = preg_replace('/(?:,.*)/', '', $tmpipaddr); - } - } return trim($ipaddr); }
tests/TestCase/Network/RequestTest.php+6 −6 modified@@ -528,7 +528,7 @@ public function testDefaultEnvValue() * * @return void */ - public function testclientIp() + public function testClientIp() { $request = new Request(['environment' => [ 'HTTP_X_FORWARDED_FOR' => '192.168.1.5, 10.0.1.1, proxy.com', @@ -539,17 +539,17 @@ public function testclientIp() $request->trustProxy = true; $this->assertEquals('192.168.1.5', $request->clientIp()); - $request->trustProxy = false; + $request->env('HTTP_X_FORWARDED_FOR', ''); $this->assertEquals('192.168.1.2', $request->clientIp()); + $request->trustProxy = false; + $this->assertEquals('192.168.1.3', $request->clientIp()); + $request->env('HTTP_X_FORWARDED_FOR', ''); - $this->assertEquals('192.168.1.2', $request->clientIp()); + $this->assertEquals('192.168.1.3', $request->clientIp()); $request->env('HTTP_CLIENT_IP', ''); $this->assertEquals('192.168.1.3', $request->clientIp()); - - $request->env('HTTP_CLIENTADDRESS', '10.0.1.2, 10.0.1.1'); - $this->assertEquals('10.0.1.2', $request->clientIp()); } /**
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
9- bakery.cakephp.org/2016/03/13/cakephp_2613_2711_282_3017_3112_325_released.htmlnvdPatchVendor AdvisoryWEB
- legalhackers.com/advisories/CakePHP-IP-Spoofing-Vulnerability.txtnvdExploitThird Party AdvisoryWEB
- www.exploit-db.com/exploits/39813/nvdExploitThird Party Advisory
- github.com/advisories/GHSA-j8p3-8m69-2hqqghsaADVISORY
- nvd.nist.gov/vuln/detail/CVE-2016-4793ghsaADVISORY
- www.securityfocus.com/bid/95846nvdWEB
- github.com/cakephp/cakephp/commit/908754649f70bab2b1093942e17c9a46a2fcf6c2ghsaWEB
- support.citrix.com/article/CTX236992nvdWEB
- www.exploit-db.com/exploits/39813ghsaWEB
News mentions
0No linked articles in our index yet.