Commit 24d5c77
committed
🔒🥅 Handle tagged "OK" to incomplete command
Taking a "belt-and-suspenders" approach:
This is a potential problem for any command which registers a response
handler: a malicious server can easily guess what the next tag will be,
and send an `OK` response _before_ the client the response handler is
attached.
`STARTTLS` is an extreme example of this issue: if the `STARTTLS`
handler does not run, then `#starttls` will not start the TLS session,
and the connection is not secured, _but no error is raised._
We should _also_ attach the response handler before sending the `CRLF`,
but that is neither necessary (the response handler will added before
the `synchronize` mutex is unlocked) nor sufficient (the fake `OK` can
be sent _much_ earlier).
On the other hand, it _is_ okay for the server to send an error tagged
response (`NO` or `BAD`), before sending the command has completed.1 parent 62eea6f commit 24d5c77
1 file changed
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3174 | 3174 | | |
3175 | 3175 | | |
3176 | 3176 | | |
| 3177 | + | |
3177 | 3178 | | |
3178 | 3179 | | |
3179 | 3180 | | |
| |||
3638 | 3639 | | |
3639 | 3640 | | |
3640 | 3641 | | |
| 3642 | + | |
3641 | 3643 | | |
3642 | 3644 | | |
3643 | 3645 | | |
| |||
3653 | 3655 | | |
3654 | 3656 | | |
3655 | 3657 | | |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
| 3661 | + | |
| 3662 | + | |
| 3663 | + | |
| 3664 | + | |
| 3665 | + | |
| 3666 | + | |
| 3667 | + | |
| 3668 | + | |
| 3669 | + | |
| 3670 | + | |
3656 | 3671 | | |
3657 | 3672 | | |
3658 | 3673 | | |
| |||
0 commit comments