Urgent: Server side template injection via Smarty template allows for RCE
The application used the Smarty templating engine and inserted user-controlled profile fields into invitation emails without sanitising them, so template syntax in those fields was evaluated. An attacker could run PHP code on the server and read local files such as the password file.
- Disclosed after 12 months
Hi All, I've found an issue which has allowed me to execute file_get_contents and extract your /etc/passwd file.
##Description It appears as though you are using smarty on the backend for templating. Entering a malicious payload as my firstname, lastname and nickname and then inviting a user to join the site results in the code being executed.
To start, I began with the payload {7*7} and received a template error in the email I received

Recognizing the injection, I then was able to confirm the version of smarty used via {$smarty.version} Next I was able to test {php} tags by using {php}print "Hello"{/php} . Finally I used file_get_contents to begin extracting the etc/pass file {php}$s = file_get_contents('/etc/passwd',NULL, NULL, 0, 100); var_dump($s);{/php}

##Steps to reproduce
- Edit your profile
- Add the payload
{php}$s = file_get_contents('/etc/passwd',NULL, NULL, 0, 100); var_dump($s);{/php}as your first name, last name and user name (I'm not sure which field is vulnerable) - Invite a friend using another email of yours
- View the email and you will see part of the etc file dumped
##Vulnerability Since the {php} tags are being parsed and executed, we can execute php functions. In this case, you'll see I'm able to extract the etc/passwd file. While I haven't tried, an attacker can more than likely create a shell on the server.
Please let me know if you have any questions. Pete
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely user-supplied profile fields were passed directly into Smarty templates without escaping or sandboxing, so template tags in those fields were compiled and executed.
Impact
An attacker could execute PHP functions on the server and read local files, and the reporter suggests a shell could likely be created, though that was not tried.
What the attacker needed
A user account; ability to edit profile fields; ability to send an invitation
How it was found
- Edit the profile.
- Put a template payload in the first name, last name and user name fields.
- Invite a friend using another email address.
- Open the invitation email and see part of the system file dumped.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Templating engines let websites fill in placeholders like a name inside an email. If the engine is given raw user input, it treats special markers in that input as instructions and runs them. Here the markers let the attacker run PHP code on the server, which is why they could read a system file.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.