Skip to content
DoS Disclosed report Intermediate CVE-2024-41990

CVE-2024-41990: Potential denial-of-service in django.utils.html.urlize()

The urlize() and urlizetrunc() template filters in Django become exponentially slower when given very large inputs containing a specific sequence of characters. An attacker could cause a denial-of-service by submitting such a string via a POST request or storing it in the database for later processing.

mprogrammer Follow

Originally disclosed on HackerOne

Bounty$2,162 Medium View original
  • Triaged in 2 days
  • Fixed in 40 days
  • Paid in 40 days
  • Disclosed after 40 days

Summary by the program

###CVE-2024-41990: Potential denial-of-service in django.utils.html.urlize()

The urlize() and urlizetrunc() template filters are subject to a potential denial-of-service attack via very large inputs with a specific sequence of characters.

The report

I reported a slow pattern in urlize using repeated .; characters, which would become exponentially slower the larger the string. If a user string from a POST request was read by the function, or stored into the database to be read later by urlize, that's where the biggest problems happened.

This is the PoC that I used:

Python
import django.utils.html
from time import time

print('=== django.utils.html.urlize(".;" * n) ===')
for i in range(0,1000000, 40000):
    start = time()
    PAYLOAD = ".;" * i
    django.utils.html.urlize(PAYLOAD)
    print(len(PAYLOAD), "\t", time() - start)
=== django.utils.html.urlize(".;" * n) ===
80000     0.517104148864746
160000    1.91546583175659
240000    4.26700210571289
320000    7.51475358009338
400000    11.7720293998718
480000    16.8458595275879
560000    23.1542763710022
640000    39.5922138690949
720000    45.6281299591064
800000    59.8330779075623
880000    74.544540643692
960000    90.4768784046173
1040000   106.528100728989

Impact

Reduced performance or Denial of Service was possible if the urlize function was used without strict limits on a large user string.

The original report as published on HackerOne, by mprogrammer. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Django ships two template filters, urlize() and urlizetrunc(), that turn URLs and email addresses found in plain text into clickable HTML links. They are convenience filters: a template author passes a string of text and the filter scans it for things that look like links and wraps them in anchor tags. Because the input is often user-supplied content (a comment, a profile field, a message body), the filter runs on data an attacker can control.

The report covers CVE-2024-41990, a potential denial-of-service in django.utils.html.urlize(). It was filed on the Internet Bug Bounty programme against the Django project on GitHub, rated medium severity, with a bounty of 2162.00 USD, and disclosed on 2024-11-30. The weakness class recorded is allocation of resources without limits or throttling.

Setup

The researcher worked directly against the Python function django.utils.html.urlize() and timed it with the standard library time() function. The precondition is that the application passes a user-controlled string to urlize(), either directly from a POST request or after storing it and reading it back later.

Finding it

The researcher noticed a slow pattern in urlize triggered by repeated .; characters. The researcher reported that the pattern became exponentially slower the larger the string got. That non-linear growth is what made it interesting. A filter that is merely slow on huge inputs is a nuisance; a filter whose cost explodes as input grows is a denial-of-service primitive, because a modest increase in input size buys a large increase in server time.

The researcher also identified where the problem bites hardest: if a user string from a POST request was read by the function, or stored into the database to be read later by urlize, that is where the biggest problems happened. The report says that is where the biggest problems happened.

Exploitation

Step 1: build a timing harness

The researcher wrote a small script that calls urlize on payloads of increasing size and prints the elapsed time for each. The payload is the two-character sequence .; repeated i times, with i stepping from 0 to 1000000 in increments of 40000.

Python
import django.utils.html
from time import time

print('=== django.utils.html.urlize(".;" * n) ===')
for i in range(0,1000000, 40000):
    start = time()
    PAYLOAD = ".;" * i
    django.utils.html.urlize(PAYLOAD)
    print(len(PAYLOAD), "\t", time() - start)

The loop variable i is the repeat count, so the actual string length is twice i. The script records time() before the call, runs urlize on the payload, and prints the payload length alongside the elapsed time. Nothing else is measured, so the numbers reflect the cost of the filter itself.

