fix: use timing-safe comparison for OPER credentials
Some checks failed
check / check (push) Failing after 1m49s

Replace plain != string comparison with crypto/subtle.ConstantTimeCompare
for both operator name and password checks in handleOper to prevent
timing-based side-channel attacks.

Closes review feedback on PR #82.
This commit is contained in:
user
2026-03-17 11:57:29 -07:00
parent b7999b201f
commit 67460ea6b2

View File

@@ -2,6 +2,7 @@ package handlers
import (
"context"
"crypto/subtle"
"encoding/json"
"errors"
"fmt"
@@ -3186,7 +3187,8 @@ func (hdlr *Handlers) handleOper(
cfgPass := hdlr.params.Config.OperPassword
if cfgName == "" || cfgPass == "" ||
operName != cfgName || operPass != cfgPass {
subtle.ConstantTimeCompare([]byte(operName), []byte(cfgName)) != 1 ||
subtle.ConstantTimeCompare([]byte(operPass), []byte(cfgPass)) != 1 {
hdlr.enqueueNumeric(
ctx, clientID, irc.ErrNoOperHost, nick,
nil, "No O-lines for your host",