Skip to content
RCE Disclosed report Intermediate

'Limited' RCE in certain places where Liquid is accepted

Liquid templates in shop notification emails and the checkout thank-you page exposed Ruby object methods and hidden properties to shop administrators. An attacker with admin access could call no-argument methods and dump hidden fields such as hashed passwords, and potentially reach dangerous methods.

brakhane Follow

Originally disclosed on HackerOne

Bounty$1,500 View original
  • Triaged in 3 days
  • Fixed in 4 days
  • Paid in 4 days
  • Disclosed after 4 days

Summary by the program

This issue allowed calls to ruby methods that were not intended to be available to the Liquid template.

The report

Short

Certain interfaces where a shop owner/administrator is able to utilize Liquid have access to methods and properties of certain Drops. This allows calling all methods of the object and access to all properties. While this sounds bad, it seems to be very limited and seems to be 'only' usable for Information Disclosure.

PoC

  1. Go to your shop admin and navigate to the Notifcation settings

  2. Edit the New Order Template and place the following text into the textbox (also shown in the Malicious Template screenshot:

    {{ methods | json }} {{ systemu }} {{ class }} {{ to_yaml}}

  3. Click the Preview Button to have your code executed, results are shown in the Malicious Template Rendered screenshot.

Affected parts of the system

Almost all of the Notification Email Templates are affected. It looks like one has access to an OrderDrop and DraftOrderDrop instance (verifyable throigh {{ class }} or similar methods which expose the class name). Please see the attached Affected Mail Templates screenshot, all templates which do have a Revert to default button rendered are affected.

The thank you page of the checkout is also affected, please see the Checkout Template and Checkout Rendering screenshots which are attached.

Limitations

I wasn't able to supply arguments to the methods exposed through this method, but one is still able to call methods which don't accept any. But just because I couldn't find a way doesn't mean there isn't any.

Impact

  1. One has (at least) the ability to execute instance methods with no arguments and read access to certain otherwise hidden fields via the to_yaml method. Depending on the actual code which is flawed it might be even possible to execute methods with user supplied arguments which would probably result in a server breach (there are very intersting methods like systemu, real_call, instance_eval and instance_exec.

  2. This bypasses access restrictions to certain hidden/filtered fields, like a hashed user password. For example, a malicious admin can force the delivery of the Real Order Mail Rendered to an address controlled by him if he does the following:

  3. Ensure the last user who touched an order is a desired victim (e.g. the shop owner)

  4. Edit the customers email to an attacker controlled one via the Customer admin interface

  5. Resend an order confirmation mail which is prepared to render like Real Order Rendering in an Email, by placing {{ to_yaml }} in the template

Final words

Depending on the real flaw in the code this might be something which needs to be addressed by the Liquid library. I would be very pleased if you could disclose what kind of condition exactly led to this flaw. It might be worth chaning Liquid in a way to guard against this kind of flaw as users expect it to be secure by default.

Please let me know if you need any additional information here, I hope I was clear enough with my explainations. I'm still a little disappointed that I didn't manage to achieve 'real' RCE here, but I'm happy on the other side to report this asap even without 'real' RCE so you could fix this asap. I discovered this approx. 18h ago by accident and couldn't spend that much time on developing a PoC.

Attachments

Malicious_Template_Rendered.png
Malicious_Template_Rendered.png From the original on HackerOne
Affected_Mail_Templates.png
Affected_Mail_Templates.png
Malicious_Template.png
Malicious_Template.png
Real_Order_Mail_Rendering.png
Real_Order_Mail_Rendering.png
Checkout_Template.png
Checkout_Template.png
Checkout_Rendering.png
Checkout_Rendering.png

The original report as published on HackerOne, by brakhane. 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 Liquid drops exposed their underlying Ruby object and its methods to templates instead of restricting templates to a safe allowlist of properties.

Impact

An administrator could call no-argument instance methods and read hidden fields such as hashed passwords, and the author notes it might be possible to pass arguments and reach a server breach, though this was not demonstrated.

What the attacker needed

Shop administrator access; Liquid-enabled template interface

How it was found

  1. Open the notification settings in the shop admin.
  2. Edit the new order email template and insert template expressions that call object methods.
  3. Click preview to render the template and see the results.

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.

Liquid is a template language used to build text like emails from placeholders. Here the template engine let a shop administrator reach the underlying Ruby objects and call their methods, which should have been hidden. That leaked private data and could have led to running code on the server.

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 brakhane

View all

12 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.