Skip to content

Commit 1554fc8

Browse files
authored
fix: Proxy: do not trust input - always set own value for 'X-Origin-IP' (#354)
An external packet received by the proxy can have any value in 'X-Origin-IP' - we can't trust it, it's best to set it on our own Signed-off-by: Alexander Piskun <[email protected]>
1 parent dc7de14 commit 1554fc8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/Controller/ExAppProxyController.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,17 +255,16 @@ private function buildHeadersWithExclude(ExApp $exApp, string $exAppRoute, array
255255
break;
256256
}
257257
}
258-
if (empty($headersToExclude)) {
259-
return $headers;
258+
if (!in_array('x-origin-ip', $headersToExclude)) {
259+
$headersToExclude[] = 'x-origin-ip';
260260
}
261+
$headersToExclude[] = 'authorization-app-api';
261262
foreach ($headers as $key => $value) {
262263
if (in_array(strtolower($key), $headersToExclude)) {
263264
unset($headers[$key]);
264265
}
265266
}
266-
if (!isset($headers['X-Origin-IP'])) {
267-
$headers['X-Origin-IP'] = $this->request->getRemoteAddress();
268-
}
267+
$headers['X-Origin-IP'] = $this->request->getRemoteAddress();
269268
return $headers;
270269
}
271270
}

0 commit comments

Comments
 (0)