H1514 Server Side Template Injection in Return Magic email templates?
The email template editor in Return Magic appeared to evaluate template expressions on the server. The reporter suspected possible server-side template injection but only demonstrated basic object introspection.
Originally disclosed on HackerOne
- Triaged in 2 months
- Fixed in 2 months
- Paid in 2 months
- Disclosed after 6 months
Summary by the researcher
Full story with explanation of how this was exploited can be found here: https://mahmoudsec.blogspot.com/2019/04/handlebars-template-injection-and-rce.html
The report
Summary: Possible template injection in return magic email templates.
Description:
I've been playing with return magic workflow email templates and there seems to be some kinda of template injection but I am not sure if it's exploitable or even valid.
Here is why I think it could be vulnerable:
I set the email template to the following and then test the template and then the results go to my gmail inbox.
{{ this }} -> [Object Object]
{{ this.__proto__ }} --> [Object Object]
{{ this.__proto__.constructor.name }} --> Object
I couldn't go further but it seems like the backend is NodeJs.
Steps To Reproduce:
- Install Return Magic app
- Navigate to
https://<shop>.myshopify.com/admin/apps/returnmagic - Open Settings tab from the top menu and then open Emails --> Workflow from the left menu
- Click Edit for any email template then at the editor click the code icon and enter
{{this}} - Go back to Workflow page and click Send me a test email for the template you edited then enter your email and check your inbox.
- You'll see
[Object Object]
Supporting Material/References:
████████
██████
Impact
Could be a Server Side template injection that can be used to take over the server ¯_(ツ)_/¯
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 the application used a template engine (Handlebars) to render user-supplied email templates without proper sandboxing or input sanitisation.
Impact
Could be a Server Side template injection that can be used to take over the server.
What the attacker needed
Shopify store with Return Magic app; Access to email template editor
How it was found
- Install the Return Magic app on a Shopify store.
- Navigate to the app's admin page.
- Open the Emails > Workflow settings.
- Edit an email template and insert a Handlebars expression in the code editor.
- Send a test email to your own address.
- Observe the rendered output in the received email.
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.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.