Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/small-waves-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

Adds "DOMPurify" and "he" to sanitize ECDH and Livechat errors
6 changes: 4 additions & 2 deletions apps/meteor/ee/server/services/ecdh-proxy/lib/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import cookie from 'cookie';
import cookieParser from 'cookie-parser';
import type { Request, Response } from 'express';
import express from 'express';
import he from 'he';
import mem from 'mem';
import WebSocket from 'ws';

Expand Down Expand Up @@ -106,7 +107,7 @@ app.post('/api/ecdh_proxy/initEncryptedSession', async (req, res) => {
publicKeyString: session.publicKeyString,
});
} catch (e) {
res.status(400).send(e instanceof Error ? e.message : String(e));
res.status(400).send(e instanceof Error ? he.escape(e.message) : he.escape(String(e)));
}
});

Expand All @@ -126,7 +127,8 @@ app.post('/api/ecdh_proxy/echo', async (req, res) => {
res.send(await session.encrypt(result));
} catch (e) {
console.error(e);
res.status(400).send(e instanceof Error ? e.message : String(e));
const errorMessage = e instanceof Error ? e.message : String(e);
res.status(400).send(he.encode(errorMessage));
}
});

Expand Down
1 change: 1 addition & 0 deletions packages/livechat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"@rocket.chat/ui-kit": "workspace:~",
"css-vars-ponyfill": "^2.4.9",
"date-fns": "^2.30.0",
"dompurify": "^3.2.3",
"emoji-mart": "^3.0.1",
"history": "~5.3.0",
"i18next": "~23.4.9",
Expand Down
4 changes: 2 additions & 2 deletions packages/livechat/src/components/Composer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import type { CSSProperties } from 'preact/compat';

import { createClassName } from '../../helpers/createClassName';
import { parse } from '../../helpers/parse';
import DOMPurify from 'dompurify';
import styles from './styles.scss';

const findLastTextNode = (node: Node): Node | null => {
if (node.nodeType === Node.TEXT_NODE) {
return node;
Expand Down Expand Up @@ -214,7 +214,7 @@ export class Composer extends Component<ComposerProps, ComposerState> {
const caretPosition = this.getCaretPosition(this.el);
const oldText = this.el?.innerText ?? '';
const newText = `${oldText.slice(0, caretPosition)}${emoji}&nbsp;${oldText.slice(caretPosition)}`;
this.el.innerHTML = newText;
this.el.innerHTML = DOMPurify.sanitize(newText);
this.moveCursorToEndAndFocus(caretPosition + emoji.length + 1);
onChange?.(this.el.innerText);
}
Expand Down
Loading