Skip to content
Permalink
Browse files Browse the repository at this point in the history
Limit DB LOGIN NAMES length to avoid some kind of injection
  • Loading branch information
fmancardi committed Feb 24, 2018
1 parent e2d1d1f commit 9696012
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions install/installNewDB.php
Expand Up @@ -63,22 +63,25 @@
$db_server = trim($_SESSION['databasehost']);
$db_server = preg_replace($san,'',$db_server);

$db_admin_name = trim($_SESSION['databaseloginname']);
$db_admin_name = preg_replace($san,'',$db_admin_name);

$db_admin_pass = trim($_SESSION['databaseloginpassword']);
$db_admin_pass = preg_replace($san,'',$db_admin_pass);

$db_type = trim($_SESSION['databasetype']);
$db_type = preg_replace($san,'',$db_type);

$tl_db_login = trim($_SESSION['tl_loginname']);
$tl_db_login = preg_replace($san,'',$tl_db_login);

$tl_db_passwd = trim($_SESSION['tl_loginpassword']);
$tl_db_passwd = preg_replace($san,'',$tl_db_passwd);


// will limit length to avoi some kind of injection
// Choice: 32
$tl_db_login = trim($_SESSION['tl_loginname']);
$tl_db_login = substr(preg_replace($san,'',$tl_db_login),0,32);

$db_admin_name = trim($_SESSION['databaseloginname']);
$db_admin_name = substr(preg_replace($san,'',$db_admin_name),0,32);



$sql_create_schema = array();
$sql_create_schema[] = "sql/{$db_type}/testlink_create_tables.sql";
Expand Down

3 comments on commit 9696012

@Kanaduchi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only 32?

If we use OAUTH we set login names as emails. But emails can be more that 32 symbols. Example, vasyliy.lomachenkov@microsoft.com

You can avoid injections in php (using preg_replace) not by DB

@fmancardi
Copy link
Contributor Author

@fmancardi fmancardi commented on 9696012 Feb 25, 2018 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kanaduchi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry. Its OK

Please sign in to comment.