From 365c5ba39591fab2e60bf4f0e67d9dcf79ecc506 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 24 Jun 2013 22:24:35 +0200 Subject: formpost: better random boundaries When doing multi-part formposts, libcurl used a pseudo-random value that was seeded with time(). This turns out to be bad for users who formpost data that is provided with users who then can guess how the boundary string will look like and then they can forge a different formpost part and trick the receiver. My advice to such implementors is (still even after this change) to not rely on the boundary strings being cryptographically strong. Fix your code and logic to not depend on them that much! I moved the Curl_rand() function into the sslgen.c source file now to be able to take advantage of the SSL library's random function if it provides one. If not, try to use the RANDOM_FILE for seeding and as a last resort keep the old logic, just modified to also add microseconds which makes it harder to properly guess the exact seed. The formboundary() function in formdata.c is now using 64 bit entropy for the boundary and therefore the string of dashes was reduced by 4 letters and there are 16 hex digits following it. The total length is thus still the same. Bug: http://curl.haxx.se/bug/view.cgi?id=1251 Reported-by: "Floris" --- tests/data/test587 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/data/test587') diff --git a/tests/data/test587 b/tests/data/test587 index 6e1239a6a..d936372c5 100644 --- a/tests/data/test587 +++ b/tests/data/test587 @@ -28,8 +28,8 @@ http://%HOSTIP:%HTTPPORT/587 # Verify data after the test has been "shot" -s/^------------------------------[a-z0-9]*/------------------------------/ -s/boundary=----------------------------[a-z0-9]*/boundary=----------------------------/ +s/^--------------------------[a-z0-9]*/------------------------------/ +s/boundary=------------------------[a-z0-9]*/boundary=----------------------------/ POST /587 HTTP/1.1 -- cgit v1.2.3