Blind SQL injection in third-party software, that allows to reveal user statistic from rocket.chat and possibly hack into the rocketchat.agilecrm.com
A third-party statistics script loaded on the Rocket.Chat website passed a URL parameter into a database query without sanitisation, making it vulnerable to blind SQL injection. An attacker could use time-based queries to confirm the flaw and extract database names and table names, potentially exposing user statistics.
- Triaged in 19 days
- Fixed in 5 months
- Disclosed after 11 months
Hi. I decided to go to static website https://rocket.chat/ and look what is there. I found third-party website request https://stats2.agilecrm.com/addstats?callback=json9064172181954295&guid=5d659e65-2870-63d3-eff0-654315dd3b91&sid=515241ff-64f3-5589-f595-bf1bcccc56f9&url=https%3A%2F%2Frocket.chat%2F&agile=8pat9ou8gh0thqd8dlgctje3go&domain=dorgam that loading on the main page. After "lite" parameters fussing I found out that parameter "new" is vulnerable to Blind SQL injection vulnerability.
PoC:
https://stats2.agilecrm.com/addstats?callback=json949659033379064&guid=f0d3738c-44c0-60a6-44b6-56e14ca30872&sid=2172c2ca-15b6-49c8-052d-b7d817cd280b&url=https%3A%2F%2Frocket.chat%2F&agile=8pat9ou8gh0thqd8dlgctje3go&new=(select*from(select(sleep(5)))a)&ref=&domain=dorgam
Result: 5 seconds of loading.
To show the vulnerability threat I decided to exploit it a bit:
Database version: MySQL 5.0.12 Server hostname: localhost Databases: information_schema; mysql; performance_schema; stats Stats: 3; persons; map.
Suggested mitigation
Try to contact agilecrm support / developers and tell them about vulnerability and fix needing.
P.S: I know that on BB main page you letting researchers know about exclusions:
Exclusions While researching, we'd like to ask you to refrain from: Static website (https://rocket.chat)
But because of vulnerability severity I think I must let you know anyway.
Impact
Vuln allows to reveal user statistic information from rocket.chat and possibly hack into rocketchat.agilecrm.com (if attacker decided to go deeper).
Attachments


