بررسی آسیب پذیری Server Side Template Injection (SSTI)

???? ????? Server Side Template Injection (SSTI) ???? ?
???????? ???? (Template engines) ?? ??? ?????? ?? ???? ?????? ??? ??????? ??
???? ????? ???? ??? ???? (????????) ?? ???? ????? ?? ? ????? ?? ??????? ?? ????. ?????? ??? ???? ????? ????? ?? ???? ?? ? ???? ???? ????? Server Side Template Injection ????? ?? ?? ???? ????? ??? ?? ???? ????? ? ??? ???? ?? XSS ??? ?????.
- ?? ???? XSS ????? ???? (Template Injection) ?? ????? ???? ???? ??????
?? ??? ????? ??????? ?? ? ???? ?? ??? ????? ?? ?? ??? ??? (RCE) ??????? ???? ? ??? ???? ????? ?????? ????? ????? ????? ?? ???? ???.
Template Injection ?? ????? ?? ?? ???? ???? ????? ????? ? ?? ?? ???? ???? ????? Template ?? ???? ????? ????.

????? ???? ??
?????? ??? ??????? ?? ???? ?? ????? ??? ???? ????? Twig ? FreeMarker ???? ??????
?????? ???? ?? ????? ?? ? ????? ?? ??????? ?? ????. Template Injection ????? ????? ?? ???? ?? ????? ????? ?? ???? ????? ?? ???? ?????? ??? ??? (???? ????? ?????? ???? ???? ????? ???? ????? ????? ?? ????? ???? ??? ??? ????). ?? ?????? ????????? ?? ?? ??? ?????? ?? ????? ??? ????? ????? ?? ??? ? ?? ?? ???? Twig ???? ??????? ?? ??? ???????? ??????? ?? ???. ??? ??? ??? ?? ???? ????? ???? ????? ???? ??? ??? ??? ??? ??? ?? ??? :
1 |
$output = $twig-render("Dear {first_name},", array("first_name" = $user.first_name) ); |
?? ??? ???? ??? ?? ??????? ????? ???? ??? ??? ????? ?? ?? ?????? ????? ?????? ??? ?? ?? ??? :
1 |
$output = $twig-render($_GET['custom_email'], array("first_name" $user.first_name) ); |
?? ????? ???? :
?? ??? ???? ??? ????? ?????? ???? ?? ?? ???? ??????? custom_email GET ?? ??? ????? ????
? ???? ????? ???? ??? ?? ???? ????? ???? ?? ?????? ?? ??? ????? ?? ??? ???? ????? XSS ???. ??? ?? ?? ???? ??? ???? ?????? ??? ?? ????? ?????? ????? ?? ???. ????? ?? ?? ???? ????? ??? ?? ???? ????? ??? ???? ????? ?? ??? :
- ???? ???? ?? ???? ????? ????? {{7*7}} ?? ?? ????? ????? ????? ???? :
1 |
custom_email={{7*7}} |
2 |
3 |
result : 49 |
?? ?????..
???? ?? ????? ????? ?????? ????? ?? ??? ???? ?? ?? ??????? ???.
???? ?? ????? ???? ???? ??????? ? ???? ??? ????? ?? ??????? ???? ??? ? ?? ?????? ?? ???? ???.
??? ???? ????? ??????? ?? ???? ????? ??????? ????? ?? ??? ?? ???? ?? ??????? ????? ?? ????
???? ?? ?? ????? ?? ?????? ???? .?? ????? ?? ????? ??????? ?????? ??? ?? ???????? ????? ???? ???? ??? ???? ???? ????? ?? ???? ????? ???? ? ?????.Template injection ?????? ?? ????? ?? ??? ?????? ????? ???? ?????? ?? ????? ????? ?? ????? ???????? ?? ?? ???? ???? ?? ???. ??? ???? ??? ??? ???? ???? ?? ??? ????? ??? ????? ???? ????? ??? SQL Injection ???
- ?? ?? ????? ?????? ???? ???. ????? ?? ??? ?Template injection ??? ??? ????? ???? ???
???? ??????? ??? ????? ???? ?????? ?? ???? ?????? ????. ????? ???? ???? ????? ??? ?????? ????? ?? ????? ?? ????? ???? ???? ????. ?? ????? ???? ? ???? ??? ?? ????? ?? ??? Local File Include (LFI) ?? ???? ?? ?? ???? ????? ??? ?????? LFI ????? ?? ????? ??? ?? ?????? ??? log ???? ??? session ?? /proc/self/env ????
??? ????? ???? ???? ????? SSTI
??????? ?
???? ??????
???? ?
??? ???????





