The Message That Ate the CPU: Finding a Quadratic-Time DoS in Markdown Parsing
A crafted Markdown message with repeated incomplete link syntax caused quadratic-time parsing on the server, leading to CPU exhaustion. An authenticated attacker could send such a message to degrade server performance for other users.
Bug Bounty
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.
Context
The target was an application the author calls Collab-app, a chat platform that processes Markdown on the server. A normal chat message is just a string of characters: no attachments, no images, no complicated formatting. The server parses that string as Markdown, and the same parsing is used for several post-processing features.
The author describes the outcome plainly: you send a message, press Enter, and then you wait. Five seconds, ten, twenty, with no response, while one of the server's CPU cores sits at 100% doing nothing but processing that message. The whole problem came down to an inefficient Markdown parsing algorithm and a surprisingly simple input pattern:
](a](a](a](a](a](a](a](a...
This was the author's first write-up, published under the handle elze1n.
Setup
The report describes a single authenticated API endpoint used for both messages, and two payloads of roughly the same size. No accounts, roles, tool versions or other preconditions are described beyond the fact that the requests were authenticated.
The endpoint was:
POST /api/v4/posts
The two messages were generated as follows. The control message is plain text:
message = "a" * 65536
The crafted message repeats the three-character sequence ](a:
message = "] (a" * 21845
Both messages contain approximately 64 KB of text. The point of the pairing is that the two inputs are the same size, so any difference in server-side cost comes from the structure of the input rather than its length.
Finding it
Because the platform processes Markdown on the server, the author wanted to understand whether malformed Markdown could trigger expensive parsing operations. The hypothesis was tested by sending the control message and the crafted message through the same authenticated endpoint and comparing what happened.
The results were immediately interesting: the crafted input was triggering significantly more server-side processing. The most interesting part was that increasing the input size produced a disproportionate increase in execution time, which is the signature of superlinear work rather than a constant per-byte cost.


Exploitation
Step 1: Establish a baseline with plain text
Send a 64 KB message consisting only of the character a through the authenticated endpoint:
message = "a" * 65536
POST /api/v4/posts
This is the control. It measures what a message of this size costs the server when there is no Markdown structure to parse.
Step 2: Send the crafted Markdown pattern
Send a message of approximately the same size built from repeated ](a sequences:
message = "] (a" * 21845
POST /api/v4/posts
The three characters matter individually. ] is the character the parser looks for when deciding whether a link construct has ended. ( immediately after it is what makes the parser treat the sequence as the start of a link destination. a is filler that keeps the message a valid, ordinary-looking string.
Step 3: Compare and scale
The crafted input triggered significantly more server-side processing than the control of the same size. Increasing the input size then produced a disproportionate increase in execution time, confirming that the cost grows faster than the input.
Root cause
A standard Markdown link looks like this:
[link text](destination)[Click here](https:
When the parser encounters ], it checks whether the next character is (, and if so it attempts to parse the destination. An incomplete link such as:
](some-destination
has no closing ). That is where the problem starts. When the destination parser cannot find a closing parenthesis, it does not stop after a reasonable search window; it continues scanning toward the end of the input. Repeated thousands of times, each ]( sequence triggers another attempt to parse a link destination, and each attempt scans almost the whole remaining input.
Conceptually the work looks like this:
First opener: scan almost N charactersSecond opener: scan almost N charactersThird opener: scan almost N characters...Last opener: scan a few characters
The total amount of work resembles:
N + (N-1) + (N-2) + (⋯) + 1
That sum is quadratic in N, which is why the crafted input costs far more than plain text of the same length.
The report does not describe any input length limit, parser timeout or other defence that stopped the pattern.
Impact
The immediate effect is server-side CPU exhaustion: one core at 100% for the duration of the parse, with the request hanging for seconds or longer. The author's framing is a server-side denial of service reachable through a normal chat operation.
The part the author found most interesting is that the cost does not stop when the message is sent. Tracing the application showed that Markdown inspection happens in multiple places. During post creation, the relevant processing includes:
getFirstLinkinpost_metadata.gogetImagesinpost_metadata.gogetExplicitMentionsinnotification.go
These operations invoke Markdown inspection. The post is also processed again when preparing it for clients:
PreparePostForClientWithEmbedsAndImages
As the author puts it: the attacker pays the cost once to publish the message, and other users can pay that cost again when retrieving it. A single stored message can therefore cost again when other users retrieve it.

The report notes that the issue was marked as a duplicate.
Fix
The report does not state what was changed. The defect it describes is a destination parser that scans to the end of the input for every unmatched ](, so the fix implied by the analysis is to bound that scan: stop the destination search after a reasonable window instead of continuing to the end of the message, which turns the per-opener cost into a constant and the total into linear time. Whether that, an input length limit, or something else was applied is not said.
Variants to test
- Other Markdown constructs with an opener and a terminator. Send repeated unmatched openers for images, emphasis, code spans, autolinks or HTML tags, for example long runs of
.
The author found that a message made of a very specific, very short repeating pattern could make the server work enormously hard. The message looked ordinary in size, about 64 KB, which is roughly the length of a short article. But instead of being handled quickly, it kept one of the server's processors (a CPU core) busy at 100% for a long time. From the user's side it looked like this: you press Enter, and then you wait. Five seconds. Ten. Twenty. No response.
The whole problem came down to an inefficient Markdown parsing algorithm and a surprisingly simple input pattern:
](a](a](a](a](a](a](a](a...
That is just three characters, ], ( and a, repeated over and over. The rest of this article explains, from scratch, what the author did, why each step was taken, and why three characters can bring a server to its knees.
This was the author's first write-up, published under the handle elze1n.

Background you need first
Before the steps make sense, here are the basic ideas, explained as if you have never read a security report before.
What an API is. A website has two sides. The part you see in the browser (buttons, text boxes, the message list) is the front end. The part that stores data and does the real work is the back end, running on a server, which is just a computer in a data centre. An API is the doorway the front end uses to talk to the back end. When you send a chat message, your browser does not write it straight into a database; it sends a request to an API, and the API does the work. Think of a restaurant: the menu and the waiter are the front end, the kitchen is the back end, and the little window where orders are passed through is the API.
What a request looks like. An API request has a method (what kind of action), a path (which doorway), and usually some data. POST means "create something new". So POST /api/v4/posts means "create a new post", and a post here is a chat message.
What authenticated means. Most APIs will not accept a request from just anyone. You have to prove who you are, usually by logging in once and then carrying a pass (a session cookie or a token) with every later request. Think of a wristband at an event: you show your ticket once at the door, get the wristband, and after that the staff just glance at your wrist. An authenticated request is one that carries a valid wristband. The author's requests were authenticated, meaning they were sent as a logged-in user through the normal doorway, not through some hidden back entrance.
What Markdown is. Markdown is a way of writing formatted text using ordinary characters. For example, wrapping a word in asterisks makes it bold, and writing square brackets followed by round brackets makes a clickable link. The app reads the raw characters and turns them into formatted output. That reading step is the parser.
What a parser is. A parser is a program that reads text and works out its structure. Reading [Click here](https://example.com) and deciding "this is a link, the visible text is 'Click here', the destination is the address" is parsing. Parsers have to look ahead: to know whether something is a link, they may need to scan forward for the closing bracket.
What a denial of service is. A denial-of-service (DoS) attack does not steal data or break in. It makes a service unusable, usually by making it do far more work than it can handle, so that real users cannot get answers. If a shop assistant is buried under a mountain of pointless paperwork, real customers wait forever. A server-side DoS means the overload happens on the server, not in the attacker's browser.
What CPU and CPU cores are. The CPU is the part of a computer that actually executes instructions. A modern server has several CPU cores, each able to work on something at the same time. If one core is pinned at 100%, that core is fully occupied. If enough cores are pinned, the server cannot serve anyone.
What quadratic time means. This is the heart of the report, so here is the everyday version. Suppose you have a pile of letters and for each letter you must check every other letter. With 10 letters that is about 100 checks. With 100 letters it is about 10,000 checks. Double the pile and the work roughly quadruples. That is called quadratic, or O(n²), growth. Compare it with linear work, where double the input means double the work. Quadratic work is fine for tiny inputs and disastrous for large ones. The author's finding is that a particular input makes the Markdown parser do quadratic work.
The setup: two messages of the same size
The author used a single authenticated API endpoint for both messages, and two payloads of roughly the same size. A payload is simply the data you send in a request. The report does not describe any accounts, roles, tool versions or other preconditions beyond the fact that the requests were authenticated.
The endpoint was:
POST /api/v4/posts
Line by line: POST is the method, meaning "create something". /api/v4/posts is the path, the doorway for creating posts. v4 is just a version number in the address. Nothing here is unusual; this is the same doorway the app's own front end uses when you send a chat message.
The two messages were generated as follows. The control message is plain text:
message = "a" * 65536
Line by line: message is the name of the variable, a labelled box that holds the text. "a" is a single letter a. * 65536 means "repeat that 65,536 times". So the box ends up holding a string of 65,536 letter a's, which is 64 KB of text. This is the control: a message of the target size with no Markdown structure at all.
The crafted message repeats the three-character sequence ](a:
message = "] (a" * 21845
Line by line: "] (a" is the three-character sequence, a closing square bracket, an opening round bracket and the letter a. * 21845 repeats it 21,845 times. That gives roughly 65,535 characters, so approximately the same 64 KB as the control. The point of the pairing is that the two inputs are the same size, so any difference in server-side cost comes from the structure of the input rather than its length. If the crafted message were simply bigger, a slower response would prove nothing.
Finding it
Because the platform processes Markdown on the server, the author wanted to understand whether malformed Markdown could trigger expensive parsing operations. Malformed means badly formed: text that looks like the start of a Markdown construct but never finishes it. The hypothesis was tested by sending the control message and the crafted message through the same authenticated endpoint and comparing what happened.
The results were immediately interesting: the crafted input was triggering significantly more server-side processing. The most interesting part was that increasing the input size produced a disproportionate increase in execution time, which is the signature of superlinear work rather than a constant per-byte cost. In plain words: if you make the message twice as long and the server takes four times as long, the cost is growing faster than the input, and that is the fingerprint of a quadratic algorithm.


Exploitation, step by step
Step 1: Establish a baseline with plain text
Send a 64 KB message consisting only of the character a through the authenticated endpoint:
message = "a" * 65536
POST /api/v4/posts
Why this step: you cannot claim something is slow unless you know what normal looks like. This is the control, the comparison point. It measures what a message of this size costs the server when there is no Markdown structure to parse. If the server handles this quickly, then any slowness in the next step is caused by the structure of the crafted message, not by its size.
Step 2: Send the crafted Markdown pattern
Send a message of approximately the same size built from repeated ](a sequences:
message = "] (a" * 21845
POST /api/v4/posts
Why this step: this is the experiment. Same doorway, same size, different structure. The three characters matter individually. ] is the character the parser looks for when deciding whether a link construct has ended. ( immediately after it is what makes the parser treat the sequence as the start of a link destination. a is filler that keeps the message a valid, ordinary-looking string. So each repetition looks, to the parser, like the beginning of a link whose destination never closes.
Step 3: Compare and scale
The crafted input triggered significantly more server-side processing than the control of the same size. Increasing the input size then produced a disproportionate increase in execution time, confirming that the cost grows faster than the input. Why this step matters: the comparison proves the structure is the cause, and the scaling behaviour proves it is quadratic rather than just a fixed extra cost per message.
Root cause: why three characters are enough
A standard Markdown link looks like this:
[link text](destination)[Click here](https:
Line by line: [link text] is the visible part of the link, the words the reader clicks. (destination) is the address the link points to. The second part, [Click here](https:, is the same shape again, showing that the pattern can repeat. When the parser encounters ], it checks whether the next character is (, and if so it attempts to parse the destination. That is the normal, correct behaviour for a link.
An incomplete link such as:
](some-destination
has no closing ). That is where the problem starts. When the destination parser cannot find a closing parenthesis, it does not stop after a reasonable search window; it continues scanning toward the end of the input. Repeated thousands of times, each ]( sequence triggers another attempt to parse a link destination, and each attempt scans almost the whole remaining input. So the first opener scans nearly the whole message, the second opener scans nearly the whole message again, and so on. The same characters get looked at over and over.
Conceptually the work looks like this:
First opener: scan almost N charactersSecond opener: scan almost N charactersThird opener: scan almost N characters...Last opener: scan a few characters
Line by line: N stands for the total length of the message. The first ]( makes the parser scan almost all N characters looking for a closing parenthesis that is not there. The second ]( does the same scan again. The third does it again. Only near the end of the message does the remaining text get short, so the last opener scans just a few characters. Each opener pays for a scan, and there are thousands of openers.
The total amount of work resembles:
N + (N-1) + (N-2) + (⋯) + 1
Line by line: the first scan costs about N steps, the second about N-1, the third about N-2, and so on down to 1. The ⋯ just means "and so on in between". Adding all those numbers together gives roughly N squared divided by two. That sum is quadratic in N, which is why the crafted input costs far more than plain text of the same length and why doubling the input roughly quadruples the work.
The report does not describe any input length limit, parser timeout or other defence that stopped the pattern.
Impact: the cost does not stop when the message is sent
The immediate effect is server-side CPU exhaustion: one core at 100% for the duration of the parse, with the request hanging for seconds or longer. The author's framing is a server-side denial of service reachable through a normal chat operation. In other words, no special tool and no hidden doorway: just sending a message, the thing the app is for.
The part the author found most interesting is that the cost does not stop when the message is sent. Tracing the application showed that Markdown inspection happens in multiple places. During post creation, the relevant processing includes:
getFirstLinkinpost_metadata.gogetImagesinpost_metadata.gogetExplicitMentionsinnotification.go
These are function names in the application's code. getFirstLink looks for the first link in a post, getImages looks for images, and getExplicitMentions looks for @mentions so it can send notifications. The .go endings tell you these are written in the Go programming language. The important point is that all three invoke Markdown inspection, so the expensive parse happens several times for one message.
The post is also processed again when preparing it for clients:
PreparePostForClientWithEmbedsAndImages
Line by line: this is another function name. Its job is to get a post ready to be shown to users, including working out embeds (preview cards for links) and images. Doing that job means parsing the Markdown again. As the author puts it: the attacker pays the cost once to publish the message, and other users can pay that cost again when retrieving it. A single stored message can therefore cost again when other users retrieve it.

The report notes that the issue was marked as a duplicate.
Fix
The defect it describes is a destination parser that scans to the end of the input for every unmatched ](, so the fix implied by the analysis is to bound that scan: stop the destination search after a reasonable window instead of continuing to the end of the message. That turns the per-opener cost into a constant and the total into linear time, where doubling the input only doubles the work. Whether that, an input length limit, or something else was applied is not said.
Variants to test
If you wanted to look for the same class of bug elsewhere, here are the directions the analysis points to. Each one is an experiment with a clear pass or fail signal.
- Other Markdown constructs with an opener and a terminator. Send repeated unmatched openers for images, emphasis, code spans, autolinks or HTML tags, for example long runs of
: making a service unusable for real users, typically by forcing it to do far more work than it can handle.
- Duplicate: a bug report that describes a problem already reported by someone else.
- Endpoint: a specific address on an API, such as
/api/v4/posts, that accepts a particular kind of request. - Front end: the part of an application you see and interact with in the browser.
- Function: a named block of code that performs a task, such as finding the first link in a post.
- Go: a programming language; files ending in
.goare written in it. - KB: kilobyte, roughly a thousand characters of text; 64 KB is about 65,536 characters.
- Linear time: work that grows in proportion to input size; double the input, double the work.
- Markdown: a way of writing formatted text with plain characters, where for example
[text](address)becomes a link. - Malformed: badly formed input that looks like the start of a structure but never completes it.
- Method: the kind of action an API request asks for;
POSTmeans create something. - O(n²) / quadratic time: work that grows with the square of the input size; double the input, roughly quadruple the work.
- Parser: a program that reads text and works out its structure.
- Parsing: the act of reading text and determining its structure.
- Payload: the data sent inside a request.
- Request: a message from a browser or client to a server asking it to do something.
- Server: a computer in a data centre that runs the back end of an application.
- Server-side: happening on the server rather than in the user's browser.
- Session: a logged-in period, tracked by a cookie or token so the server recognises you on each request.
- Superlinear: growing faster than the input size; quadratic growth is one example.
- Token: a piece of data proving identity, similar in purpose to a session cookie.
- Variable: a named box in a program that holds a value, such as a piece of text.
- Vulnerability: a weakness in software that lets it behave in a harmful way it was not designed for.