I posted this to the security team at cPanel some months back and without luck they told me this is not a security issue but how their DNS and API works.
So I will decide to make it public based on the consideration that other users can or should test it in their own setup and decide if indeed this is not a security hole but a feature I requested.
The issue allows for a provider that provides DNS management to customers via their API and runs a cPanel DNS cluster for their users to hijack domains, put them off line or redirect all traffic. This means you can change the IP, records and zones for any domain that is in the hosting company. Quite a HUGE security hole if you ask me, but then again im not here to decide that.
When a users adds a domain or addon via his cPanel interface, or a reseller does via WHM, cPanel adds the correct DNS zones as well. This in the local server and as well in the DNS cluster. If the domain exists as a DNS record it will fail, from WHM you should be able to see all zones from all servers in the cluster. You can´t of course edit or delete zones which you don´t belong to your user from cPanel or WHM. This checks seems pretty basic and are in the GUI itself but works. You should not be able to add accounts that exists, and cPanel tells you so that DNS records exists. This is fine and it works.
But what happens when you use the cPanel DNS API calls? Well here comes the issue. API calls runs as root which and for DNS records it allows to do functions like add, edit, delete, etc.
If you send an add API call to the sever and the domains exists in the local server where you are sending the API call it will fail, telling you similar to the GUI that it exists already. But if the domain or DNS record exists in another cPanel server, which is normal in a clustered setup, again assume you have a cPanel DNS cluster, it will pass. Don´t be confused here with the domain existing, you could have just fine only DNS records without hosting the account on cPanel. So this applies to his case as well. If the DNS zone exists for a domain in server a even without being hosted it will securely inform with a failure, not so in the cluster.
This means if "example.com" is hosted in Server A or DNS zones for "example.com" exists and we are sending API calls always to server A, the API will correctly deny it as the domain/zones exist.
But if you send the same api call to add example2.com, again to Server A, and example2.com exists in another cPanel server it will pass because Server A only checks its local domains, not the DNS records on the whole cluster. You will not overwrite the zones for that domain.
So now you have taking control on example2.com which does not belong to you, you can change it records and even deleted it.
The same applies to the delete API call. Here you first send the API call to add example2.com, then its yours and you can deleted it.
You can actually send a delete call for all domains hosted by the hosting company and take each down, if the company happens to host their zones in their cPanel DNS cluster, that customer will now also be able to take control over the company infrastructure completely. How? Lets assume cPanel.net provides me the hosting for the DNS services, and they use a cPanel DNS cluster. I purchase their DNS services and then I can add my domain from the control panel the company provides me which just runs the API calls in the background. I would then just add cpanel.net to my account and it will overwrite the zones that existed already. Now I control the zones.
The API calls regarding the DNS fails completely to check zones in the cluster, only locally. So now you can hijack, delete, erase, or update zones of ALL domains in the cluster.
If you are a hosting provider and are providing DNS services to your customers, using the cPanel API, I assume your DNS servers are at least 2, which is clustered already. I assume a provider does not just 1 local DNS server which does not give redundancy. Most providers have 2 separated DNS servers in separate server or network and I assume most providers using cPanel for DNS have the clustering enabling.
So if you give customers access to manage this DNS zones, or give DNS services, outside cPanel or WHM you are probably using the API and in this case I advice you immediately to check this issue since your customers can hijack and use zones that do not belong to them as there is absolutely no pre check done by the API. Unless you do some other checks. I tested this failure in at least one popular billing systems that has cPanel DNS features advertised and it works just fine.
The correct procedure is for the API to fail if the zones for that domain exists already, not overwrite them. This means that if the API call would fail if the records exists, it could potentially avoid this issue. The API fails to realize the domain exists in another server in the cluster and so this issue.
So I will decide to make it public based on the consideration that other users can or should test it in their own setup and decide if indeed this is not a security hole but a feature I requested.
The issue allows for a provider that provides DNS management to customers via their API and runs a cPanel DNS cluster for their users to hijack domains, put them off line or redirect all traffic. This means you can change the IP, records and zones for any domain that is in the hosting company. Quite a HUGE security hole if you ask me, but then again im not here to decide that.
When a users adds a domain or addon via his cPanel interface, or a reseller does via WHM, cPanel adds the correct DNS zones as well. This in the local server and as well in the DNS cluster. If the domain exists as a DNS record it will fail, from WHM you should be able to see all zones from all servers in the cluster. You can´t of course edit or delete zones which you don´t belong to your user from cPanel or WHM. This checks seems pretty basic and are in the GUI itself but works. You should not be able to add accounts that exists, and cPanel tells you so that DNS records exists. This is fine and it works.
But what happens when you use the cPanel DNS API calls? Well here comes the issue. API calls runs as root which and for DNS records it allows to do functions like add, edit, delete, etc.
If you send an add API call to the sever and the domains exists in the local server where you are sending the API call it will fail, telling you similar to the GUI that it exists already. But if the domain or DNS record exists in another cPanel server, which is normal in a clustered setup, again assume you have a cPanel DNS cluster, it will pass. Don´t be confused here with the domain existing, you could have just fine only DNS records without hosting the account on cPanel. So this applies to his case as well. If the DNS zone exists for a domain in server a even without being hosted it will securely inform with a failure, not so in the cluster.
This means if "example.com" is hosted in Server A or DNS zones for "example.com" exists and we are sending API calls always to server A, the API will correctly deny it as the domain/zones exist.
But if you send the same api call to add example2.com, again to Server A, and example2.com exists in another cPanel server it will pass because Server A only checks its local domains, not the DNS records on the whole cluster. You will not overwrite the zones for that domain.
So now you have taking control on example2.com which does not belong to you, you can change it records and even deleted it.
The same applies to the delete API call. Here you first send the API call to add example2.com, then its yours and you can deleted it.
You can actually send a delete call for all domains hosted by the hosting company and take each down, if the company happens to host their zones in their cPanel DNS cluster, that customer will now also be able to take control over the company infrastructure completely. How? Lets assume cPanel.net provides me the hosting for the DNS services, and they use a cPanel DNS cluster. I purchase their DNS services and then I can add my domain from the control panel the company provides me which just runs the API calls in the background. I would then just add cpanel.net to my account and it will overwrite the zones that existed already. Now I control the zones.
The API calls regarding the DNS fails completely to check zones in the cluster, only locally. So now you can hijack, delete, erase, or update zones of ALL domains in the cluster.
If you are a hosting provider and are providing DNS services to your customers, using the cPanel API, I assume your DNS servers are at least 2, which is clustered already. I assume a provider does not just 1 local DNS server which does not give redundancy. Most providers have 2 separated DNS servers in separate server or network and I assume most providers using cPanel for DNS have the clustering enabling.
So if you give customers access to manage this DNS zones, or give DNS services, outside cPanel or WHM you are probably using the API and in this case I advice you immediately to check this issue since your customers can hijack and use zones that do not belong to them as there is absolutely no pre check done by the API. Unless you do some other checks. I tested this failure in at least one popular billing systems that has cPanel DNS features advertised and it works just fine.
The correct procedure is for the API to fail if the zones for that domain exists already, not overwrite them. This means that if the API call would fail if the records exists, it could potentially avoid this issue. The API fails to realize the domain exists in another server in the cluster and so this issue.