Context
The target here is the public static website at https://rocket.chat/. The researcher was looking at what the main page loads, and found that it pulls in a third-party analytics script from Agile CRM. The endpoint is stats2.agilecrm.com/addstats, a tracking call that records a visit: it takes a callback name, a guid, a sid, the page url, an agile account identifier and a domain value.
The report is about that third-party endpoint, not about Rocket.Chat's own application code. The researcher notes that the program's main page lists an exclusion for the static website (https://rocket.chat), and says he reported anyway because of the severity.
Setup
No accounts, roles or special tooling are described. The work was done against the live static site and the live Agile CRM endpoint. The only precondition is that the main page loads the analytics request, which it does for any visitor.
Finding it
While browsing https://rocket.chat/, the researcher noticed this request being made by the page:
https://stats2.agilecrm.com/addstats?callback=json9064172181954295&guid=5d659e65-2870-63d3-eff0-654315dd3b91&sid=515241ff-64f3-5589-f595-bf1bcccc56f9&url=https%3A%2F%2Frocket.chat%2F&agile=8pat9ou8gh0thqd8dlgctje3go&domain=dorgam
The request carries a callback name, guid, sid, the page url, an agile value and a domain value. After experimenting with the parameters, the researcher found that a parameter called new is vulnerable to blind SQL injection.
Exploitation
Step 1: confirm the injection with a time delay
The proof of concept adds the new parameter with a subquery that calls sleep(5):
https://stats2.agilecrm.com/addstats?callback=json949659033379064&guid=f0d3738c-44c0-60a6-44b6-56e14ca30872&sid=2172c2ca-15b6-49c8-052d-b7d817cd280b&url=https%3A%2F%2Frocket.chat%2F&agile=8pat9ou8gh0thqd8dlgctje3go&new=(select*from(select(sleep(5)))a)&ref=&domain=dorgam
The payload is (select*from(select(sleep(5)))a). The select*from(...)a form wraps the inner query as a derived table, and the alias a is needed for MySQL to accept it. If the value reaches the database unparameterised, the query pauses for five seconds.
The result was five seconds of loading, which confirms the injection.
Step 2: extract information
Having confirmed the delay, the researcher exploited it further and reports the following from the database:
- Database version: MySQL 5.0.12
- Server hostname: localhost
- Databases:
information_schema,mysql,performance_schema,stats - Tables in the
statsdatabase:3,persons,map
The report does not show the individual queries used to retrieve these values.
Root cause
The new parameter reaches a SQL query on the Agile CRM statistics backend, since a sleep(5) payload delayed the response by five seconds. The report does not describe the server-side code, so the exact construction is not shown; the behaviour is consistent with string concatenation into the query. The endpoint is reachable by anyone who loads the Rocket.Chat page, and the parameter is attacker-controlled through the URL.
Impact
According to the report, the vulnerability allows an attacker to reveal user statistics from Rocket.Chat, and possibly to hack into rocketchat.agilecrm.com if the attacker decides to go deeper. The second part is stated as a possibility, not as something demonstrated. The data actually shown as reachable is the database version, the server hostname and the list of databases and tables on the statistics host.
Fix
The suggested mitigation in the report is to contact Agile CRM support or developers, tell them about the vulnerability and ask them to fix it.
Variants to test
- Add an unused parameter such as
newto a third-party analytics or tracking endpoint and try a time-based payload like the one above. A positive result is a response delayed by the number of seconds in the payload, repeatable across requests.
Hunting notes
This kind of bug hides in third-party scripts embedded in a target's pages: analytics, chat widgets, marketing tags. The signal during recon is a request to an external host that carries identifiers and a page URL, such as the one the Rocket.Chat page loads. The researcher showed impact by turning the delay into concrete extraction: version, hostname, database names and table names. Note that the static site was on the program's exclusion list, and the report was submitted anyway on severity grounds; the vulnerable component was the third-party service, not Rocket.Chat's own application.
Attachments


What happened, in plain words
A security researcher was looking at the public website of Rocket.Chat, a chat application company, at https://rocket.chat/. This is the marketing site, the pages anyone can read without logging in. While looking at what the page loads in the browser, he noticed that the page quietly contacts another company's server: an analytics service run by Agile CRM. Analytics services are the tools websites use to count visits, see which pages are popular and where visitors come from.
The request the page makes goes to stats2.agilecrm.com/addstats. Think of it as a small note the page sends to a counting office: "someone visited this page, here are their identifiers". The page sends the request to the counting office. The researcher experimented with the parts of that request (the parameters, explained below) and found that one of them, called new, is not handled safely. Whatever text is put there reaches the database as part of a query. That is a SQL injection, and because the researcher could not see the answers directly, only measure how long the server took, it is called a blind one.
He proved it by making the server wait five seconds on purpose, then used the same trick to read the database version, the server's hostname and the names of the databases and tables. The report says this could expose Rocket.Chat's visitor statistics and possibly allow deeper access to rocketchat.agilecrm.com. The report also notes that the static website https://rocket.chat is on the program's list of places researchers are asked not to test, and that he submitted anyway because of the severity.
Background you need first
A few ideas come up again and again, so here they are from zero.
- A web page is not one file. When you open a page, your browser fetches the page itself and then many other things: images, fonts, and small programs (scripts) written by other companies. Those scripts can make their own requests to their own servers. That is how a page can talk to an analytics company without you noticing.
- A request and its parameters. A web address can carry extra information after a question mark, in the form
name=value, separated by&. Eachname=valuepair is a parameter. For example, a search page might use?q=catsto mean "search for cats". The server reads these values and acts on them. - URL encoding. Some characters cannot appear literally in a web address, so they are written in a coded form.
%3Ameans a colon:, and%2Fmeans a slash/. Sohttps%3A%2F%2Frocket.chat%2Fis justhttps://rocket.chat/written in a form safe to put inside a parameter. - JSONP and the
callbackparameter. Normally a browser will not let a page read data from a different company's server, for safety. JSONP is an old workaround: the page tells the server the name of a small function to wrap the data in, using thecallbackparameter, and the browser then runs that function. It is a way of receiving data across companies. - A database and SQL. A database is an organised store of information, like a very large set of spreadsheets. The language used to ask it questions is SQL. A question such as "give me all rows in the visitors table" is a SQL query.
- SQL injection. If a website builds a SQL query by gluing together text that came from the outside, an attacker can supply text that is not just data but also SQL instructions. The database cannot tell the difference and runs them. This is SQL injection. The safe way is to keep data and instructions separate (parameterised queries).
- Blind SQL injection. Sometimes the attacker never sees the query's output on the page. "Blind" means you learn by indirect signals instead. One classic signal is time: you ask the database to pause for a few seconds if a condition is true, and you watch how long the reply takes.
- A subquery and an alias. A subquery is a query inside another query. An alias is a short name given to a result so the database can refer to it. The payload below uses both, and the explanation after the code block walks through it.
The request the page was already making
While browsing https://rocket.chat/, the researcher saw the page make this request:
https://stats2.agilecrm.com/addstats?callback=json9064172181954295&guid=5d659e65-2870-63d3-eff0-654315dd3b91&sid=515241ff-64f3-5589-f595-bf1bcccc56f9&url=https%3A%2F%2Frocket.chat%2F&agile=8pat9ou8gh0thqd8dlgctje3go&domain=dorgam
Line by line, in plain words:
https://stats2.agilecrm.com/addstatsis the address of the counting office: Agile CRM's statistics server, and theaddstatsaction on it.callback=json9064172181954295tells the server which function name to wrap the reply in (the JSONP trick). The long number makes the name unique for this request.guid=...andsid=...are identifier values sent with the request.url=https%3A%2F%2Frocket.chat%2Fis the page being counted, written in URL-encoded form. Decoded, it ishttps://rocket.chat/.agile=...is another value sent with the request.domain=dorgamis another value sent with the request.
The important point is that the page sends them automatically for every visitor, so anyone can see them and anyone can change them before sending the request again.
After experimenting with these parameters, the researcher found that a parameter called new, which is not in the original request, is vulnerable to blind SQL injection. In other words, the server accepts an extra parameter it was not expecting, and its value affects a database query.
Step 1: prove the injection with a delay
To check whether his text really reaches the database as instructions, the researcher added the new parameter with a value that asks the database to sleep:
https://stats2.agilecrm.com/addstats?callback=json949659033379064&guid=f0d3738c-44c0-60a6-44b6-56e14ca30872&sid=2172c2ca-15b6-49c8-052d-b7d817cd280b&url=https%3A%2F%2Frocket.chat%2F&agile=8pat9ou8gh0thqd8dlgctje3go&new=(select*from(select(sleep(5)))a)&ref=&domain=dorgam
Line by line:
- The address and the
callback,guid,sid,url,agileanddomainparameters are the same kind of bookkeeping as before, with fresh identifier values. new=(select*from(select(sleep(5)))a)is the payload, the part that carries the attack. It is the only new thing.ref=is an empty parameter.
The payload itself, (select*from(select(sleep(5)))a), deserves its own walkthrough:
sleep(5)is a database instruction meaning "do nothing for five seconds".select(sleep(5))wraps that instruction in a query that returns its result.select*from(...)atakes that inner query and treats it as a temporary table, giving it the short name (alias)a. Theais an alias for the derived table.- The outer brackets make the whole thing a single value that can sit where the server expects the
newvalue.
Why this step: if the server treats the new value as plain data, nothing happens and the reply comes back at normal speed. If the server glues the value into a SQL query, the database runs sleep(5) and the reply is late. The delay is the proof, and it does not require seeing any data.
The result was five seconds of loading, which confirms the injection.
Step 2: read information out of the database
Having confirmed the delay, the researcher exploited it further and reports the following from the database:
| What | Value |
|---|---|
| Database version | MySQL 5.0.12 |
| Server hostname | localhost |
| Databases | information_schema, mysql, performance_schema, stats |
Tables in the stats database |
3, persons, map |
What these mean in everyday terms:
- The version tells you which database software and release is running, which matters because different versions behave differently.
- The hostname
localhostmeans the database sits on the same machine as the web service, not on a separate server. - The databases are the top-level containers. The databases are
information_schema,mysql,performance_schemaandstats. - The tables inside
statsare where the actual records live. The tables instatsare3,personsandmap.
The report does not show the individual queries used to retrieve these values. The point for a beginner is the shape of the attack: once you can make the database answer yes or no through timing, you can ask it many small questions and piece the answers together.
Why it works
The new parameter reaches a SQL query on the Agile CRM statistics backend, since a sleep(5) payload delayed the response by five seconds. The report does not describe the server-side code, so the exact construction is not shown; the behaviour is consistent with string concatenation into the query. The endpoint is reachable by anyone who loads the Rocket.Chat page, and the parameter is attacker-controlled through the URL.
A simple comparison: imagine a form where you write your name, and the clerk reads it out to a colleague as "let in [your name]". If you write "Alice and also open the safe", the colleague may do both. The clerk needed a rule that says "this part is only a name", which is what parameterised queries do.
Impact
According to the report, the vulnerability allows an attacker to reveal user statistics from Rocket.Chat, and possibly to hack into rocketchat.agilecrm.com if the attacker decides to go deeper. The second part is stated as a possibility, not as something demonstrated. The data actually shown as reachable is the database version, the server hostname and the list of databases and tables on the statistics host.
Suggested fix
The suggested mitigation in the report is to contact Agile CRM support or developers, tell them about the vulnerability and ask them to fix it.
Other places to look
- Add an unused parameter such as
newto a third-party analytics or tracking endpoint and try a time-based payload like the one above. A positive result is a response delayed by the number of seconds in the payload, repeatable across requests.
Notes on finding this kind of bug
This kind of bug hides in third-party scripts embedded in a target's pages: analytics, chat widgets, marketing tags. The signal while looking around is a request to an external host that carries identifiers and a page URL, such as the one the Rocket.Chat page loads. The researcher showed impact by turning the delay into concrete extraction: version, hostname, database names and table names. Note that the static site was on the program's exclusion list, and the report was submitted anyway on severity grounds; the vulnerable component was the third-party service, not Rocket.Chat's own application.
Attachments
The report includes two screenshots.


Glossary
- Analytics service: an outside company that counts visits and records which pages people look at.
- API: a defined way for one program to ask another program for something, like a service counter with set questions.
- Blind SQL injection: SQL injection where you cannot see the query's output, so you learn the answers indirectly, for example by timing.
- Callback (JSONP): a parameter that names a function the server should wrap its reply in, so a page can receive data from another company's server.
- Database: an organised store of information, queried with SQL.
- Database version: the name and release number of the database software running on a server.
- Domain: here, a short site label sent to the analytics service; more generally, the name part of a web address.
- Endpoint: a specific address on a server that accepts a particular kind of request.
- Exclusion list: places a bug bounty program asks researchers not to test.
- GUID: a long, effectively unique identifier; here it identifies a visitor.
- Hostname: the name of a machine on a network;
localhostmeans the same machine. - JSONP: an old technique for fetching data across companies by wrapping it in a function call.
- Parameter: a
name=valuepair in a web address that carries information to the server. - Parameterised query: a way of building SQL where outside values are kept separate from the instructions, so they cannot be executed.
- Payload: the part of a request that carries the attack.
- Request: a message a browser sends to a server asking for something.
- Session (SID): one person's continuous visit to a site, identified by a value so the server can tell visits apart.
- SQL: the language used to ask a database questions and give it instructions.
- SQL injection: tricking a program into running database instructions hidden inside data it was given.
- Subquery: a query written inside another query.
- Alias: a short name given to a query result so the database can refer to it.
- Static website: a site made of fixed pages that do not run the company's own application logic.
- Table: a set of rows and columns inside a database, like one spreadsheet.
- Third-party script: a small program on a page that comes from another company, such as an analytics or chat widget.
- URL encoding: writing special characters in a web address in coded form, such as
%3Afor a colon.