Securing a file upload endpoint
While a file upload endpoint may not be the first choice of places to hit with a DDOS attack, that doesn't mean that security concerns should go out the window. As you mention in comments, requiring user access doesn't help much: PHP will accept the upload regardless and store it in a temporary location. It will get immediately deleted when you don't do anything with the upload, but it will still get written to disk temporarily.
Your other suggestion of setting the /tmp
directory size large enough that you can't run out of free space (as determined by your available bandwidth) will certainly make sure your hard-drive won't fill up (although overflowing a /tmp directory wouldn't necessarily kill a server, especially if it is on its own partition). That then shows the next weak point in your chain - if all your bandwidth is being used up in an attempt to overwhelm a file upload endpoint, then your service is going to be down regardless of whether or not your machine has space on its hard-drive (because your network bandwidth is all used up). Which pretty much answers your question because at that point in time a DDOS via file upload is no longer possible. If your file upload endpoint can't be DDOS'd except by completely overwhelming your network bandwidth, then no one will bother trying to DDOS your file upload endpoint: they'll just aim enough traffic at you to try to overwhelm your network connection. At that point in time, I'd say that your file upload is secure!
I'm not sure how much it would cost to purchase that much hard-drive space. It would depend on your hosting provider (although hard-drive space is usually cheap) and your available bandwidth. That being said, there is also a pretty simple solution to protect such a system: put your file upload system on a separate server on a separate network, (uploads.example.com
) and make sure all your systems have some DDOS protection (i.e. cloudflare). Then a DDOS against your file upload endpoint can take it down, but the rest of your systems would continue on their merry way. Of course in that case, I can't imagine someone would try to DDOS your file upload. They would just try to find a more appealing attack vector that impacts your main systems.