Skip to content
RCE Disclosed report Intermediate

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.

Mahmoud Gamal Follow

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:

  1. Install Return Magic app
  2. Navigate to https://<shop>.myshopify.com/admin/apps/returnmagic
  3. Open Settings tab from the top menu and then open Emails --> Workflow from the left menu
  4. Click Edit for any email template then at the editor click the code icon and enter {{this}}
  5. 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.
  6. 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 ¯_(ツ)_/¯

The original report as published on HackerOne, by zombiehelp54. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Install the Return Magic app on a Shopify store.
  2. Navigate to the app's admin page.
  3. Open the Emails > Workflow settings.
  4. Edit an email template and insert a Handlebars expression in the code editor.
  5. Send a test email to your own address.
  6. 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.

More by Mahmoud Gamal

View all

32 more disclosed reports, best first.

More from Shopify

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Remote code execution

The lesson behind this report.

Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.