RocketChat / RocketChat/EmbeddedChat
HTTP Parameter Pollution via Unencoded JSON in EmbeddedChatApi
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 165
- Forks
- 381
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 1
Description
The EmbeddedChatApi class builds request URLs by directly inserting the output of JSON.stringify() into query parameters without URL encoding. This happens in the getMessages and getOlderMessages methods.
If the query or field object contains special URL characters such as &, =, or #, those characters are interpreted by the server as URL delimiters, not as part of the value. This allows extra query parameters to be injected into the request.
As a result, the API is vulnerable to HTTP Parameter Pollution, which can lead to incorrect request handling and potential security issues.
Affected Code
File: packages/api/src/EmbeddedChatApi.ts
Current Implementation
const query = options?.query
? `&query=${JSON.stringify(options.query)}`
: "";
Steps to Reproduce
- Initialize
EmbeddedChatApi. - Call
getMessageswith a malicious query object:
api.getMessages(false, {
query: { attack: "test&roomId=GENERAL" }
});
- Inspect the network request.
Observed URL
.../messages?roomId=RID&query={"attack":"test&roomId=GENERAL"}
Result
The server interprets roomId=GENERAL as a separate query parameter, because the & inside the JSON string was not URL-encoded.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in packages/api/src/EmbeddedChatApi.ts and inspect the getMessages and getOlderMessages methods where JSON.stringify output is inserted into query parameters. Reproduce the issue with the supplied attack value, then verify that special characters remain part of the JSON value rather than becoming separate URL parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100