Skip to content

Commit 28ae0b9

Browse files
committed
login: Fix XSS issue if "Debug Userlogin" is enabled.
The username field was vulnerable against XSS attacks. However this only affected POST data, so creating a URL with Querystring for a XSS attack would not work.
1 parent 32d6b3f commit 28ae0b9

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
---------------------------------------------------------------------------
2+
Version 4.1.12 (stable), 2021-04-29
3+
---------------------------------------------------------------------------
4+
- Secured username field against XSS attacks, thanks for reporting to:
5+
Michael Strametz of SySS Cyber Security GmbH (Austria).
6+
- UserDB: Allow NULL value for defaultfilter fields, updated to v13
7+
---------------------------------------------------------------------------
28
Version 4.1.11 (stable), 2020-07-09
39
- ThirdParty: Updated jpgraph to 4.3.1 (2020-04-24)
410
- Thanks to Javier Pastor for the following fixes and changes:

src/include/functions_users.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ function CheckUserLogin( $username, $password )
283283
}
284284
*/
285285
if ( GetConfigSetting("DebugUserLogin", 0) == 1 )
286-
DieWithFriendlyErrorMsg( "Debug Error: Could not find user '" . $username . "' <br><br><B>Sessionarray</B> <pre>" . var_export($_SESSION, true) . "</pre>");
286+
DieWithFriendlyErrorMsg( "Debug Error: Could not find user '" . htmlspecialchars($username) . "' <br><br><B>Sessionarray</B> <pre>" . var_export($_SESSION, true) . "</pre>");
287287

288288
// Default return false
289289
return false;

src/login.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,38 +65,32 @@
6565
$szRedir = "index.php"; // Default
6666
$szRedir = SecureRedirect($szRedir);
6767

68-
if ( isset($_POST['op']) && $_POST['op'] == "login" )
69-
{
68+
if ( isset($_POST['op']) && $_POST['op'] == "login" ) {
7069
// Perform login!
7170
if ( $_POST['op'] == "login" )
7271
{
7372
if (
7473
(isset($_POST['uname']) && strlen($_POST['uname']) > 0)
7574
&&
7675
(isset($_POST['pass']) && strlen($_POST['pass']) > 0)
77-
)
78-
{
79-
// Set Username and password
80-
$content['uname'] = DB_RemoveBadChars($_POST['uname']);
81-
$content['pass'] = $_POST['pass']; // RAW Copy of password string, otherwise passwords with special characters can be broken.
76+
) {
77+
// Copy Username and password for template system
78+
$content['uname'] = htmlspecialchars(DB_RemoveBadChars($_POST['uname'])); // URL Decode the username to avoid XSS issues!
79+
$content['pass'] = htmlspecialchars($_POST['pass']); // RAW Copy of password string, otherwise passwords with special characters can be broken.
8280

83-
if ( !CheckUserLogin( $content['uname'], $content['pass']) )
84-
{
81+
// Use raw properties for database login check
82+
if ( !CheckUserLogin( DB_RemoveBadChars($_POST['uname']), $_POST['pass']) ) {
8583
$content['ISERROR'] = "true";
8684
$content['ERROR_MSG'] = $content['LN_LOGIN_ERRWRONGPASSWORD'];
8785
}
8886
else
8987
RedirectPage( urldecode($szRedir) );
90-
}
91-
else
92-
{
88+
} else {
9389
$content['ISERROR'] = "true";
9490
$content['ERROR_MSG'] = $content['LN_LOGIN_USERPASSMISSING'];
9591
}
9692
}
97-
}
98-
else if ( isset($_GET['op']) && $_GET['op'] == "logoff" )
99-
{
93+
} else if ( isset($_GET['op']) && $_GET['op'] == "logoff" ) {
10094
// logoff in this case
10195
DoLogOff();
10296
}

0 commit comments

Comments
 (0)