Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There is a storage xss vulnerability in comment title #1

Open
ghost opened this issue Aug 25, 2018 · 0 comments
Open

There is a storage xss vulnerability in comment title #1

ghost opened this issue Aug 25, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Aug 25, 2018

comment.php code show as below. Only length restrictions are applied to the $msgtitle. So caused a loophole. We can use /**/ to bypass the length limit. For example, the first comment title input "<script>alert(11111/", and second input "/11111)</script>". View comments in the background to trigger the vulnerability.

if($action == "save")
{
    $msgtitle = $_POST["msgtitle"];
    $msgname = $_POST["msgname"];
    $msgcontact = $_POST["msgcontact"];
    $msgcontent = htmlspecialchars($_POST["msgcontent"]);
    
    if (empty($_SESSION['captcha']) || trim(strtolower($_POST['capcode'])) != $_SESSION['captcha']) 
    {
        ShowMsg("验证码错误,请重新输入");
        exit();
    }
    
    if(!preg_match("/^.{1,30}$/",$msgtitle))
    {
        ShowMsg("请输入正确的标题");
        exit();
    }
    if(!preg_match("/^.{1,10}$/",$msgname))
    {
        ShowMsg("请输入您的姓名");
        exit();
    }
    if(!preg_match("/^.{1,20}$/",$msgcontact))
    {
        ShowMsg("请输入正确的联系方式");
        exit();
    }
    if(!preg_match("/^.{1,200}$/",$msgcontent))
    {
        ShowMsg("请输入正确的留言内容");
        exit();
    }
        
    $msgcontent = safeCheck($msgcontent);
    
    $userip = $_SERVER["REMOTE_ADDR"];;
	$sql = "INSERT INTO yiqi_comments (cid ,title ,name,contact,content,ip,adddate)" .
		   "VALUES (NULL, '$msgtitle', '$msgname', '$msgcontact','$msgcontent', '$userip', null)";
	$result = $yiqi_db->query(CheckSql($sql));
	if($result == 1)
	{
	    ShowMsg("留言添加成功");
	}
	else
	{
	    ShowMsg("留言添加失败");
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants