]> git.ipfire.org Git - thirdparty/curl.git/commit
formpost: better random boundaries
authorDaniel Stenberg <daniel@haxx.se>
Mon, 24 Jun 2013 20:24:35 +0000 (22:24 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 25 Jun 2013 07:55:49 +0000 (09:55 +0200)
commit365c5ba39591fab2e60bf4f0e67d9dcf79ecc506
tree6e02f6904f12fcd94b1036643bc5064c809e807b
parentcb1aa8b0e32068ec4bbbc42d41267420b46a36e7
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"
16 files changed:
lib/Makefile.inc
lib/curl_darwinssl.h
lib/curl_rand.c [deleted file]
lib/curl_rand.h [deleted file]
lib/curl_sasl.c
lib/easy.c
lib/formdata.c
lib/gtls.h
lib/nssg.h
lib/sslgen.c
lib/sslgen.h
lib/ssluse.h
tests/data/test158
tests/data/test277
tests/data/test554
tests/data/test587