Step 2: observe the growth

The output shows the elapsed time climbing far faster than the input length:

=== django.utils.html.urlize(".;" * n) ===
80000     0.517104148864746
160000    1.91546583175659
240000    4.26700210571289
320000    7.51475358009338
400000    11.7720293998718
480000    16.8458595275879
560000    23.1542763710022
640000    39.5922138690949
720000    45.6281299591064
800000    59.8330779075623
880000    74.544540643692
960000    90.4768784046173
1040000   106.528100728989

Reading the table from top to bottom: doubling the input from 80000 to 160000 characters takes the time from about 0.52 seconds to about 1.92 seconds, roughly a factor of four. Going from 80000 to 320000 characters, a factor of four in length, takes the time to about 7.51 seconds, roughly a factor of fourteen. By 1040000 characters the call takes about 106.5 seconds. The researcher describes the pattern as exponentially slower the larger the string. At 1040000 characters the call took about 106.5 seconds.

Root cause

The report attributes the behaviour to the specific sequence of characters .; repeated many times, which became exponentially slower the larger the string. The report does not include the internal code path or name the function inside urlize responsible for the blow-up, so the precise mechanism is not stated. What is clear is that the filter has no limit on the amount of work it will do for a given input, which matches the recorded weakness: allocation of resources without limits or throttling.

Impact

Reduced performance or denial of service was possible if the urlize function was used without strict limits on a large user string. The exposure depends entirely on how the application uses the filter. Where a user string from a POST request is read by urlize, the report says that is where the biggest problems happened. Where the string is stored in the database and read later by urlize, the report says that is where the biggest problems happened. The report frames this as reduced performance or denial of service.

Fix

The report does not describe the patch. The summary states the vulnerability and its trigger, but not what changed in Django to address it. What the report makes clear is the condition under which the problem exists: urlize used without strict limits on a large user string.

Variants to test

  1. Try other short repeating character sequences through urlize and urlizetrunc, not just .;. A positive result is elapsed time growing faster than the input length, measured the same way as the harness above.
  2. A positive result is the same superlinear timing curve.
  3. Submit the payload through a POST field that is rendered with urlize and time the response. A positive result is response time rising sharply with payload size while other fields stay constant.
  4. Store the payload and request the page that renders it. A positive result is a consistently slow render for that record, repeated on every request, which turns a single submission into a persistent cost.
  5. Compare timings across input sizes to confirm the curve rather than a single slow sample. A positive result is a clean superlinear trend, as in the table above, rather than noise.

Hunting notes

This kind of bug hides wherever a text-processing helper runs on attacker-controlled input without a size cap: template filters, markdown and linkifiers, autolinkers, syntax highlighters, and any function that scans a string for patterns. During recon, the signals are features that accept free-form text and display it with automatic link detection, comment systems, profile bios, message boards, and anything that stores user text and renders it later. The most valuable case is stored input, because one submission then costs the application on every render.

The harness sweeps input sizes and prints a table. The harness sweeps input sizes and prints a table, which makes the superlinear growth visible and separates a genuine algorithmic problem from ordinary slowness. That evidence, tied to a concrete trigger sequence and a realistic path from user input to the filter, is what supports the denial-of-service claim.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 9 min read.

What happened, in plain words

Django is a popular toolkit for building websites in Python. It includes two helpers, urlize() and urlizetrunc(), that look through a piece of plain text and turn anything that looks like a web address or an email address into a clickable link. Website builders use these helpers so that when a visitor writes a comment containing https://example.com, the comment shows a real link instead of raw text.

The problem appears when urlize is used without strict limits on a large user string. If someone sends a specially crafted string of characters, the helper slows down dramatically. The longer the string, the worse it gets, and the slowdown is not gradual: it grows much faster than the string itself. At 1040000 characters the call took about 106.5 seconds. If a website passes user input to this helper without strict limits, reduced performance or denial of service was possible. That is a denial-of-service attack: the attacker does not steal data or break in, they just make the service too slow to use.

