weaveworks / weave-gitops-private

This is for tracking weaveworks internal information on weave-gitops. Will include issues, internal roadmaps, etc.
2 stars 3 forks source link

High-Impact Subdomain Takeover #109

Open hiddeco opened 1 year ago

hiddeco commented 1 year ago

Report

:warning: reported via security@weave.works on January 18...

Describe

High-Impact Subdomain Takeover

FQDN: wkp.weave.works
IP address: 13.49.241.153

Overview of the Vulnerability

A subdomain takeover is when a misconfigured Domain Name System (DNS) record is re-registered to an endpoint owned by an attacker. An attacker is then able to redirect users to the endpoint and capture data such as cookies and credentials, perform Cross-Site Scripting (XSS) attacks, and potentially take over accounts in the legitimate application.

A high-impact subdomain takeover vulnerability was identified which could impact the reputation and brand of the business. An attacker can register a subdomain on behalf of the target domain and use it to create a HTML document with JavaScript payload that triggers a Cross-Site Scripting (XSS) attack. The target domain can also be used to create a scenario where an attacker can harvest user credentials by phishing users who then visit and login on a cloned version of a legitimate website.

You could imagine an attacker creating any sort of website using this subdomain, including phishing sites, ransomware attacks, hosting malware, distributing porn or illegal content such as copyrighted materials. You could also imagine an attacker creating any number of other NFT or DeFi scam web pages, all under your company banner.

Business Impact

High-Impact subdomain takeover could lead to data theft and indirect financial loss through the attacker’s ability to interact with legitimate users. These malicious actions could also result in reputational damage for the business through the impact to customers’ trust.

Steps to Reproduce

    Browse to the URL https://wkp.weave.works/proof.txt
    You will see my name
    Browse to the URL https://weave.works/ and login
    Browse to the URL https://wkp.weave.works/cookie-thief.php
    You will see the cookies an attacker could steal, and possibly use to compromise an account
    Click the COOKIE BOMB button
    Browse to the URL https://weave.works/
    You will receive an error and not be able to access this site or anything related until you clear your cookies, resulting in DoS

References

Handling

If you are reporting a potential vulnerability, you could ignore this section. It is intended to be managed by a Vulnerability Manager

lizwarner-weave commented 1 year ago

@morancj is investigating

bigkevmcd commented 1 year ago

We should also do https://github.com/weaveworks/weave-gitops/issues/3409

morancj commented 1 year ago

For context, this zone was created and delegated in https://github.com/weaveworks/corp/issues/495#issuecomment-558233088

morancj commented 1 year ago

Old config

```shell dig wkp.weave.works. ; <<>> DiG 9.18.11 <<>> wkp.weave.works. ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 53040 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 65494 ;; QUESTION SECTION: ;wkp.weave.works. IN A ;; ANSWER SECTION: wkp.weave.works. 157 IN A 13.49.241.153 ;; Query time: 0 msec ;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP) ;; WHEN: Wed Feb 15 15:11:44 GMT 2023 ;; MSG SIZE rcvd: 60 dig NS wkp.weave.works. ; <<>> DiG 9.18.11 <<>> NS wkp.weave.works. ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38032 ;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 65494 ;; QUESTION SECTION: ;wkp.weave.works. IN NS ;; ANSWER SECTION: wkp.weave.works. 819 IN NS ns-1597.awsdns-07.co.uk. wkp.weave.works. 819 IN NS ns-1523.awsdns-62.org. wkp.weave.works. 819 IN NS ns-380.awsdns-47.com. wkp.weave.works. 819 IN NS ns-757.awsdns-30.net. ;; Query time: 70 msec ;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP) ;; WHEN: Wed Feb 15 15:16:55 GMT 2023 ;; MSG SIZE rcvd: 184 ```
morancj commented 1 year ago

A record and TXT record both removed.

morancj commented 1 year ago

They kindly also set X-Subdomain-Takeover: true in the headers

```shell curl -IL http://13.49.241.153/cookie-thief.php HTTP/1.1 200 OK Server: nginx Date: Wed, 15 Feb 2023 15:55:41 GMT Content-Type: text/html; charset=UTF-8 Connection: keep-alive Set-Cookie: PHPSESSID=lh80709tfvjpnh8rv6b6tch2b6; expires=Mon, 14-Feb-2033 15:55:41 GMT; Max-Age=315532800; path=/; domain=.241.153 Expires: Thu, 31 Dec 2037 23:55:55 GMT Cache-Control: max-age=315360000 Pragma: no-cache X-Subdomain-Takeover: true ```
lizwarner-weave commented 1 year ago

how civilised of them

morancj commented 1 year ago

We have likely junk in wkp.weave.works. Using r53export.sh:

