Skip to content
Business logic Write-up Beginner

Implementing Django Rest Api Throttling And Unauthenticated Bypass

The Django REST Framework throttling identifies clients by the X-Forwarded-For header, so an unauthenticated attacker can bypass the rate limit by changing that header with each request. This allows unlimited requests to the API.

hosein vita Follow

Published on infosecwriteups.com

In this write-up, we are going to walk through implementing a Django-Rest project with Throttling and try to bypass this feature. If you have not worked with Django before or don’t have any idea about it, don’t worry we are going to explain it step by step so we have a clear understanding of what is going on.

hosein vita, on infosecwriteups.com

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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the throttling implementation trusts the client-supplied X-Forwarded-For header to identify the client, without validating it against a trusted proxy.

Impact

An unauthenticated attacker could bypass the rate limit and make unlimited requests to the API, which could enable brute-force attacks or denial of service.

What the attacker needed

Django REST Framework with throttling enabled; Ability to set X-Forwarded-For header

The fix

The throttling should not trust the X-Forwarded-For header unless it comes from a trusted proxy, or it should use a more reliable client identifier.

How it was found

  1. Set up a Django REST API with throttling enabled (anon rate 50/day).
  2. Send more than 50 requests as an unauthenticated user and observe a 429 response.
  3. Add an X-Forwarded-For header with a different IP address to the request.
  4. Observe that the request is no longer blocked.
  5. Change the X-Forwarded-For value after every 50 requests to maintain unlimited access.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Rate limiting is a way to stop someone from making too many requests to a website in a short time. This report shows that the rate limiter trusted a header called X-Forwarded-For, which the client can set to any value, so the attacker could pretend to be a new client each time and never get blocked.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by hosein vita

View all

2 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.