You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memory Corruption in boost::network::uri::decode #501
Hi.
During some research on library, I have found, that vulnerability in function boost::network::uri::decode can be used in Denial Of Service attacks.
Issue exist when user pass to in_begin argument few "%" characters. It results in out-of-bound read from null pointer.
For example:
std::string foo;
boost::network::uri::decode("%%%%%%%%%%%%%%%%", back_inserter(foo));
if (_it == '%') {
++it; <= PTR+1
value_type v0 = detail::letter_to_hex(_it);
++it; <= PTR+1
value_type v1 = detail::letter_to_hex(*it);
++it; <= PTR+1
Okay, thanks @zeroinside -- do you have a fix, preferably with a test case that you can put in a pull request that I can merge (and release soon) against the 0.11-devel branch?
Sorry for my fault in path, it's incomplete, variable *it should be checked every time when pointer is incremented.
I think You should path it your own way.
I'm asking so that we can get proper history on the commits, and explicit granting of copyrights to you licensed under the Boost Software License. This is why I haven't looked at the patches you've put up in pastebin. 😄
If you can't do this for whatever reason, maybe @glynos can try and fix it? Or I can try if I get the time to do it, which is very scarce for me at the moment. 😦
Activity
deanberris commentedon Mar 3, 2015
In what version of the library are you seeing this @zeroinside? Thanks for reporting this BTW.
zeroinside commentedon Mar 3, 2015
Currently I'm using 0.11.0, but I've downloaded the 0.11.1 and boost::network::uri::decode is unchanged.
deanberris commentedon Mar 3, 2015
Okay, thanks @zeroinside -- do you have a fix, preferably with a test case that you can put in a pull request that I can merge (and release soon) against the 0.11-devel branch?
zeroinside commentedon Mar 3, 2015
Test Case:
#include
#include
#include <boost/network/uri.hpp>
#include <boost/network/uri/uri_io.hpp>
int main () {
std::string foo;
boost::network::uri::decode("%%%%%%%%%%%%%%%%", back_inserter(foo));
return 0;
}
PATH:
/usr/local/include/boost/network/uri/decode.hpp
template <class InputIterator, class OutputIterator>
OutputIterator decode(const InputIterator &in_begin,
const InputIterator &in_end,
const OutputIterator &out_begin) {
typedef typename boost::iterator_value::type value_type;
InputIterator it = in_begin;
OutputIterator out = out_begin;
while (it != in_end) {
if(_it==NULL) // Check for the end of string
break;
if (_it == '%') {
++it;
value_type v0 = detail::letter_to_hex(_it);
++it;
value_type v1 = detail::letter_to_hex(_it);
++it;
_out++ = 0x10 * v0 + v1;
} else if (_it == '+') {
*out++ = ' ';
++it;
} else {
*out++ = *it++;
}
}
return out;
}
Please test the path, if it doesn't cause a regression.
zeroinside commentedon Mar 3, 2015
Sorry, github removes some special chars, like *.
Pathed function is available @ http://pastebin.com/z6BCq6NK
zeroinside commentedon Mar 3, 2015
And a test-case.
http://pastebin.com/9LjUHD10
zeroinside commentedon Mar 3, 2015
Sorry for my fault in path, it's incomplete, variable *it should be checked every time when pointer is incremented.
I think You should path it your own way.
deanberris commentedon Mar 4, 2015
Can you put these in a pull request please @zeroinside?
zeroinside commentedon Mar 4, 2015
I'm a newbie on github:), please do it yourself.
griwes commentedon Mar 4, 2015
s/path/patch/FTFYdeanberris commentedon Mar 4, 2015
So, you can give this a try: http://cpp-netlib.org/process.html
I'm asking so that we can get proper history on the commits, and explicit granting of copyrights to you licensed under the Boost Software License. This is why I haven't looked at the patches you've put up in pastebin. 😄
If you can't do this for whatever reason, maybe @glynos can try and fix it? Or I can try if I get the time to do it, which is very scarce for me at the moment. 😦
deanberris commentedon Sep 11, 2015
This looks like a serious issue that warrants a proper pull request to fix. Any takers?
susnux commentedon Apr 8, 2016
I think this can be closed, it is fixed since 0.12-RC2 with commit: be97dfe
(Pull request #553 )
(Except you want also a fix for the 0.11 branch)
glynos commentedon Apr 8, 2016
We don't intend to apply any new fixes on 0.11 any more.