```shell $ r53export.sh wkp.weave.works ; Using AWS profile sts ; Hosted zone ID: Z1TBOQ0594AGJ9 wkp.weave.works. 172800 IN NS ns-380.awsdns-47.com. wkp.weave.works. 172800 IN NS ns-757.awsdns-30.net. wkp.weave.works. 172800 IN NS ns-1523.awsdns-62.org. wkp.weave.works. 172800 IN NS ns-1597.awsdns-07.co.uk. wkp.weave.works. 900 IN SOA ns-380.awsdns-47.com. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400 _c6b2ec19a73ea2206fc67b80ae577bda.wkp.weave.works. 300 IN CNAME _56468c26ed5f4cda97fe302815a675c7.mzlfeqexyx.acm-validations.aws. demo.wkp.weave.works. IN ALIAS dualstack.d89b23d5-wkpui-wkpuialbing-603e-1976046370.eu-west-2.elb.amazonaws.com. ; HostedZoneId: ZHURV8PSTC4K8 dev.wkp.weave.works. 300 IN NS ns-1195.awsdns-21.org. dev.wkp.weave.works. 300 IN NS ns-249.awsdns-31.com. dev.wkp.weave.works. 300 IN NS ns-823.awsdns-38.net. dev.wkp.weave.works. 300 IN NS ns-1712.awsdns-22.co.uk. _acme-challenge.dev.wkp.weave.works. 300 IN TXT "jw2wful_5Cec4dBTLVPQZ6gxeD7uKvJr4hIF6vbvmtc" docs.wkp.weave.works. 60 IN CNAME weaveworks.github.io. _fa5b04d7b39c0d26cd2ac47ebf429f5b.mccp.wkp.weave.works. 300 IN CNAME _93ebb99073f87e1f41df0640795887d1.hkmpvcwbzw.acm-validations.aws. wk-simon-2.wkp.weave.works. 300 IN CNAME 1172b3a1-wkpoauth-wkpoauth-1624-778069029.eu-north-1.elb.amazonaws.com wkp-wk-simon-2.wkp.weave.works. 300 IN TXT "heritage=external-dns,external-dns/owner=default,external-dns/resource=ingress/wkp-oauth/wkp-oauth-alb-ingress" ```

dev.wkp.weave.works only appears to host charts.dev.wkp.weave.works.

```shell $ r53export.sh dev.wkp.weave.works ; Using AWS profile sts ; Hosted zone ID: Z06887422P2J81C9U51JB dev.wkp.weave.works. 172800 IN NS ns-1195.awsdns-21.org. dev.wkp.weave.works. 172800 IN NS ns-249.awsdns-31.com. dev.wkp.weave.works. 172800 IN NS ns-823.awsdns-38.net. dev.wkp.weave.works. 172800 IN NS ns-1712.awsdns-22.co.uk. dev.wkp.weave.works. 900 IN SOA ns-1195.awsdns-21.org. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400 charts.dev.wkp.weave.works. IN ALIAS d1ksdw3ce0kn9v.cloudfront.net. ; HostedZoneId: Z2FDTNDATAQYW2 _ac93eefa0e75933bfe529aa5ea0e8a47.charts.dev.wkp.weave.works. 300 IN CNAME _7e55bbcd784d138f0179448945f6b8c2.bcsdcprczz.acm-validations.aws. ```
morancj commented 1 year ago

@foot might know if we need any of these, otherwise we have to do some extra work

morancj commented 1 year ago

Intestingly, MSFT have a tool for Azure to detect dangling DNS entries here.

morancj commented 1 year ago

Stuff from my temp. repo's README, before I forget

# DNS hijacking enumeration ## Prerequisites [nuclei-templates](https://github.com/projectdiscovery/nuclei-templates) [nuclei](https://github.com/projectdiscovery/nuclei) [subfinder](https://github.com/projectdiscovery/subfinder) ## Search ```shell subfinder -d weave.works -recursive -output subfinder-recursive-weave.works.out ``` ## Check ### Broad ```shell nuclei -project -project-path nuclei -tags 'dns' \ -list subfinder-recursive-weave.works.out ``` ### Focussed ```shell nuclei -project -project-path nuclei \ -list subfinder-recursive-weave.works.out \ -templates nuclei-templates/dns/detect-dangling-cname.yaml ``` ## References [r53export.sh](https://gist.github.com/ramsey/37c3a12558a0cc38c422c7dbf2ad7c3e) [Sublist3r](https://github.com/aboul3la/Sublist3r) (alternative to `subfinder`)
foot commented 1 year ago

dev.wkp.weave.works only appears to host charts.dev.wkp.weave.works.

Yeah this is the important one

Others like simon, demo can all go I think