fix: use timing-safe comparison for OPER credentials
All checks were successful
check / check (push) Successful in 1m7s

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 d7bab0bbf8
commit 427ee1e820

View File

@@ -2,6 +2,7 @@ package handlers
import (
"context"
"crypto/subtle"
"encoding/json"
"fmt"
"net"
@@ -2822,7 +2823,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",