# RuubikCMS 1.0.3 csrf 和xss漏洞
## csrf 漏洞
漏洞存在文件:ruubikcms/cms/users.php
```
............................................
if ($_POST['save']) {
// username not selected if disabled
if (!$_POST['username']) $_POST['username'] = $_POST['username_hidden'];
if ($_POST['password'] != $_POST['confirmpassword']) $error = TRUE;
// strip slashes if needed
if (function_exists('get_magic_quotes_gpc') AND get_magic_quotes_gpc()) {
$_POST = stripslashes_deep($_POST);
}
// not dot allow administrator to change his own role (ensure there is always one administrator)
if (!$_POST['role'] or $_GET['p'] == $_SESSION['uid']) $_POST['role'] = '5';
// new user -> get unique username
if (!$_GET['p'] AND $_GET['n']) {
$newname = get_unique_url($_POST['username'], 2);
if ($_POST['password'] == "") $error = TRUE;
$new = TRUE;
} else {
$newname = $_GET['p'];
}
............................................
} else {
// passwords also changes, insert or replace all data
$stmt = $dbh->prepare("INSERT OR REPLACE INTO cmsuser (username, password, role, firstname, lastname, email, phone) VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->bindParam(1, $newname);
$stmt->bindParam(2, sha1($_POST['password']));
$stmt->bindParam(3, $_POST['role']);
$stmt->bindParam(4, $_POST['firstname']);
$stmt->bindParam(5, $_POST['lastname']);
$stmt->bindParam(6, $_POST['email']);
$stmt->bindParam(7, $_POST['phone']);
$stmt->execute();
}
```
修改用户密码没有要求用户输入验证码之类的措施,存在csrf漏洞
## xss漏洞
```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo RLANG;?>" lang="<?php echo RLANG;?>">
<head>
<title>RuubikCMS - <?php echo $cmspage;?></title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="RuubikCMS - The easy & fast way to build Google optimized websites." />
<meta name="keywords" content="CMS, SEO, RuubikCMS" />
<meta name="robots" content="none" />
<meta name="author" content="Iisakki Pirilä, Henrik Valros" />
<meta name="copyright" content="Iisakki Pirilä, Henrik Valros" />
```
<?php echo $cmspage;?> 直接输出没有过滤,
当PHP<5.4 register_gloable=on的时候,才会触发
暂无评论