Guard the namespace on NickServ GROUP, gRPC GroupNick, and GroupServ REGISTER (confusable/forbid/cap)
Some checks failed
CI / check (push) Has been cancelled

This commit is contained in:
Jean Chevronnet 2026-07-19 15:34:35 +00:00
parent 224bc78641
commit 03d39c1329
No known key found for this signature in database
3 changed files with 34 additions and 0 deletions

View file

@ -11,6 +11,14 @@ pub fn handle(me: &str, from: &Sender, name: Option<&str>, ctx: &mut ServiceCtx,
ctx.notice(me, from.uid, "A group name starts with \x02!\x02, e.g. \x02!staff\x02.");
return;
}
// Guard the group namespace like NickServ/ChanServ REGISTER: a look-alike group
// name (!аdmin) could impersonate a real one that opers grant channel access to.
if db.confusable_check_enabled() {
if let Some(reason) = echo_api::confusable_reason(name) {
ctx.notice(me, from.uid, reason);
return;
}
}
let acc = acc.to_string();
match db.group_register(name, &acc) {
Ok(()) => ctx.notice(me, from.uid, format!("Group \x02{name}\x02 registered — you're the founder.")),

View file

@ -26,6 +26,24 @@ pub fn handle(me: &str, from: &Sender, args: &[&str], ctx: &mut ServiceCtx, db:
ctx.notice(me, from.uid, format!("\x02{}\x02 is itself a registered account.", from.nick));
return;
}
// Guard the namespace like REGISTER does: grouping RESERVES from.nick (SET KILL
// enforces it), so a look-alike or FORBIDden nick must not be groupable, and one
// account can't squat an unbounded number of nicks (each grows the log forever).
if db.confusable_check_enabled() {
if let Some(reason) = echo_api::confusable_reason(from.nick) {
ctx.notice(me, from.uid, reason);
return;
}
}
if db.is_forbidden(echo_api::ForbidKind::Nick, from.nick).is_some() {
ctx.notice(me, from.uid, format!("The nick \x02{}\x02 is reserved and can't be grouped.", from.nick));
return;
}
const MAX_GROUPED: usize = 25;
if db.grouped_nicks(&canonical).len() >= MAX_GROUPED {
ctx.notice(me, from.uid, format!("\x02{canonical}\x02 already has the maximum of {MAX_GROUPED} grouped nicks."));
return;
}
match db.group_nick(from.nick, &canonical) {
Ok(()) => ctx.notice(me, from.uid, format!("Your nick \x02{}\x02 is now grouped to \x02{canonical}\x02.", from.nick)),
Err(_) => ctx.notice(me, from.uid, "Sorry, that didn't work. Please try again in a moment."),

View file

@ -148,6 +148,14 @@ impl Engine {
if self.db.account(nick).is_some() {
return AuthorityStatus::Invalid; // nick is itself a registered account
}
// Same namespace guards as REGISTER: grouping reserves the nick, so a website
// can't group a look-alike/forbidden nick, and one account can't squat many.
if let Err(status) = self.authority_name_ok(nick) {
return status;
}
if self.db.grouped_nicks(account).len() >= 25 {
return AuthorityStatus::Invalid;
}
match self.db.group_nick(nick, account) {
Ok(()) => AuthorityStatus::Ok,
Err(_) => AuthorityStatus::NotFound, // group_nick's only Err means the account doesn't exist