Skip to content

Commit

Permalink
Do not use PHP_SELF
Browse files Browse the repository at this point in the history
Upstream is using extensively PHP_SELF which is the source of XSS
vulnerabilities. This patch removes PHP_SELF and uses ? when possible,
and also forces the use of SCRIPT_NAME instead of
PHP_SELF.do-not-use-PHP_SELF-to-avoid-xss
  • Loading branch information
thomasgoirand authored and f3l1x committed Jun 21, 2023
1 parent a5fd9cb commit 1ca484b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/nusoap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4565,11 +4565,11 @@ function register($name, $in = array(), $out = array(), $namespace = false, $soa
if (!$soapaction) {
if (isset($_SERVER)) {
$SERVER_NAME = $_SERVER['SERVER_NAME'];
$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$SCRIPT_NAME = $_SERVER['SCRIPT_NAME'];
$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
} elseif (isset($HTTP_SERVER_VARS)) {
$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
$SCRIPT_NAME = $HTTP_SERVER_VARS['SCRIPT_NAME'];
$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
} else {
$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
Expand Down Expand Up @@ -4649,12 +4649,12 @@ function configureWSDL($serviceName, $namespace = false, $endpoint = false, $sty
if (isset($_SERVER)) {
$SERVER_NAME = $_SERVER['SERVER_NAME'];
$SERVER_PORT = $_SERVER['SERVER_PORT'];
$SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
$SCRIPT_NAME = $_SERVER['SCRIPT_NAME'];
$HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off');
} elseif (isset($HTTP_SERVER_VARS)) {
$SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
$SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT'];
$SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
$SCRIPT_NAME = $HTTP_SERVER_VARS['SCRIPT_NAME'];
$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
} else {
$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
Expand Down Expand Up @@ -5597,7 +5597,7 @@ function popout(){ // Hides message
<br><br>
<div class=title>' . $this->serviceName . '</div>
<div class=nav>
<p>View the <a href="' . $PHP_SELF . '?wsdl">WSDL</a> for the service.
<p>View the <a href="?wsdl">WSDL</a> for the service.
Click on an operation name to view it&apos;s details.</p>
<ul>';
foreach ($this->getOperations() as $op => $data) {
Expand Down

0 comments on commit 1ca484b

Please sign in to comment.