News for hackers. Stuff that matters.
Re:The Serde Rust Framework by xet7 on Thursday October 14, 2021 @06:06PM (#28870820)
Is there any Rust web framework that does not have problem with Slow-Loris ?

https://github.com/SergioBenitez/Rocket/issues/1405

Re:The Serde Rust Framework by pornel on Thursday October 14, 2021 @06:28PM (#28871037)
Because of the way Rust's async works, you can put a timeout on anything (e.g. you don't need your http parser support timeouts, you can kill it at any await point). So it's only a matter of choosing timeout policy for your app. One person's DoS attack is another person's long polling API.

Anyway, it has nothing to do with Serde, which doesn't have a network component. For Serde you'd typically buffer the input first, or use external framing (like line-oriented JSON).

Re:The Serde Rust Framework by the_duke on Thursday October 14, 2021 @06:43PM (#28871193)
None of the current Rust async frameworks will prevent your synchronous code from going haywire.

Tokio or async-std timeouts only cancel futures. The dedicated spawn_blocking threadpools also do not support cancellation.

To prevent such cases you would have to spawn the work into a dedicated thread pool and then kill the thread on timeout.

Terminating threads is a very complicated topic though and not generally possible for compiled languages, especially without introducing memory unsafety.

The only real workaround is to have the synchronous code regularly check for cancellation via an atomic bool or similar, and terminate if required.

Re:The Serde Rust Framework by pornel on Thursday October 14, 2021 @07:14PM (#28871494)
Slow loris is I/O based, so it’s easy to abort. The rest will follow from that. Even if you piped your request stream into synchronous blocking io::Read adapter for use with Serde (which IMHO is pointless), the adapter will see an error due to its channel dropping, and bail out immediately.

Native busy-looping or deadlocked threads are tricky to kill safely, but that’s a general problem with threads in non-interpreted languages. Not specific to Serde, not related to Slow loris.

Re:The Serde Rust Framework by orf on Thursday October 14, 2021 @10:05PM (#28873216)
If you’re blocking on IO that’s you’re cancellation signal. You can of course close the pipe you’re reading from which surfaces an error in your synchronous thread.
Re:The Serde Rust Framework by dbrgn on Thursday October 14, 2021 @06:45PM (#28871212)
How is that related to serde?
Re:The Serde Rust Framework by _xyub on Thursday October 14, 2021 @10:36PM (#28873486)
I thought I'd share this project in case anyone wanted to quickly evaluate rust for web

https://github.com/wulf/create-rust-app

Although there's a lot of work left to be done, I'd love to hear feedback, painpoints and ideas you have :)

Hoping to have documentation up at create-rust-app.dev soon~

Re:The Serde Rust Framework by option_greek on Thursday October 14, 2021 @11:54PM (#28874063)
Please consider giving warp as choice for the web server.
Re:The Serde Rust Framework by Wulf_ on Friday October 15, 2021 @12:57AM (#28874456)
Any particular reason?
Re:The Serde Rust Framework by option_greek on Friday October 15, 2021 @02:22AM (#28874903)
Its more light weight and usually doesn't enforce any particular way of doing things. Regardless of warp support, I have most of the other things on your list integrated one by one (JWT/dashboards /react/diesel) but it was time consuming as I didn't have a quick start project template.

So I think the work you are doing is going to be valuable for the community. I guess giving an option between the three popular web frameworks (actix, warp, rocket) won't be so easy as you might have very different way of integrating the authentication etc with each. Probably one way to do this is to keep things more modular so that the authentication can be called independently (among other features).

Re:The Serde Rust Framework by ttymck on Thursday October 14, 2021 @06:09PM (#28870855)
This is interesting, and news to me. Your comment suggests something about Rust imposes this problem on all web frameworks, is that true? If so could you share the root cause?
Re:The Serde Rust Framework by xet7 on Thursday October 14, 2021 @06:17PM (#28870930)
I'm just newbie in Rust. Does some web framework not use hyper? I'm trying to find web framework that does not have problem with Slow-Loris.
Re:The Serde Rust Framework by fwip on Thursday October 14, 2021 @07:46PM (#28871831)
This doesn't solve your problem out of the box, but I think most reverse-proxies have configurations that can protect the services behind them from these sorts of attacks.
Re:The Serde Rust Framework by Ericson2314 on Thursday October 14, 2021 @06:24PM (#28871003)
I don't think anyone will want to avoid hyper, tbh, that's a lot of work to hand-roll instead. so you better advertise the issue there instead, and if they refuse to do anything about it then make a big stink downstream.
Re:The Serde Rust Framework by eptcyka on Thursday October 14, 2021 @06:29PM (#28871051)
I think this should be fixed in hyper.