The report was filed on the Internet Bug Bounty programme against the Django project on GitHub. It was rated medium severity, a bounty of 2162.00 USD was paid, and it was disclosed on 2024-11-30. The weakness is classified as allocation of resources without limits or throttling, which means the software uses up time or memory without any cap.

Context

Django ships two template filters, urlize() and urlizetrunc(), that turn URLs and email addresses found in plain text into clickable HTML links. A template filter is a small function you can use inside a web page template to transform some text before it is shown. These two are convenience filters: a template author passes a string of text and the filter scans it for things that look like links and wraps them in anchor tags. Anchor tags are the HTML element that makes a link clickable. Because the input is often user-supplied content (a comment, a profile field, a message body), the filter runs on data an attacker can control.

The report covers CVE-2024-41990, a potential denial-of-service in django.utils.html.urlize(). A CVE is a public identifier for a known security flaw, so people can look it up and track fixes. It was filed on the Internet Bug Bounty programme against the Django project on GitHub, rated medium severity, with a bounty of 2162.00 USD, and disclosed on 2024-11-30. The weakness class recorded is allocation of resources without limits or throttling.

Setup

The researcher worked directly against the Python function django.utils.html.urlize() and timed it with the standard library time() function. The precondition is that the application passes a user-controlled string to urlize(), either directly from a POST request or after storing it and reading it back later.

Finding it

The researcher noticed a slow pattern in urlize triggered by repeated .; characters. The researcher reported that the pattern became exponentially slower the larger the string got. Linear growth would mean that doubling the input doubles the time; exponential growth means that each extra bit of input multiplies the time. That non-linear growth is what made it interesting. A filter that is merely slow on huge inputs is a nuisance; a filter whose cost explodes as input grows is a denial-of-service primitive, because a modest increase in input size buys a large increase in server time.

The researcher also identified where the problem bites hardest: if a user string from a POST request was read by the function, or stored into the database to be read later by urlize, that is where the biggest problems happened. A POST request is the way a browser sends data to a server, for example when you submit a form. The report says that is where the biggest problems happened.

Exploitation

Step 1: build a timing harness

The researcher wrote a small script that calls urlize on payloads of increasing size and prints the elapsed time for each. The payload is the two-character sequence .; repeated i times, with i stepping from 0 to 1000000 in increments of 40000.

Python
import django.utils.html
from time import time

print('=== django.utils.html.urlize(".;" * n) ===')
for i in range(0,1000000, 40000):
    start = time()
    PAYLOAD = ".;" * i
    django.utils.html.urlize(PAYLOAD)
    print(len(PAYLOAD), "\t", time() - start)

Line by line:

  • import django.utils.html loads the part of Django that contains the urlize function, so the script can call it.
  • from time import time brings in a function that returns the current time in seconds, used to measure how long a call takes.
  • print('=== django.utils.html.urlize(".;" * n) ===') prints a heading so the output is easy to read.
  • for i in range(0,1000000, 40000): starts a loop where i takes values 0, 40000, 80000, and so on up to just below 1000000. Each value is the number of times the two-character sequence will be repeated.
  • start = time() records the time just before the call.
  • PAYLOAD = ".;" * i builds the test string by repeating the two characters .; exactly i times. So the string length is twice i.
  • django.utils.html.urlize(PAYLOAD) calls the filter on that string. This is the operation being measured.
  • print(len(PAYLOAD), "\t", time() - start) prints the length of the string, a tab character, and the number of seconds that passed during the call.

The loop variable i is the repeat count, so the actual string length is twice i. The script records time() before the call, runs urlize on the payload, and prints the payload length alongside the elapsed time. Nothing else is measured, so the numbers reflect the cost of the filter itself.

Step 2: observe the growth

The output shows the elapsed time climbing far faster than the input length:

=== django.utils.html.urlize(".;" * n) ===
80000     0.517104148864746
160000    1.91546583175659
240000    4.26700210571289
320000    7.51475358009338
400000    11.7720293998718
480000    16.8458595275879
560000    23.1542763710022
640000    39.5922138690949
720000    45.6281299591064
800000    59.8330779075623
880000    74.544540643692
960000    90.4768784046173
1040000   106.528100728989

