Skip to content

Commit bb19d02

Browse files
committed
Ignore errors in run loop
This fixes CVE-2021-37625
1 parent 8b7de71 commit bb19d02

File tree

5 files changed

+62
-2
lines changed

5 files changed

+62
-2
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,13 @@ All changes in this project will be noted in this file.
116116
under the `default` keyspace
117117
- Fix log output in `sky-bench` even if the `--json` flag was passed
118118
- Use flocks to enable auto release of pid file, even if process is forcefully terminated
119+
- Fixes [CVE-2021-37625](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-37625)
120+
121+
## Version 0.6.4 [2021-08-05]
122+
123+
### Fixes
124+
125+
- Fixes [CVE-2021-37625](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-37625) (backport)
119126

120127
## Version 0.6.3 [2021-06-27]
121128

server/src/dbnet/macros.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Created on Thu Aug 05 2021
3+
*
4+
* This file is a part of Skytable
5+
* Skytable (formerly known as TerrabaseDB or Skybase) is a free and open-source
6+
* NoSQL database written by Sayan Nandan ("the Author") with the
7+
* vision to provide flexibility in data modelling without compromising
8+
* on performance, queryability or scalability.
9+
*
10+
* Copyright (c) 2021, Sayan Nandan <ohsayan@outlook.com>
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as published by
14+
* the Free Software Foundation, either version 3 of the License, or
15+
* (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
macro_rules! skip_loop_err {
28+
($expr:expr) => {
29+
match $expr {
30+
Ok(ret) => ret,
31+
Err(_) => continue,
32+
}
33+
};
34+
}

server/src/dbnet/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ use tokio::net::TcpListener;
5252
use tokio::sync::Semaphore;
5353
use tokio::sync::{broadcast, mpsc};
5454
pub mod connection;
55+
#[macro_use]
56+
mod macros;
5557
mod tcp;
5658
mod tls;
5759

server/src/dbnet/tcp.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,15 @@ impl Listener {
103103
// Take the permit first, but we won't use it right now
104104
// that's why we will forget it
105105
self.base.climit.acquire().await.unwrap().forget();
106-
let stream = self.accept().await?;
106+
/*
107+
SECURITY: Ignore any errors that may arise in the accept
108+
loop. If we apply the try operator here, we will immediately
109+
terminate the run loop causing the entire server to go down.
110+
Also, do not log any errors because many connection errors
111+
can arise and it will flood the log and might also result
112+
in a crash
113+
*/
114+
let stream = skip_loop_err!(self.accept().await);
107115
let mut chandle = ConnectionHandler::new(
108116
self.base.db.clone(),
109117
Connection::new(stream),

server/src/dbnet/tls.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,15 @@ impl SslListener {
114114
// Take the permit first, but we won't use it right now
115115
// that's why we will forget it
116116
self.base.climit.acquire().await.unwrap().forget();
117-
let stream = self.accept().await?;
117+
/*
118+
SECURITY: Ignore any errors that may arise in the accept
119+
loop. If we apply the try operator here, we will immediately
120+
terminate the run loop causing the entire server to go down.
121+
Also, do not log any errors because many connection errors
122+
can arise and it will flood the log and might also result
123+
in a crash
124+
*/
125+
let stream = skip_loop_err!(self.accept().await);
118126
let mut sslhandle = ConnectionHandler::new(
119127
self.base.db.clone(),
120128
Connection::new(stream),
@@ -123,6 +131,7 @@ impl SslListener {
123131
self.base.terminate_tx.clone(),
124132
);
125133
tokio::spawn(async move {
134+
log::debug!("Spawned listener task");
126135
if let Err(e) = sslhandle.run().await {
127136
log::error!("Error: {}", e);
128137
}

0 commit comments

Comments
 (0)