Download Quota - Flaw discovered (and fixed)

Information and news about the website will be posted here.
Post Reply
Andy
User avatar
Administrator
Posts: 12801
Joined: Fri Aug 18, 2006 11:47 am
Location: United Kingdom
Contact:

Download Quota - Flaw discovered (and fixed)

Post by Andy »

Hello everyone.

Recently I discovered a very fatal flaw in the download quota system that required me to take immediate action.

This flaw was a design flaw from the very beginning, and was overlooked throughout all testing. It only recently came to light because of some users massively going over their quota. Thanks to our logging system, we noticed this and were able to analyse how it was happening.

So what was the flaw?

Put simply, the rolling quota system was doomed from day 1. If you downloaded a 50GB file, you use 50GB of quota with an expiry time of 24 hours. That worked fine because quota was 24 hour rolling.

But consider a situation where you download two 25GB files instead. That would have a quota expiry time of 12 hours. Now say you download them both right now, in parallel. You'll use your 50GB quota, but BOTH files quota will get returned in just 12 hours from now. That means that you would then be able to get another 50GB of quota after just 12 hours!

This problem gets worse the smaller the file you download. You could download 50x1GB files and after 28 minutes all of the files had their quota returned and you could download another 50GB of files!

You can see why this was such a serious flaw and how under typical use and testing it would never have been noticed.

So what was the fix and how does it work now?

The fix was to recode the entire authentication and quota script, which is what I have spent the majority of today doing.

The quota system is now set up so that you regain about 2.083GB of quota per hour. So it's still sort of rolling, but not second by second. This should still allow you to download new files regularly once your used quota drops below 50GB.

The "quota expiry" column is now gone because it served no purpose anymore.

Please report any issues

As I have essentially re-written this in just a few hours, please do report any bugs to me. That includes all unexpected 401's, 404's, etc. that you encounter.

I have improved the logging capability of the authentication system to help me further identify problems more easily.

Thanks

Andy

SigmaTel71
User avatar
Posts: 5
Joined: Wed Jul 29, 2020 8:38 pm
Location: Russia
Contact:

Re: Download Quota - Flaw discovered (and fixed)

Post by SigmaTel71 »

If I download a file that is less than maximum quota per hour, will it reserve the entire hour 'capacity' or I'll regain my 1.25 GB (for example) quota back earlier?

Andy
User avatar
Administrator
Posts: 12801
Joined: Fri Aug 18, 2006 11:47 am
Location: United Kingdom
Contact:

Re: Download Quota - Flaw discovered (and fixed)

Post by Andy »

You'll only use whatever the size of the file is. You'll get 2.083GB back every hour on the hour.

Essentially nothing has changed other than the quota actually works as intended now and you get quota back hourly.

Resident007
User avatar
Posts: 206
Joined: Mon Nov 04, 2013 7:05 pm
Location: /dev/null

Re: Download Quota - Flaw discovered (and fixed)

Post by Resident007 »

For whatever reason, I am now getting division by zero error when opening "My downloads" tab in the Database:
Image
Image

PlyrStar93
User avatar
Posts: 324
Joined: Mon Jan 23, 2012 2:48 pm
Location: guess it

Re: Download Quota - Flaw discovered (and fixed)

Post by PlyrStar93 »

Resident007 wrote:
Sun Aug 27, 2023 7:30 pm
For whatever reason, I am now getting division by zero error when opening "My downloads" tab in the Database:
Image
Same
Basically the page doesn't work even if I have generated a download and then go back to My Downloads.
Image

Andy
User avatar
Administrator
Posts: 12801
Joined: Fri Aug 18, 2006 11:47 am
Location: United Kingdom
Contact:

Re: Download Quota - Flaw discovered (and fixed)

Post by Andy »

Fixed. Please try now.

PlyrStar93
User avatar
Posts: 324
Joined: Mon Jan 23, 2012 2:48 pm
Location: guess it

Re: Download Quota - Flaw discovered (and fixed)

Post by PlyrStar93 »

Can confirm it's fixed, thank you Andy.

Resident007
User avatar
Posts: 206
Joined: Mon Nov 04, 2013 7:05 pm
Location: /dev/null

Re: Download Quota - Flaw discovered (and fixed)

Post by Resident007 »

Yes, it's fixed, thanks.
Image

gamer765
Posts: 90
Joined: Sat Jun 16, 2007 1:05 am

Re: Download Quota - Flaw discovered (and fixed)

Post by gamer765 »

Users caught actively abusing the bug should've been given a warning/temp ban

Andy
User avatar
Administrator
Posts: 12801
Joined: Fri Aug 18, 2006 11:47 am
Location: United Kingdom
Contact:

Re: Download Quota - Flaw discovered (and fixed)

Post by Andy »

I don't think it's fair to give people a warning for a bug that has existed since day 1 and was never caught. They could have been unknowingly exploiting it too if they queued up files and may not have realised. Even if they did, I bet most people wouldn't say anything if they were getting more than they were meant to.

In any case, it's fixed now.

Post Reply