Skip to content

Commit a0cb246

Browse files
authored
Merge pull request #77 from alorbach/pr-issue-76
login: Fix XSS issue if "Debug Userlogin" is enabled.
2 parents 5d0247e + 28ae0b9 commit a0cb246

File tree

7 files changed

+27
-20
lines changed

7 files changed

+27
-20
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/db_template.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ CREATE TABLE `logcon_sources` (
8181
`DBTableName` varchar(64) default NULL,
8282
`DBEnableRowCounting` tinyint(1) default NULL,
8383
`DBRecordsPerQuery` int(11) NOT NULL default '100',
84-
`defaultfilter` VARCHAR(1024) NOT NULL,
84+
`defaultfilter` VARCHAR(1024) NULL,
8585
`userid` int(11) default NULL,
8686
`groupid` int(11) default NULL,
8787
PRIMARY KEY (`ID`)
@@ -128,7 +128,7 @@ CREATE TABLE IF NOT EXISTS `logcon_charts` (
128128
`chart_type` int(11) NOT NULL,
129129
`chart_width` int(11) NOT NULL,
130130
`chart_field` varchar(255) NOT NULL,
131-
`chart_defaultfilter` VARCHAR(1024) NOT NULL,
131+
`chart_defaultfilter` VARCHAR(1024) NULL,
132132
`maxrecords` int(11) NOT NULL,
133133
`showpercent` tinyint(1) NOT NULL,
134134
`userid` int(11) default NULL,

src/include/db_update_v13.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-- New Database Structure Updates
2+
ALTER TABLE `logcon_sources` CHANGE `defaultfilter` `defaultfilter` VARCHAR(1024) NULL;
3+
ALTER TABLE `logcon_charts` CHANGE `chart_defaultfilter` `chart_defaultfilter` VARCHAR(1024) NULL;
4+
5+
-- Insert data
6+
7+
-- Updated Data

src/include/functions_common.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
$LANG = "en"; // Default language
6666

6767
// Default Template vars
68-
$content['BUILDNUMBER'] = "4.1.11";
68+
$content['BUILDNUMBER'] = "4.1.12";
6969
$content['UPDATEURL'] = "http://loganalyzer.adiscon.com/files/version.txt";
7070
$content['TITLE'] = "Adiscon LogAnalyzer :: Release " . $content['BUILDNUMBER']; // Default page title
7171
$content['BASEPATH'] = $gl_root_path;

src/include/functions_db.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
$errno = 0;
5050

5151
// --- Current Database Version, this is important for automated database Updates!
52-
$content['database_internalversion'] = "12"; // Whenever incremented, a database upgrade is needed
52+
$content['database_internalversion'] = "13"; // Whenever incremented, a database upgrade is needed
5353
$content['database_installedversion'] = "0"; // 0 is default which means Prior Versioning Database
5454
// ---
5555

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)