TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Watch out for DoS when using Rust’s Hyper package

53 pointsby simjueover 2 years ago

11 comments

seeekrover 2 years ago
I&#x27;m confused by the fact that there&#x27;s no mention of interaction with the Hyper project&#x27;s authors. I&#x27;m fairly certain that Sean &amp; contributors will want to address the underlying issue, if they haven&#x27;t already done so (clearly they were describing the potential for misusing the Hyper API very directly in the docs!), and pointing that out and clearly stating when and how that has been or will be addressed would shine a much more positive light on everyone, including the security researchers.<p>I see that there&#x27;s an 1.0 RC release and the offending API seems to have changed and is probably not amenable to this type of misuse any more. The article authors could have easily added some info about that -- I certainly would have appreciated not having to go looking for that myself.
评论 #34286815 未加载
keyboredover 2 years ago
&gt; single Bytes buffer, for example the following unsafe usage<p>Highlighting “unsafe” in red in an article about a Rust package when talking about something which is not Unsafe is so cursed.
评论 #34286889 未加载
评论 #34286946 未加载
lovasoaover 2 years ago
Maybe there shouldn&#x27;t be a<p><pre><code> to_bytes(body) -&gt; Bytes </code></pre> function at all ?<p>Only a<p><pre><code> to_bytes(body: B, max_size: Option&lt;usize&gt;) </code></pre> This way if someone REALLY wants the behavior that potentially results in a crash, they still have access to it, but have to be really explicit about it.
jedisct1over 2 years ago
Rouille, another Rust HTTP server, can also trivially be DOS&#x27;d by sending a Content-Length that doesn&#x27;t match the actual content length.<p>But HTTP implementations like these are not really meant to directly face the internet. They usually sit behind reverse proxies&#x2F;API gateways&#x2F;CDNs.
jayjaderover 2 years ago
Good to see public sharing not only of such a problem, but also how to fix it in your own code.<p>I am a bit disconcerted that something that apparently is warned against in the docs, is done across several &quot;big&quot; packages that use Hyper. Maybe with a more appropriate name exposed by the library, for example `to_bytes_unchecked`, such &quot;bad&quot; uses would be less wide-spread.
sbt567over 2 years ago
Seemingly related PR <a href="https:&#x2F;&#x2F;github.com&#x2F;hyperium&#x2F;hyper&#x2F;pull&#x2F;3046">https:&#x2F;&#x2F;github.com&#x2F;hyperium&#x2F;hyper&#x2F;pull&#x2F;3046</a>
评论 #34287924 未加载
qprofyehover 2 years ago
I assume most production environments will run a reverse proxy like nginx which have sensible defaults. Good find nonetheless. Should be patched by Hyper.
curling_gradover 2 years ago
Will falliable allocations help eliminate these kinds of DoS vulnerabilities?<p>AFAIK there&#x27;s a proposal: <a href="https:&#x2F;&#x2F;rust-lang.github.io&#x2F;rfcs&#x2F;2116-alloc-me-maybe.html" rel="nofollow">https:&#x2F;&#x2F;rust-lang.github.io&#x2F;rfcs&#x2F;2116-alloc-me-maybe.html</a>
评论 #34294785 未加载
habiburover 2 years ago
Another relatively safe strategy : Don&#x27;t buffer http data on server. Read a limited sized header and then stream the body to its request handler.
评论 #34287035 未加载
评论 #34287216 未加载
throwaway67743over 2 years ago
Recently on HN: nothing can ever happen in rust it&#x27;s impossible to write bad code
baqover 2 years ago
What&#x27;s interesting to me is we&#x27;ve known about these class of API misdesign issues since gets(3)... sometimes convenient and ergonomic is really not the right way to do it.
评论 #34287290 未加载