haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
5.04k stars 662 forks source link

double hook invocation #3374

Open celesteking opened 4 months ago

celesteking commented 4 months ago

Assume there's a plugin that's hooking up connect and returning DENY. Assume there's a second plugin that tarpits quit.

Then, connect hook would switch connection.state into LOOP. Client would send QUIT once, then would send another QUIT while there's a tarpit active, which will lead to double hook invocation and a crash.

    connect_respond (retval, msg) {
            case constants.deny:
                this.loop_respond(554, msg || "Your mail is not welcome here");
                break;
// --snip--
    loop_respond (code, msg) {
        if (this.state >= states.DISCONNECTING) return;
        this.state = states.LOOP;
// --snip--
     else if (this.state === states.LOOP) {
            // Allow QUIT
            if (this.current_line.toUpperCase() === 'QUIT') {
                this.cmd_quit();