DNS Rebinding, The treacherous attack it can be
The author attempted a DNS rebinding attack against a bug bounty program, using a headless browser to access AWS metadata. The attack appeared to succeed, but the AWS instance belonged to an analytics service, not the target, so no real vulnerability was confirmed.
Published on medium.com
{{media:0}}
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This is a write-up about DNS rebinding as a bug bounty technique, told through one attempt that produced a result. The target is not a named product or feature: the researcher had received an HTTP pingback, in his case through the Referer header, and the IP address behind it resolved to AWS. That combination is what makes DNS rebinding worth attempting, because a host that can be made to look like a local address can reach the AWS instance metadata service at http://[redacted]/latest/meta-data and everything underneath it, as though the request came from inside the internal network.
The report is explicit that this is not a story of an attack that stopped working partway. It is the one time out of around four attempts where the researcher got it to work, got results, and then learned from the bug bounty program that the AWS instance in question did not belong to them.
Setup
DNS rebinding, in the researcher's short explanation, is a way to trick a victim, or a headless web browser with JavaScript support, into causing the attacker's server to connect to it and then quickly switch to a local IP address. Under that cover the attacker can extract internal network information that normally blocks external IP addresses but not local ones.
The tools and infrastructure used were:
- Singularity, from NCC Group, downloaded from
https://github.com/nccgroup/singularityand run following its instructions. - A VPS dedicated to the attack.
- A domain registered for free through Freenom (
https://www.freenom.com/), with its nameservers pointed at Digital Ocean, where the DNS records for the attack were configured. - Burp Collaborator for the JavaScript support test, and Burp Repeater for the request that triggered the payload.
The researcher notes a practical cost of the approach: many frameworks require you to enter your VPS IP address and available ports (usually 8080 or 8000), and they require you to dedicate the VPS to the attack until you are done or give up, because you have to stop the DNS service on it. Once a service such as named and/or bind is stopped, the VPS can essentially only accept incoming connections: wget does not work, and pinging anything shows a local IP address. The only active use left is extracting internal network information from the vulnerable remote server once the victim browser triggers the payload, whether that payload does port scanning, AWS data extraction, Jenkins, IoT or something else.

The diagram simplifies the process. The researcher notes that he used [redacted] instead of [redacted] because of space.
The prerequisites he lists are:
- A VPS.
- A paid web host or Freenom. He says you would probably get further with a paid web host, but used Freenom for this PoC.
- The crucial requirement: the target has to support JavaScript.
- Patience, optionally.
Finding it
The starting point was an HTTP pingback whose IP resolved to AWS. Before investing in a rebinding attack, the researcher first checks whether the pingback comes from something that executes JavaScript, because without JavaScript support the attack is a non-starter. He describes this as avoiding the likely headache of a DNS rebinding attack that, even if it succeeds, may still turn out to be out of scope for the program.
Exploitation
Step 1: confirm JavaScript support
He serves a page containing a script tag pointing at a Collaborator subdomain:
<script src=//jstest.burpcollaborator.net></script>
Naming the file index.html covers the case where the pingback only goes to the root page. Sometimes /autoattack.html is possible, as it was in this case where he could specify the page, but the safest bet in most cases is index.html. The request then carries:
Referer: http://yourserver.com/
To avoid waiting for JavaScript that will never arrive, he either monitors the server's access.log or similar, or makes one request with 1.burpcollaborator.net, then yourserver.com, then 2.burpcollaborator.net. HTTP pingbacks to 1 and 2 but nothing on jstest.burpcollaborator.net may mean JavaScript is not supported. If jstest.burpcollaborator.net is hit, the target is worth pursuing.
Step 2: prepare the rebinding infrastructure
The domain was registered through Freenom and its nameservers were set to Digital Ocean. This is the Digital Ocean DNS setup used for the attack:

He hit a DNS server caching issue and had to change the name of his Freenom domain to get around it, which he describes as a quick fix.
Step 3: get Singularity running and adapt it
He downloaded Singularity, followed the instructions to get it up and running, and edited various files under /root/singularity/html as per the instructions.

When he tried it, he got a lot of not-found errors, especially for JavaScript. The cause was that resolving *.myserver.tk would not switch to [redacted], so the browser could not reach the locally hosted JavaScript files in subfolders.
Rather than fixing the resolution, he worked around it. His reasoning was that if he left the default IP address inside autoattack.html and added a block of code to send the output to his own destination, he would not need anything beyond Singularity running in almost default mode on his server, and the resolution of his Freenom domain would not matter.
He describes the screenshot as showing the original code on the left and the added code highlighted on the right. He estimates the split as roughly 30 percent his modification, which let him read the results, and 70 percent the tool in almost default mode. The default mode uses the AWS path from https://github.com/nccgroup/singularity/blob/master/html/payloads/aws-metadata-exfil.js, while the code that sent the output back to him was added inside autoattack.html on his server. Because of this, he could not use anything except the default AWS path, /latest/meta-data.
Step 4: send the triggering request
He sent this request in Repeater:

As mentioned earlier, in this case he was able to specify the page. He also notes that the response does not really matter: from his experience you may get a 404 and still end up with an HTTP and/or DNS pingback days later.
Step 5: wait for the callback
He waited, and then the pingback arrived:

He describes the excitement that followed, walking around his apartment and talking to himself, and notes that the program in question was one of those that can afford enormous payouts for these sorts of bugs. He then wrote the report and sent it in.
Step 6: the outcome
After a few back and forth messages, the program determined from the AWS IP address that the instance was not theirs. They believed it might have been some analytics AWS that simply followed the Referer URL on their page and triggered the HTTP pingback from the analytics side. The researcher's conclusion is that it wasted a lot of his time, though he learned a thing or two.
Root cause
The report does not analyse a vulnerability in the target's code. The mechanism it relies on is that a victim browser can be made to connect to the attacker's server and then quickly switch to a local IP address, so requests reach internal services that are not exposed to the internet. The AWS metadata endpoint at [redacted] is reachable from the instance as though the request came from inside the internal network, which is what makes the technique valuable when the pingback originates from AWS.
In this case the precondition that made the attack meaningful, namely that the AWS instance belonged to the program, did not hold. The pingback came from an analytics service that followed the Referer URL, so the rebinding succeeded technically but pointed at infrastructure outside the program's scope.
Impact
When the instance does belong to the target, the researcher's description of the technique is that an attacker can extract internal network information that normally blocks external IP addresses but not local ones, including the AWS metadata tree under /latest/meta-data. The attack requires the pingback source to execute JavaScript, and it requires the attacker to dedicate a VPS and stop its DNS service for the duration. Even a successful rebind may be out of scope for the program. In this instance the only result was a pingback from an analytics AWS instance, and no data belonging to the program was obtained.
Fix
The report does not describe a fix applied by the program. The defensive direction implied by the technique is to prevent internal-only endpoints such as the instance metadata service from being reachable by browser-driven requests originating from untrusted hostnames, and to treat Referer-driven callbacks as untrusted input. The report does not state which of these, if any, was implemented.
Variants to test
- JavaScript support probe. Serve
index.htmlwith<script src=//jstest.burpcollaborator.net></script>and send a request withReferer: http://yourserver.com/. A hit on the Collaborator subdomain means the pingback source executes JavaScript and rebinding is worth attempting. - Page-specific payload delivery. Where the pingback allows you to choose the path, try
/autoattack.htmlinstead ofindex.html. A positive result is the payload page being fetched rather than only the root. - Default AWS metadata extraction. Run Singularity in almost default mode against the AWS path and add output exfiltration inside
autoattack.html. A positive result is metadata content arriving at your destination, though the report warns the response to the triggering request may be a 404 and the callback may only arrive days later. - **
- Alternative frameworks. The researcher lists
https://github.com/FSecureLABS/dref, which he got working a few years earlier but had issues with when trying it recently, possibly related to his VPS DNS and virtual host changes. A positive result is the same kind of rebind and callback described above.
What happened, in plain words
This is a story about a technique called DNS rebinding, told by someone who tried it several times and got it to work once. The result he got turned out to be a false alarm, but the journey is still worth reading, because it shows what the attack is, what you need to set it up, and how easy it is to chase the wrong thing.
A quick note on the words you will meet. A bug bounty program is a scheme where a company pays people for finding and reporting security problems in its systems. A researcher here means someone hunting for those problems. A server is a computer that answers requests from other computers. A VPS (virtual private server) is a rented computer in a data centre that you control completely, as if it were your own machine. A domain is the name people type to reach a site, like example.com. DNS is the system that turns that name into the numeric address of a computer, called an IP address. An HTTP pingback is when a server you do not control makes a request back to a server you do control, telling you it did something. A header is a small labelled line of extra information that travels with a web request, and the Referer header is the one that says which page the request came from.
The researcher had received an HTTP pingback, in his case through the Referer header, and the IP address behind it resolved to AWS, Amazon's cloud platform. That combination is what makes DNS rebinding worth trying: if you can make your server appear to be a local address, you can reach the AWS instance metadata service at http://[redacted]/latest/meta-data and everything underneath it, as though the request came from inside the internal network.
He is clear that this is not a story of an attack that stopped working partway. It is the one time out of around four attempts where he got it to work, got results, and then learned from the bug bounty program that the AWS instance in question did not belong to them.
What DNS rebinding is
In the researcher's short explanation, DNS rebinding is a way to trick a victim, or a headless web browser with JavaScript support, into causing the attacker's server to connect to it and then quickly switch to a local IP address. Under that cover the attacker can extract internal network information that normally blocks external IP addresses but not local ones.
A few of those terms need unpacking. A headless web browser is a browser with no window on a screen, run by a program rather than a person, often used by servers to render pages. JavaScript is the programming language that web pages run inside your browser to make them interactive; a page without it is just static text and pictures. A local IP address is an address that only means something inside a private network, such as [redacted], which always points back at the machine itself. Internal network information means data held on machines that are not reachable from the open internet, such as a company's internal servers.
The everyday comparison: imagine a building where the reception desk only lets in people whose badge says they work there. If you can convince the desk that your badge says "employee" for just long enough to walk through the door, you are inside, and once inside you can read the noticeboards that visitors never see. DNS rebinding is a way of flashing that badge at the right moment.
The tools and what they cost you
The tools and infrastructure used were:
- Singularity, from NCC Group, downloaded from
https://github.com/nccgroup/singularityand run following its instructions. Singularity is a ready-made toolkit for this attack: it runs the DNS server and serves the payload pages. - A VPS dedicated to the attack.
- A domain registered for free through Freenom (
https://www.freenom.com/), with its nameservers pointed at Digital Ocean, where the DNS records for the attack were configured. A nameserver is the server that holds the DNS records for a domain, and Digital Ocean is a cloud provider whose DNS service he used. - Burp Collaborator for the JavaScript support test, and Burp Repeater for the request that triggered the payload. Burp is a widely used tool for inspecting and modifying web traffic; Collaborator gives you a throwaway address that records any request sent to it, and Repeater lets you send the same request again and again, editing it each time.
The researcher notes a practical cost of the approach: many frameworks require you to enter your VPS IP address and available ports (usually 8080 or 8000), and they require you to dedicate the VPS to the attack until you are done or give up, because you have to stop the DNS service on it. A port is a numbered channel on a computer, so one machine can run several services at once. Once a service such as named and/or bind is stopped, the VPS can essentially only accept incoming connections: wget does not work, and pinging anything shows a local IP address. named and bind are the standard DNS server software on Linux, wget is a command-line tool for downloading files, and ping is a command that checks whether another computer answers. The only active use left is extracting internal network information from the vulnerable remote server once the victim browser triggers the payload, whether that payload does port scanning, AWS data extraction, Jenkins, IoT or something else. Port scanning means probing which channels on a machine are open, Jenkins is a popular automation server often found inside company networks, and IoT means internet-connected devices such as cameras and sensors.

The diagram simplifies the process. The researcher notes that he used [redacted] instead of [redacted] because of space. [redacted] is a shorthand address meaning "this machine", and [redacted] is the special address AWS instances use to reach their own metadata service.
The prerequisites he lists are:
- A VPS.
- A paid web host or Freenom. He says you would probably get further with a paid web host, but used Freenom for this PoC. A PoC, or proof of concept, is a small demonstration that an attack works.
- The crucial requirement: the target has to support JavaScript.
- Patience, optionally.
Finding it
The starting point was an HTTP pingback whose IP resolved to AWS. Before investing in a rebinding attack, the researcher first checks whether the pingback comes from something that executes JavaScript, because without JavaScript support the attack is a non-starter. He describes this as avoiding the likely headache of a DNS rebinding attack that, even if it succeeds, may still turn out to be out of scope for the program. Out of scope means the program has said that this particular system or bug is not covered by its rewards, so finding it earns nothing.
Exploitation
Step 1: confirm JavaScript support
He serves a page containing a script tag pointing at a Collaborator subdomain:
<script src=//jstest.burpcollaborator.net></script>
Line by line: <script opens a tag that tells the browser to load and run a program. src= says where that program lives. //jstest.burpcollaborator.net is the address of the program, written without http or https so the browser uses whatever scheme the page itself uses. ></script> closes the tag. The effect is that any browser rendering this page immediately fetches a file from the Collaborator address, and that fetch is recorded. If the record appears, the page was rendered by something that runs JavaScript.
Naming the file index.html covers the case where the pingback only goes to the root page. index.html is the default page a web server hands out when you ask for a folder without naming a file. Sometimes /autoattack.html is possible, as it was in this case where he could specify the page, but the safest bet in most cases is index.html. The request then carries:
Referer: http://yourserver.com/
This is a single header line. Referer is the header name, and http://yourserver.com/ is the value: the address of the page the request claims to come from. By putting his own server there, he arranges for the target to call back to him, and that call is the pingback he is watching for.
To avoid waiting for JavaScript that will never arrive, he either monitors the server's access.log or similar, or makes one request with 1.burpcollaborator.net, then yourserver.com, then 2.burpcollaborator.net. The access.log is the file where a web server records every request it receives. HTTP pingbacks to 1 and 2 but nothing on jstest.burpcollaborator.net may mean JavaScript is not supported. If jstest.burpcollaborator.net is hit, the target is worth pursuing. The logic is a control test: the first and last addresses prove the callback path works at all, so a missing hit in the middle can only be explained by the page not running scripts.
Step 2: prepare the rebinding infrastructure
The domain was registered through Freenom and its nameservers were set to Digital Ocean. This is the Digital Ocean DNS setup used for the attack:

He hit a DNS server caching issue and had to change the name of his Freenom domain to get around it, which he describes as a quick fix. Caching is when a system keeps a copy of an answer it received earlier so it can reply faster next time; the downside is that it may keep serving an old answer after you have changed the real one.
Step 3: get Singularity running and adapt it
He downloaded Singularity, followed the instructions to get it up and running, and edited various files under /root/singularity/html as per the instructions. That path is simply a folder on his server where the tool keeps the web pages it serves.

When he tried it, he got a lot of not-found errors, especially for JavaScript. The cause was that resolving *.myserver.tk would not switch to [redacted], so the browser could not reach the locally hosted JavaScript files in subfolders. The *. part means "any subdomain of", and [redacted] is the address of the machine itself. The whole point of the attack is that the name should flip from his public server to the local address at the right moment; when it refused to flip, the page could not load its own scripts.
Rather than fixing the resolution, he worked around it. His reasoning was that if he left the default IP address inside autoattack.html and added a block of code to send the output to his own destination, he would not need anything beyond Singularity running in almost default mode on his server, and the resolution of his Freenom domain would not matter. In other words, instead of making the clever part work, he kept the tool's built-in behaviour and bolted on a way to receive the results.
He describes the screenshot as showing the original code on the left and the added code highlighted on the right. He estimates the split as roughly 30 percent his modification, which let him read the results, and 70 percent the tool in almost default mode. The default mode uses the AWS path from https://github.com/nccgroup/singularity/blob/master/html/payloads/aws-metadata-exfil.js, while the code that sent the output back to him was added inside autoattack.html on his server. Because of this, he could not use anything except the default AWS path, /latest/meta-data. That path is the address inside the metadata service where AWS lists information about the instance.
Step 4: send the triggering request
He sent this request in Repeater:

As mentioned earlier, in this case he was able to specify the page. He also notes that the response does not really matter: from his experience you may get a 404 and still end up with an HTTP and/or DNS pingback days later. A 404 is the standard answer meaning "page not found". The point is that the visible answer to his request is not the signal; the signal is the separate callback that arrives later.
Step 5: wait for the callback
He waited, and then the pingback arrived:

He describes the excitement that followed, walking around his apartment and talking to himself, and notes that the program in question was one of those that can afford enormous payouts for these sorts of bugs. He then wrote the report and sent it in.
Step 6: the outcome
After a few back and forth messages, the program determined from the AWS IP address that the instance was not theirs. They believed it might have been some analytics AWS that simply followed the Referer URL on their page and triggered the HTTP pingback from the analytics side. Analytics here means a third-party service that measures traffic on a website; such services often follow links they see, which is exactly what produced the false callback. The researcher's conclusion is that it wasted a lot of his time, though he learned a thing or two.
Why it worked, and why it did not count
The report does not analyse a vulnerability in the target's code. The mechanism it relies on is that a victim browser can be made to connect to the attacker's server and then quickly switch to a local IP address, so requests reach internal services that are not exposed to the internet. Same-origin is the browser rule that a page may only read answers from the same site it came from; rebinding defeats it by making the attacker's name briefly point at the internal machine, so the browser believes both are the same place. The AWS metadata endpoint at [redacted] is reachable from the instance as though the request came from inside the internal network, which is what makes the technique valuable when the pingback originates from AWS. Authentication means proving who you are, usually with a password or key; here there is none to prove.
In this case the precondition that made the attack meaningful, namely that the AWS instance belonged to the program, did not hold. The pingback came from an analytics service that followed the Referer URL, so the rebinding succeeded technically but pointed at infrastructure outside the program's scope.
What the impact would have been
When the instance does belong to the target, the researcher's description of the technique is that an attacker can extract internal network information that normally blocks external IP addresses but not local ones, including the AWS metadata tree under /latest/meta-data. The attack requires the pingback source to execute JavaScript, and it requires the attacker to dedicate a VPS and stop its DNS service for the duration. Even a successful rebind may be out of scope for the program. In this instance the only result was a pingback from an analytics AWS instance, and no data belonging to the program was obtained.
How to defend against it
The report does not describe a fix applied by the program. The defensive direction implied by the technique is to prevent internal-only endpoints such as the instance metadata service from being reachable by browser-driven requests originating from untrusted hostnames, and to treat Referer-driven callbacks as untrusted input. The report does not state which of these, if any, was implemented.
Things worth trying
- JavaScript support probe. Serve
index.htmlwith<script src=//jstest.burpcollaborator.net></script>and send a request withReferer: http://yourserver.com/. A hit on the Collaborator subdomain means the pingback source executes JavaScript and rebinding is worth attempting. - Page-specific payload delivery. Where the pingback allows you to choose the path, try
/autoattack.htmlinstead ofindex.html. A positive result is the payload page being fetched rather than only the root. - Default AWS metadata extraction. Run Singularity in almost default mode against the AWS path and add output exfiltration inside
autoattack.html. Exfiltration means getting data out to a place you control. A positive result is metadata content arriving at your destination, though the report warns the response to the triggering request may be a 404 and the callback may only arrive days later. - ** A false positive is a result that looks like a finding but is not one.
- Alternative frameworks. The researcher lists
https://github.com/FSecureLABS/dref, which he got working a few years earlier but had issues with when trying it recently, possibly related to his VPS DNS and virtual host changes. A virtual host is a way for one server to answer for several domain names. A positive result is the same kind of rebind and callback described above.
Glossary
- 404: the standard web answer meaning the requested page was not found.
- Access log: the file where a web server records every request it receives.
- Analytics: a third-party service that measures traffic on a website, often by following links it sees.
- Authentication: proving who you are, usually with a password or key.
- AWS: Amazon Web Services, Amazon's cloud platform where customers rent computers.
- Bind / named: the standard DNS server software on Linux.
- Bug bounty program: a scheme where a company pays people for finding and reporting security problems in its systems.
- Burp: a widely used tool for inspecting and modifying web traffic.
- Burp Collaborator: a Burp feature that gives you a throwaway address and records any request sent to it.
- Burp Repeater: a Burp feature that lets you resend a request repeatedly, editing it each time.
- Caching: keeping a copy of an earlier answer so it can be served faster, at the risk of serving an old answer.
- Digital Ocean: a cloud provider whose DNS service he used to hold the records for his domain.
- DNS: the system that turns a domain name into the numeric address of a computer.
- DNS rebinding: tricking a browser into resolving an attacker-controlled name to an external address and then quickly to a local address, so requests reach internal services.
- Domain: the name people type to reach a site, like
example.com. - Exfiltration: getting data out of a system to a place you control.
- False positive: a result that looks like a finding but is not one.
- Freenom: a service that gave out free domain names, used here to register the attack domain.
- Headless web browser: a browser with no window on a screen, run by a program rather than a person.
- Header: a small labelled line of extra information that travels with a web request.
- HTTP pingback: a request made back to a server you control, telling you something happened.
- Index.html: the default page a web server hands out when you ask for a folder without naming a file.
- Internal network information: data held on machines that are not reachable from the open internet.
- IoT: internet-connected devices such as cameras and sensors.
- IP address: the numeric address of a computer on a network.
- JavaScript: the programming language web pages run inside the browser to make them interactive.
- Jenkins: a popular automation server often found inside company networks.
- Local IP address: an address that only means something inside a private network, such as
[redacted]. - Nameserver: the server that holds the DNS records for a domain.
- Out of scope: not covered by a bug bounty program's rewards.
- Ping: a command that checks whether another computer answers.
- PoC (proof of concept): a small demonstration that an attack works.
- Port: a numbered channel on a computer, so one machine can run several services at once.
- Port scanning: probing which channels on a machine are open.
- Referer header: the header that says which page a request came from.
- Researcher: here, someone hunting for security problems, often for a bug bounty program.
- Same-origin: the browser rule that a page may only read answers from the same site it came from.
- Server: a computer that answers requests from other computers.
- Singularity: NCC Group's ready-made toolkit for DNS rebinding attacks.
- VPS (virtual private server): a rented computer in a data centre that you control completely.
- Virtual host: a way for one server to answer for several domain names.
- Wget: a command-line tool for downloading files.