Issues (4122)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

maintenance/resetUserTokens.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Reset the user_token for all users on the wiki. Useful if you believe
4
 * that your user table was acidentally leaked to an external source.
5
 *
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along
17
 * with this program; if not, write to the Free Software Foundation, Inc.,
18
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
 * http://www.gnu.org/copyleft/gpl.html
20
 *
21
 * @file
22
 * @ingroup Maintenance
23
 * @author Daniel Friesen <[email protected]>
24
 * @author Chris Steipp <[email protected]>
25
 */
26
27
require_once __DIR__ . '/Maintenance.php';
28
29
/**
30
 * Maintenance script to reset the user_token for all users on the wiki.
31
 *
32
 * @ingroup Maintenance
33
 * @deprecated since 1.27, use $wgAuthenticationTokenVersion instead.
34
 */
35
class ResetUserTokens extends Maintenance {
36 View Code Duplication
	public function __construct() {
37
		parent::__construct();
38
		$this->addDescription(
39
			"Reset the user_token of all users on the wiki. Note that this may log some of them out.\n"
40
			. "Deprecated, use \$wgAuthenticationTokenVersion instead."
41
		);
42
		$this->addOption( 'nowarn', "Hides the 5 seconds warning", false, false );
43
		$this->addOption(
44
			'nulls',
45
			'Only reset tokens that are currently null (string of \x00\'s)',
46
			false,
47
			false
48
		);
49
		$this->setBatchSize( 1000 );
50
	}
51
52
	public function execute() {
53
		$this->nullsOnly = $this->getOption( 'nulls' );
0 ignored issues
show
The property nullsOnly does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
54
55
		if ( !$this->getOption( 'nowarn' ) ) {
56
			if ( $this->nullsOnly ) {
57
				$this->output( "The script is about to reset the user_token "
58
					. "for USERS WITH NULL TOKENS in the database.\n" );
59
			} else {
60
				$this->output( "The script is about to reset the user_token for ALL USERS in the database.\n" );
61
				$this->output( "This may log some of them out and is not necessary unless you believe your\n" );
62
				$this->output( "user table has been compromised.\n" );
63
			}
64
			$this->output( "\n" );
65
			$this->output( "Abort with control-c in the next five seconds "
66
				. "(skip this countdown with --nowarn) ... " );
67
			wfCountDown( 5 );
68
		}
69
70
		// We list user by user_id from one of the replica DBs
71
		// We list user by user_id from one of the slave database
72
		$dbr = $this->getDB( DB_REPLICA );
73
74
		$where = [];
75
		if ( $this->nullsOnly ) {
76
			// Have to build this by hand, because \ is escaped in helper functions
77
			$where = [ 'user_token = \'' . str_repeat( '\0', 32 ) . '\'' ];
78
		}
79
80
		$maxid = $dbr->selectField( 'user', 'MAX(user_id)', [], __METHOD__ );
81
82
		$min = 0;
83
		$max = $this->mBatchSize;
84
85
		do {
86
			$result = $dbr->select( 'user',
87
				[ 'user_id' ],
88
				array_merge(
89
					$where,
90
					[ 'user_id > ' . $dbr->addQuotes( $min ),
91
						'user_id <= ' . $dbr->addQuotes( $max )
92
					]
93
				),
94
				__METHOD__
95
			);
96
97
			foreach ( $result as $user ) {
98
				$this->updateUser( $user->user_id );
99
			}
100
101
			$min = $max;
102
			$max = $min + $this->mBatchSize;
103
104
			wfWaitForSlaves();
0 ignored issues
show
Deprecated Code introduced by
The function wfWaitForSlaves() has been deprecated with message: since 1.27 Use LBFactory::waitForReplication

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
105
		} while ( $min <= $maxid );
106
	}
107
108
	private function updateUser( $userid ) {
109
		$user = User::newFromId( $userid );
110
		$username = $user->getName();
111
		$this->output( 'Resetting user_token for "' . $username . '": ' );
112
		// Change value
113
		$user->setToken();
114
		$user->saveSettings();
115
		$this->output( " OK\n" );
116
	}
117
}
118
119
$maintClass = "ResetUserTokens";
120
require_once RUN_MAINTENANCE_IF_MAIN;
121