A recent Medium article criticized 3 of the 7 rust http clients it reviewed because of their dependency on this crate and because of this crate's use of unsafe. The criticism does not appear to be founded (i.e. it claims that HeaderMap is a reimplementation of HashMap without explaining how to use HashMap as a multimap) and the author's tests of these 3 http clients did not show any exploitable problems related to this crate. The article appears to an example of withoutboats' post about allegations of vulnerabilities in Rust libraries.
Despite the limitations of the Medium article, http is (and is designed to be) a high-level dependency of many network exposed crates so the sound use of unsafe is important. The use of unsafe has already been audited (see for example rust-secure-code/safety-dance#37). In my preliminary review of the use of unsafe I found that they were sound (with one possible exception I am still investigating). The soundness, though, relies on implicit invariants that, in some instance, are not local to the use of unsafe.
I propose to try to increase the robustness (in the sense described here) of the use of unsafe in http by:
- Adding unit tests for edge condition involving
unsafe code paths
- Refactoring the code involving
unsafe into smaller leaf modules that present a safe wrapper around the unsafe code (without introducing performance regressions)
- Documenting the invariants that make the use of
unsafe sound (making explicit what is implicit)
- Adding additional performance tests for uses-no-unsafe alternatives to
HeaderMap (such as multimap) so that the performance trade-offs of the current implantation are more easily apparent
The goal isn't to reduce or eliminate the use of unsafe (though a reduction in in the number of uses of unsafe may be a by-product). It is rather to make the soundness of the use of unsafe easier for someone else to audit.
I plan to review the use of unsafe file by file as follows (the number in parenthesis is the number of occurrences of unsafe in the file):
I have already completed the work for the first two files in #408 and #410. I am planning to continue with the three uri/* files and then the header/* files as time allows. If the maintainers of the project don't think this is worthwhile please let me know so I can move on to something else.
A recent Medium article criticized 3 of the 7 rust http clients it reviewed because of their dependency on this crate and because of this crate's use of
unsafe. The criticism does not appear to be founded (i.e. it claims thatHeaderMapis a reimplementation ofHashMapwithout explaining how to useHashMapas a multimap) and the author's tests of these 3 http clients did not show any exploitable problems related to this crate. The article appears to an example of withoutboats' post about allegations of vulnerabilities in Rust libraries.Despite the limitations of the Medium article,
httpis (and is designed to be) a high-level dependency of many network exposed crates so the sound use ofunsafeis important. The use ofunsafehas already been audited (see for example rust-secure-code/safety-dance#37). In my preliminary review of the use ofunsafeI found that they were sound (with one possible exception I am still investigating). The soundness, though, relies on implicit invariants that, in some instance, are not local to the use ofunsafe.I propose to try to increase the robustness (in the sense described here) of the use of
unsafeinhttpby:unsafecode pathsunsafeinto smaller leaf modules that present a safe wrapper around the unsafe code (without introducing performance regressions)unsafesound (making explicit what is implicit)HeaderMap(such as multimap) so that the performance trade-offs of the current implantation are more easily apparentThe goal isn't to reduce or eliminate the use of
unsafe(though a reduction in in the number of uses ofunsafemay be a by-product). It is rather to make the soundness of the use ofunsafeeasier for someone else to audit.I plan to review the use of
unsafefile by file as follows (the number in parenthesis is the number of occurrences ofunsafein the file):I have already completed the work for the first two files in #408 and #410. I am planning to continue with the three uri/* files and then the header/* files as time allows. If the maintainers of the project don't think this is worthwhile please let me know so I can move on to something else.