Skip to content

Commit

Permalink
fix: make sure that stripping backslashes for notification urls canno…
Browse files Browse the repository at this point in the history
…t cause catastophic backtracking (ReDOS) (louislam#5573)

Co-authored-by: Frank Elsinga <frank@elsinga.de>
  • Loading branch information
ShiyuBanzhou and CommanderStorm authored Jan 26, 2025
1 parent 7dc6191 commit 7a91917
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion server/notification-providers/pushdeer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class PushDeer extends NotificationProvider {
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
const okMsg = "Sent Successfully.";
const serverUrl = notification.pushdeerServer || "https://api2.pushdeer.com";
const url = `${serverUrl.trim().replace(/\/*$/, "")}/message/push`;
// capture group below is nessesary to prevent an ReDOS-attack
const url = `${serverUrl.trim().replace(/([^/])\/+$/, "$1")}/message/push`;

let valid = msg != null && monitorJSON != null && heartbeatJSON != null;

Expand Down
2 changes: 1 addition & 1 deletion server/notification-providers/whapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Whapi extends NotificationProvider {
"body": msg,
};

let url = (notification.whapiApiUrl || "https://gate.whapi.cloud/").replace(/\/+$/, "") + "/messages/text";
let url = (notification.whapiApiUrl || "https://gate.whapi.cloud/").replace(/([^/])\/+$/, "$1") + "/messages/text";

await axios.post(url, data, config);

Expand Down

0 comments on commit 7a91917

Please sign in to comment.