POST http://xxxx/action/teepay-post-free title=xxxtitle&teepay_isFee=y&teepay_price=3.00&teepay_content=%3C%2Fspan%3E%3Cscript%3Ealert%28%27xss%27%29%3B%3C%2Fscript%3E&do=update&cid=1
界面重定向到后台登录界面且弹框修改成功即可。
English version
Introduction
TeePay is a plug-in that provides payment and paid reading capabilities for Typecho blogs. The basic version is open source, but has easily exploitable vulnerabilities.
Vulnerability trigger principle
In Typecho, the operation of the plug-in is bound in the Action.php file and is designed as an action () function.
In the Typecho design, this function call does not require administrator privileges, that is, ordinary users do not even need to log in. As long as they know the URL, they can call this function. This problem of Escalation of Privileges is common in Typecho.
Unfortunately, our protagonist, TeePay, also has this problem, and the user input characters are not filtered, which leads to the possibility of XSS beyond the authority. Even more regrettable, after I submitted ISSUE, the developer directly deleted the ISSUE and did not respond to me, which is why I wrote this blog post.
action () function
In the 1.5.2 (that is, the latest) Action.php file, line 33 is this function.
Very simple code, take out the parameters submitted by the user without putting any processing in the database, and pop up a cost update prompt.
The analysis of this piece of code is complete. At this point, the payload has been placed in the database unblocked. The next step is how to display it.
getTeePay () function
This plugin shows that the getTeePay function needs to be added in the article. Obviously this is the main code displayed in the Plugin.php file.
For the sake of illustration, omit some unimportant code.
The code is a bit long and deletes a lot of non-critical content, but the logic is clear.
First get the cid of the article, then check whether the requested cookies are paid, and then check whether the visitor is the author.
We will not discuss the paid area for the time being, only look at the author area.
`<? php echo $ row ['teepay_content']?>`
$ Row [‘teepay_content’] is directly output here, so where is this row?
`$ row = $ db-> fetchRow ($ query);``$ query = $ db-> select ()-> from ('table.contents')-> where ('cid =?', $ cid);`
Query directly from the database, then return directly, and output directly. XSS is so enjoyable that no filtering is required.
POC
1 2
POST http://xxxx/action/teepay-post-free title=xxxtitle&teepay_isFee=y&teepay_price=3.00&teepay_content=<span><script>alert('xss');</script>&do=update&cid=1
If the interface redirects to the background login interface and there is a prompt, it is successful