Skip to content

Commit c68209d

Browse files
committed
fix edge-case potential perm elevation
1 parent f1eb9a1 commit c68209d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/commands/adduser.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ export async function runAddUserCommand(
3131
formatted_body: "You aren't a moderator!",
3232
});
3333
}
34+
if (Object.keys(db.mods).length > 0) { // make sure a malicious user cannot hax with autojoin on
35+
return client.sendMessage(roomId, {
36+
body: "It seems that there is already a moderator in the database.\nIf this is a mistake, please manually clear graimdb.json",
37+
msgtype: "m.notice",
38+
format: "org.matrix.custom.html",
39+
formatted_body: "It seems that there is already a moderator in the database.<br/>If this is a mistake, please manually clear graimdb.json",
40+
});
41+
}
3442
}
3543

3644
if (!args[3]) {
@@ -122,7 +130,8 @@ export async function runAddUserCommand(
122130
` Discord: ${htmlEscape(user.discord)}<br/>` +
123131
`Moderator? ${moderator ? "Yes" : "No"}`,
124132
});
125-
} catch {
133+
} catch(err) {
134+
console.log(err);
126135
return client.sendMessage(roomId, {
127136
body: "Something went wrong running this command",
128137
msgtype: "m.notice",

0 commit comments

Comments
 (0)