Reading the table from top to bottom: doubling the input from 80000 to 160000 characters takes the time from about 0.52 seconds to about 1.92 seconds, roughly a factor of four. Going from 80000 to 320000 characters, a factor of four in length, takes the time to about 7.51 seconds, roughly a factor of fourteen. By 1040000 characters the call takes about 106.5 seconds. The researcher describes the pattern as exponentially slower the larger the string.

Root cause

The report attributes the behaviour to the specific sequence of characters .; repeated many times, which became exponentially slower the larger the string. The report does not include the internal code path or name the function inside urlize responsible for the blow-up, so the precise mechanism is not stated. What is clear is that the filter has no limit on the amount of work it will do for a given input, which matches the recorded weakness: allocation of resources without limits or throttling.

Impact

Reduced performance or denial of service was possible if the urlize function was used without strict limits on a large user string. The exposure depends entirely on how the application uses the filter. Where a user string from a POST request is read by urlize, the report says that is where the biggest problems happened. Where the string is stored in the database and read later by urlize, the report says that is where the biggest problems happened. The report frames this as reduced performance or denial of service.

Fix

The report does not describe the patch. The summary states the vulnerability and its trigger, but not what changed in Django to address it. What the report makes clear is the condition under which the problem exists: urlize used without strict limits on a large user string.

Variants to test

  1. Try other short repeating character sequences through urlize and urlizetrunc, not just .;. A positive result is elapsed time growing faster than the input length, measured the same way as the harness above.
  2. A positive result is the same superlinear timing curve.
  3. Submit the payload through a POST field that is rendered with urlize and time the response. A positive result is response time rising sharply with payload size while other fields stay constant.
  4. Store the payload and request the page that renders it. A positive result is a consistently slow render for that record, repeated on every request, which turns a single submission into a persistent cost.
  5. Compare timings across input sizes to confirm the curve rather than a single slow sample. A positive result is a clean superlinear trend, as in the table above, rather than noise.

Hunting notes

This kind of bug hides wherever a text-processing helper runs on attacker-controlled input without a size cap: template filters, markdown and linkifiers, autolinkers, syntax highlighters, and any function that scans a string for patterns. During recon, the signals are features that accept free-form text and display it with automatic link detection, comment systems, profile bios, message boards, and anything that stores user text and renders it later. The most valuable case is stored input, because one submission then costs the application on every render.

The harness sweeps input sizes and prints a table. The harness sweeps input sizes and prints a table, which makes the superlinear growth visible and separates a genuine algorithmic problem from ordinary slowness. That evidence, tied to a concrete trigger sequence and a realistic path from user input to the filter, is what supports the denial-of-service claim.

Glossary

  • Django: a free, open-source web framework written in Python that helps developers build websites quickly.
  • Template filter: a small function used inside a web page template to transform text before it is displayed.
  • urlize(): a Django template filter that finds URLs and email addresses in plain text and turns them into clickable HTML links.
  • urlizetrunc(): a similar Django template filter that also shortens long URLs when making them clickable.
  • HTML anchor tag: the HTML element <a> that makes text clickable as a link.
  • CVE: a public identifier for a known security vulnerability, so people can track and fix it.
  • Denial-of-service (DoS): an attack that makes a service unavailable or unusably slow, often by exhausting its resources.
  • Allocation of resources without limits or throttling: a weakness where software uses time, memory, or other resources without any cap, allowing an attacker to exhaust them.
  • POST request: an HTTP request that sends data to a server, typically from a form submission.
  • Payload: the specially crafted input an attacker sends to trigger a vulnerability.
  • Superlinear growth: when the time or resources needed grow faster than the size of the input; doubling the input more than doubles the cost.
  • Exponential growth: a specific kind of superlinear growth where each increase in input multiplies the cost by a constant factor.
  • Timing harness: a script that measures how long a function takes to run on different inputs, to reveal performance problems.
  • time() function: a Python function that returns the current time in seconds, used to measure elapsed time.
  • Template: a file that defines the structure of a web page, often with placeholders that are filled in with data.
  • Recon: short for reconnaissance, the phase of security testing where you look for potential targets and entry points.

More by mprogrammer

View all

3 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.