Mercurial > dropbear
annotate fuzz/fuzz-harness.c @ 1790:42745af83b7d
Introduce extra delay before closing unauthenticated sessions
To make it harder for attackers, introduce a delay to keep an
unauthenticated session open a bit longer, thus blocking a connection
slot until after the delay.
Without this, while there is a limit on the amount of attempts an attacker
can make at the same time (MAX_UNAUTH_PER_IP), the time taken by dropbear to
handle one attempt is still short and thus for each of the allowed parallel
attempts many attempts can be chained one after the other. The attempt rate
is then:
"MAX_UNAUTH_PER_IP / <process time of one attempt>".
With the delay, this rate becomes:
"MAX_UNAUTH_PER_IP / UNAUTH_CLOSE_DELAY".
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Wed, 15 Feb 2017 13:53:04 +0100 |
parents | 8179eabe16c9 |
children | fd00aeff38fd |
rev | line source |
---|---|
1348 | 1 #include "includes.h" |
1354 | 2 #include "buffer.h" |
3 #include "dbutil.h" | |
1348 | 4 |
5 extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size); | |
6 | |
7 int main(int argc, char ** argv) { | |
1354 | 8 int i; |
9 buffer *input = buf_new(100000); | |
10 | |
1363 | 11 for (i = 1; i < argc; i++) { |
12 #if DEBUG_TRACE | |
13 if (strcmp(argv[i], "-v") == 0) { | |
14 debug_trace = 1; | |
1373
9891bc31a1b3
fuzzers disable logging by default
Matt Johnston <matt@ucc.asn.au>
parents:
1363
diff
changeset
|
15 TRACE(("debug printing on")) |
1363 | 16 } |
1357 | 17 #endif |
1363 | 18 } |
1357 | 19 |
1605
bff41a61a1b6
Disable wrapfds outside of fuzzed code
Matt Johnston <matt@ucc.asn.au>
parents:
1589
diff
changeset
|
20 int old_fuzz_wrapfds = 0; |
1354 | 21 for (i = 1; i < argc; i++) { |
1363 | 22 if (argv[i][0] == '-') { |
1559
92c93b4a3646
Fix to be able to compile normal(ish) binaries with --enable-fuzz
Matt Johnston <matt@ucc.asn.au>
parents:
1373
diff
changeset
|
23 /* ignore arguments */ |
1363 | 24 continue; |
25 } | |
26 | |
1354 | 27 char* fn = argv[i]; |
28 buf_setlen(input, 0); | |
29 buf_readfile(input, fn); | |
30 buf_setpos(input, 0); | |
31 | |
1741
d1b279aa5ed1
Get client fuzzer building and starting (fails straight away)
Matt Johnston <matt@ucc.asn.au>
parents:
1740
diff
changeset
|
32 /* Run twice to catch problems with statefulness */ |
1605
bff41a61a1b6
Disable wrapfds outside of fuzzed code
Matt Johnston <matt@ucc.asn.au>
parents:
1589
diff
changeset
|
33 fuzz.wrapfds = old_fuzz_wrapfds; |
1358
6b89eb92f872
glaring wrapfd problems fixed
Matt Johnston <matt@ucc.asn.au>
parents:
1357
diff
changeset
|
34 printf("Running %s once \n", fn); |
6b89eb92f872
glaring wrapfd problems fixed
Matt Johnston <matt@ucc.asn.au>
parents:
1357
diff
changeset
|
35 LLVMFuzzerTestOneInput(input->data, input->len); |
6b89eb92f872
glaring wrapfd problems fixed
Matt Johnston <matt@ucc.asn.au>
parents:
1357
diff
changeset
|
36 printf("Running %s twice \n", fn); |
1354 | 37 LLVMFuzzerTestOneInput(input->data, input->len); |
38 printf("Done %s\n", fn); | |
1605
bff41a61a1b6
Disable wrapfds outside of fuzzed code
Matt Johnston <matt@ucc.asn.au>
parents:
1589
diff
changeset
|
39 |
bff41a61a1b6
Disable wrapfds outside of fuzzed code
Matt Johnston <matt@ucc.asn.au>
parents:
1589
diff
changeset
|
40 /* Disable wrapfd so it won't interfere with buf_readfile() above */ |
bff41a61a1b6
Disable wrapfds outside of fuzzed code
Matt Johnston <matt@ucc.asn.au>
parents:
1589
diff
changeset
|
41 old_fuzz_wrapfds = fuzz.wrapfds; |
bff41a61a1b6
Disable wrapfds outside of fuzzed code
Matt Johnston <matt@ucc.asn.au>
parents:
1589
diff
changeset
|
42 fuzz.wrapfds = 0; |
1354 | 43 } |
44 | |
45 printf("Finished\n"); | |
46 | |
1348 | 47 return 0; |
48 } | |
1760
2406a9987810
Add first try at fuzzing custom mutator
Matt Johnston <matt@ucc.asn.au>
parents:
1756
diff
changeset
|
49 |
1775
8179eabe16c9
fuzzing - fix some wrong types and -lcrypt on macos
Matt Johnston <matt@ucc.asn.au>
parents:
1760
diff
changeset
|
50 // Just to let it link |
8179eabe16c9
fuzzing - fix some wrong types and -lcrypt on macos
Matt Johnston <matt@ucc.asn.au>
parents:
1760
diff
changeset
|
51 size_t LLVMFuzzerMutate(uint8_t *UNUSED(Data), size_t UNUSED(Size), size_t UNUSED(MaxSize)) { |
1760
2406a9987810
Add first try at fuzzing custom mutator
Matt Johnston <matt@ucc.asn.au>
parents:
1756
diff
changeset
|
52 printf("standalone fuzzer harness shouldn't call LLVMFuzzerMutate"); |
2406a9987810
Add first try at fuzzing custom mutator
Matt Johnston <matt@ucc.asn.au>
parents:
1756
diff
changeset
|
53 abort(); |
2406a9987810
Add first try at fuzzing custom mutator
Matt Johnston <matt@ucc.asn.au>
parents:
1756
diff
changeset
|
54 return 0; |
2406a9987810
Add first try at fuzzing custom mutator
Matt Johnston <matt@ucc.asn.au>
parents:
1756
diff
changeset
|
55 } |