iOS app crashed by specially crafted direct message reactions
The Twitter iOS app did not sanitise direct message reaction text, allowing special characters such as carriage return, newline and a NUL byte to be stored and displayed. An attacker could send a reaction containing a NUL byte to crash the app persistently for the victim.
- Triaged in 3 days
- Fixed in 14 days
- Paid in 14 days
- Disclosed after 24 days
Summary: iOS app crashed by specially crafted direct message reactions
Description:
Twitter does not properly sanitize direct message reactions, making it possible for arbitrary reaction text to be shown to the user via the message preview in the direct message list. Special characters such as \r and \n are not stripped, and it is even possible to crash the app by inserting a \0 character into the reaction text.
Steps To Reproduce:
(Add details for how we can reproduce the issue)
- Start a direct message conversation with the victim (this can also be yourself).
- Make a request to https://api.twitter.com/1.1/dm/reaction/new.json with an appropriate
conversation_idanddm_idparameter, andreaction_keyset to\0(an actual NUL byte). - Notice that the iOS app crashes, even on any subsequent attempts to reopen it.
Impact
This makes it trivial for an attacker to make the Twitter iOS app unusable for any user they can send a direct message to. The only recourse for the victim is to log in via twitter.com and delete the affected message or conversation.
Context
Twitter's iOS client, bundled as com.atebits.Tweetie2, includes direct messages with reactions: a user can attach a reaction to an individual message inside a conversation, and the direct message list shows a preview of the latest message in each thread. The reaction text is rendered as part of that preview. The report concerns the handling of that reaction text on the client side, specifically the absence of sanitisation before it is displayed.
Setup
The researcher needed two things: a direct message conversation with the victim, and the ability to send a reaction to a message in that conversation. The report notes that the conversation can be with yourself, so a single account is enough to reproduce the crash. The reaction is created by calling the direct message reaction endpoint directly rather than through the app UI, which allows an arbitrary reaction_key value to be submitted.
Finding it
The researcher observed that Twitter does not properly sanitise direct message reactions. Because the reaction text is surfaced to the user through the message preview in the direct message list, arbitrary reaction content reaches the client. Control characters such as \r and \n are not stripped, and the researcher found that inserting a \0 character into the reaction text crashes the app.
Exploitation
Step 1: Start a conversation
Start a direct message conversation with the victim. The report notes this can also be yourself, which makes the issue testable with a single account.
Step 2: Send the crafted reaction
Make a request to the reaction endpoint with an appropriate conversation_id and dm_id parameter, and reaction_key set to \0, an actual NUL byte:
https://api.twitter.com/1.1/dm/reaction/new.json
The conversation_id and dm_id identify the thread and the specific message being reacted to. The reaction_key carries the reaction text, and here it contains a raw NUL byte instead of a normal reaction value.
Step 3: Observe the crash
The iOS app crashes. The report adds that it crashes even on any subsequent attempts to reopen it, so the failure is persistent rather than a one-off glitch.
Root cause
The client does not sanitise reaction text before rendering it in the direct message preview. Control characters such as \r and \n pass through untouched, and a NUL byte in the reaction text is enough to crash the app. The report notes that the app crashes even on subsequent attempts to reopen it. The report does not describe the specific client code path involved.
Impact
An attacker can make the Twitter iOS app unusable for any user they can send a direct message to. The report describes this as trivial to do. The only recourse for the victim is to log in via twitter.com and delete the affected message or conversation. The platform recorded the issue as medium severity with a CVSS score of 5.7, classified as Uncontrolled Resource Consumption, with a bounty of 560.00 USD.
Fix
The report does not state what was changed.
Variants to test
- Other control characters in
reaction_key: try\r,\nand other non-printing bytes and check whether they appear raw in the message preview or disrupt rendering. - Other fields rendered in previews: apply the same NUL byte and control character tests to message text, display names and other content that appears in list previews.
- Other clients: check whether the Android client or the web client handles the same stored reaction differently, which would show whether the flaw is client-specific.
- Persistence: after a crash, reopen the app and confirm whether the failure repeats, as it did here.
Hunting notes
This kind of bug hides where server-supplied strings are rendered in list previews and other compact UI surfaces, especially fields that are not free-form message text and so may escape the sanitisation applied to messages. During recon, look for features that accept structured values, such as reactions, and check whether those values are validated server-side. The report notes that the app crashes even on subsequent attempts to reopen it, and that the victim's only recourse is to log in via twitter.com and delete the affected message or conversation.
Difficulty
beginner
Difficulty reason
The reproduction is a single API request with a NUL byte in one parameter, and the crash is immediate and persistent, so no chaining or deep reverse engineering is required.
What happened, in plain words
Twitter's iPhone app (the app's internal bundle name is com.atebits.Tweetie2) lets people send direct messages, which are private messages between two accounts. Inside a conversation you can attach a reaction to a single message, a small piece of text that sits next to that message. The direct message list, the screen that shows all your conversations, also shows a short preview of the latest message in each thread, and the reaction text is drawn as part of that preview.
The researcher found that the app does not clean up (sanitise) the reaction text before showing it. That means whatever text is stored as a reaction ends up on screen, including invisible control characters. One particular character, a NUL byte, is enough to crash the app, and the app keeps crashing every time you reopen it, because the bad text is still stored in the conversation.
A NUL byte is a byte with the value zero. It is not a printable character; it is used in many programs to mark the end of a piece of text. If a program that expects ordinary text receives a zero byte in the middle, it can misbehave badly. The everyday comparison: imagine a form that asks for your name and you write an invisible symbol that the printer cannot handle. The printer jams, and every time you try to print the same page it jams again, because the symbol is still on the page.
Background you need first
A few ideas come up repeatedly, so here they are before the steps.
- API: an API (Application Programming Interface) is a way for one program to talk to another over the internet. When you use the Twitter app, the app is not doing everything itself; it sends requests to Twitter's servers and the servers send back data. Those requests go to addresses like
https://api.twitter.com/.... An API is like a service counter: you hand over a form with fields filled in, and the clerk behind the counter does the work and hands back a result. - Endpoint: a specific address on that counter, for example the reaction endpoint. Each endpoint does one job.
- Parameter: one field on the form you hand to the counter. In the request below,
conversation_id,dm_idandreaction_keyare parameters. Each one tells the server which conversation, which message, and what reaction. - Sanitise: to clean input before using it, for example by removing characters that should never appear. Think of a bouncer checking IDs at a door: anything that does not belong is stopped before it gets inside.
- Control character: a character that is not meant to be seen, such as
\r(carriage return, which moves the cursor to the start of a line),\n(newline, which moves to the next line) and\0(the NUL byte). They are instructions to a program rather than letters you read. - Uncontrolled Resource Consumption: the vulnerability class recorded for this report. In plain words, the program uses up something it needs (memory, processing, or in this case its ability to stay running) because it was not given a limit on what it accepts. The everyday comparison is a machine that keeps taking coins until it jams, because nobody told it to stop after a certain number.
Setting up the test
The researcher needed two things: a direct message conversation with the victim, and a way to send a reaction to a message in that conversation. The report notes that the conversation can be with yourself, so a single account is enough to reproduce the crash. That matters because it means you do not need a second person to try this.
The reaction is created by calling the reaction endpoint directly, rather than by tapping a reaction button in the app. By sending the request yourself, you can put any value you like into the reaction field. This is the same idea as ordering from the kitchen directly instead of through the waiter: the menu limits you, the kitchen does not.
Finding the problem
The researcher observed that Twitter does not properly sanitise direct message reactions. Because the reaction text is shown to the user through the message preview in the direct message list, whatever is stored as a reaction reaches the app's screen. Control characters such as \r and \n are not stripped, and the researcher found that inserting a \0 character into the reaction text crashes the app.
Reproducing it
Step 1: Start a conversation
Start a direct message conversation with the victim. The report notes this can also be yourself, which makes the issue testable with a single account. This step exists because a reaction has to live inside a conversation and be attached to a message; without a thread and a message, there is nothing to react to.
Step 2: Send the crafted reaction
Make a request to the reaction endpoint with an appropriate conversation_id and dm_id parameter, and reaction_key set to \0, an actual NUL byte:
https://api.twitter.com/1.1/dm/reaction/new.json
Line by line:
https://is the secure web protocol, the same one your browser uses when the address bar shows a padlock.api.twitter.comis Twitter's API server, the counter where requests are handed in./1.1/dm/reaction/new.jsonis the path to the endpoint that creates a new reaction on a direct message.dmstands for direct message,reactionfor the reaction feature,newfor creating one, and.jsonsays the answer comes back in JSON, a common text format for data.
The conversation_id and dm_id identify the thread and the specific message being reacted to. The reaction_key carries the reaction text, and here it contains a raw NUL byte instead of a normal reaction value. The request sets reaction_key to a raw NUL byte instead of a normal reaction value.
Step 3: Observe the crash
The iOS app crashes. The report adds that it crashes even on any subsequent attempts to reopen it, so the failure is persistent rather than a one-off glitch. The report notes that the app crashes even on subsequent attempts to reopen it.
Why it happens
The app does not sanitise reaction text before drawing it in the direct message preview. Control characters such as \r and \n pass through untouched, and a NUL byte in the reaction text is enough to crash the app. The report does not describe the specific client code path involved.
What an attacker can do with it
An attacker can make the Twitter iOS app unusable for any user they can send a direct message to. The report describes this as trivial to do. The only recourse for the victim is to log in via twitter.com and delete the affected message or conversation.
The platform recorded the issue as medium severity with a CVSS score of 5.7, classified as Uncontrolled Resource Consumption, with a bounty of 560.00 USD. CVSS is a standard scoring system for how serious a security issue is; 5.7 sits in the middle of the scale.
The fix
The report does not state what was changed. Two layers are better than one: the server refuses to store nonsense, and the app refuses to draw it even if it somehow arrives.
Other things worth testing
- Other control characters in
reaction_key: try\r,\nand other non-printing bytes and check whether they appear raw in the message preview or disrupt rendering. - Other fields rendered in previews: apply the same NUL byte and control character tests to message text, display names and other content that appears in list previews.
- Other clients: check whether the Android client or the web client handles the same stored reaction differently, which would show whether the flaw is client-specific.
- Persistence: after a crash, reopen the app and confirm whether the failure repeats, as it did here.
Where to look for similar bugs
This kind of bug hides where server-supplied strings are rendered in list previews and other compact UI surfaces, especially fields that are not free-form message text and so may escape the sanitisation applied to messages. During recon (the early stage of looking around a target for weak spots), look for features that accept structured values, such as reactions, and check whether those values are validated server-side. The report notes that the app crashes even on subsequent attempts to reopen it, and that the victim's only recourse is to log in via twitter.com and delete the affected message or conversation. A denial of service simply means making a service unusable for someone, rather than stealing their data.
How hard was it
Beginner. The reproduction is a single API request with a NUL byte in one parameter, and the crash is immediate and persistent, so no chaining or deep reverse engineering is required. Chaining means combining several small weaknesses into a bigger attack; reverse engineering means taking a program apart to understand how it works. Neither was needed here.
Glossary
- API: a way for one program to talk to another over the internet, usually by sending requests to specific addresses and getting data back.
- Endpoint: one specific address on an API that performs one job, such as creating a reaction.
- Parameter: a named field in a request that tells the server what to act on, such as which conversation or which message.
- Control character: a non-printing character that instructs a program rather than being read, such as
\r,\nand\0. - NUL byte: a byte with the value zero, written
\0, often used to mark the end of text; it is not a printable character. - Direct message: a private message between accounts on Twitter.
- Reaction: a small piece of text attached to a single message inside a conversation.
- Message preview: the short snippet of the latest message shown in the direct message list.
- Uncontrolled Resource Consumption: a vulnerability class where a program uses up something it needs because it was not given a limit on what it accepts.
- Denial of service: making a service unusable for someone, rather than stealing their data.
- CVSS: a standard scoring system for the severity of a security issue; 5.7 is a medium score.
- Recon: the early stage of looking around a target for weak spots.
- Chaining: combining several small weaknesses into a bigger attack.
- Reverse engineering: taking a program apart to understand how it works.
- JSON: a common text format for exchanging data between programs.