255 Commits

Author SHA1 Message Date
Michael Rash
837f7780fe [libfko] validate MAX_PORT integer value for SPA messages 2014-10-25 08:42:14 -04:00
Michael Rash
71b97b6cad bumped libfko version to 2.0.3 2014-07-28 21:46:32 -04:00
Michael Rash
4878607254 [libfko] removed fko_new_strdup() fault injection tag since fko_destroy() isn't called 2014-06-16 17:11:52 -04:00
Michael Rash
34f7ebd082 [test suite] added strtol_wrapper() fault injection tags 2014-06-15 09:41:43 -04:00
Michael Rash
42a20616b4 [libfko] additional fault injection additions with test suite support 2014-06-14 21:27:18 -04:00
Michael Rash
c00a3e7b26 [test suite] additional fault injection tests 2014-06-12 20:29:54 -04:00
Michael Rash
06ce514111 [test suite] add several fault injection tests 2014-06-12 00:02:18 -04:00
Michael Rash
410624a858 [libfko] free() temp buffer right after strdup() call, add libfiu fault injection tags 2014-06-12 00:00:40 -04:00
Michael Rash
ffde9c3f1a [libfko] bug fix to check strdup() return value
Using the 'fiu-run' fault injection binary, a couple of cases were
turned up with libfko does not properly check the strdup() return value.
This commit fixes these issues, and here is an illustration of the stack
trace for one such issue:

  Core was generated by `../client/.libs/fwknop -A tcp/22 -a 127.0.0.2 -D
  127.0.0.1 --get-key local_spa.'.
  Program terminated with signal 11, Segmentation fault.
  #0  __strnlen_sse2 () at ../sysdeps/x86_64/multiarch/../strnlen.S:34
  34      ../sysdeps/x86_64/multiarch/../strnlen.S: No such file or directory.
  (gdb) where
  #0  __strnlen_sse2 () at ../sysdeps/x86_64/multiarch/../strnlen.S:34
  #1  0x00007effa38189bc in _rijndael_encrypt (enc_key_len=<optimized out>, enc_key=<optimized out>, ctx=0x7effa5945750) at fko_encryption.c:141
  #2  fko_encrypt_spa_data (ctx=0x7effa5945750, enc_key=<optimized out>, enc_key_len=<optimized out>) at fko_encryption.c:605
  #3  0x00007effa381a2d6 in fko_spa_data_final (ctx=0x7effa5945750, enc_key=enc_key@entry=0x7fff3ff4aa10 "fwknoptest", enc_key_len=<optimized out>, hmac_key=hmac_key@entry=0x7fff3ff4aaa0 "", hmac_key_len=0) at fko_funcs.c:489
  #4  0x00007effa405f2fb in main (argc=<optimized out>, argv=<optimized out>) at fwknop.c:449
2014-06-08 23:09:55 -04:00
Michael Rash
82b05b9530 [libfko] fko_new() bug fix to not leak memory under fko_set_... error conditions
This commit changes how fko_new() deals with FKO context initialization
to not set ctx->initval back to zero (uninitialized) imediately after
calling each fko_set_... function and before checking the fko_set_... return
value.  The reason for this change is that fko_destroy() checks for
context initialization via ctx->initval before calling free() against
any heap allocated context member. So, if fko_set_... returns an error,
fko_destroy() (previous to this commit) would have no opportunity to
free such members.

This bug was found with fault injection testing provided by libfiu
together with valgrind. Specifically the following test suite command
exposes the problem (from the test/ directory):

./test-fwknop.pl --enable-complete --include "fault injection.*libfko"

In the resulting output/2.test file valgrind reports the following:

==27941== LEAK SUMMARY:
==27941==    definitely lost: 264 bytes in 1 blocks
==27941==    indirectly lost: 28 bytes in 3 blocks
==27941==      possibly lost: 0 bytes in 0 blocks
==27941==    still reachable: 1,099 bytes in 12 blocks
==27941==         suppressed: 0 bytes in 0 blocks

After this commit is applied, this changes to:

==7137== LEAK SUMMARY:
==7137==    definitely lost: 0 bytes in 0 blocks
==7137==    indirectly lost: 0 bytes in 0 blocks
==7137==      possibly lost: 0 bytes in 0 blocks
==7137==    still reachable: 1,099 bytes in 12 blocks
==7137==         suppressed: 0 bytes in 0 blocks

Note that 'definitely lost' in valgrind output means there is a real
memory leak that needs to be fixed whereas 'still reachable' is most
likely not a real problem according to:

http://valgrind.org/docs/manual/faq.html#faq.deflost
2014-06-06 21:28:28 -04:00
Michael Rash
6d1d66fe03 add --fault-injection-tag support to the client/server/libfko
This is a significant commit to add the ability to leverage libfko fault
injections from both the fwknop client and server command lines via a
new option '--fault-injection-tag <tag name>'.  This option is used by
the test suite with the tests/fault_injection.pl tests.
2014-06-05 23:05:49 -04:00
Michael Rash
ddaf0134d6 use fiu.h instead of fiu-local.h 2014-05-26 15:54:12 -04:00
Michael Rash
597a3d3953 [libfko] added fault injections for remaining ...set...() functions called by fko_new() 2014-05-24 15:12:07 -04:00
Michael Rash
5f227cfa48 [libfko] added fault injections for fko_set_username() 2014-05-24 14:47:10 -04:00
Michael Rash
17f325eceb [libfko] added fault injections for fko_set_rand_value() 2014-05-24 14:01:49 -04:00
Michael Rash
35ad832392 [libfko] started on libfiu fault injection code 2014-05-24 10:14:28 -04:00
Michael Rash
40e14fc400 Merge branch 'spa_encoding_fuzzing' 2014-04-28 23:00:16 -04:00
Michael Rash
7442002a89 [libfko] bumped version to 2.0.2 2014-04-28 21:08:27 -04:00
Michael Rash
add2c913ab [libfko] fix double free bug in SPA parser
This commit fixes a double free condition discovered through the new
python SPA payload fuzzer.  This bug could be triggered in fwknopd with
a malicious SPA payload but only when GnuPG is used.  When Rijndael is
used for SPA packet encryption, this bug cannot be triggered due to an
length/format check towards the end of _rijndael_decrypt().  It should
be noted that only a person in possession of the correct encryption and
authentication GnuPG keys could trigger this bug.
2014-04-26 23:26:36 -04:00
Michael Rash
9901d8a76a [libfko/test suite] add the FUZZING_INTERFACES macro
Add a new fko_set_encoded_data() function gated by #define
FUZZING_INTERFACES to allow encryption and authentication to be bypassed
for fuzzing purposes (and only fuzzing purposes).  The fko-wrapper code
has been extended to process data in the
test/fko-wrapper/fuzz_spa_payloads file, which is created by the new
python fuzzer.  Typical workflow is:

$ cd test/fko-wrapper
$ ../spa_fuzzer.py > fuzz_spa_payloads
$ make fuzzing

(as root):

./test-fwknop.pl  --enable-profile-coverage --enable-fuzzing-interfaces --enable-all --include wrapper

[+] Starting the fwknop test suite...

    args: --enable-profile-coverage --enable-fuzzing-interfaces --enable-all --include wrapper

    Saved results from previous run to: output.last/

    Valgrind mode enabled, will import previous coverage from:
        output.last/valgrind-coverage/

[+] Total test buckets to execute: 2

[Rijndael] [fko-wrapper] multiple libfko calls (with valgrind)......pass (1)
[Rijndael] [fko-wrapper] multiple libfko calls......................pass (2)
[profile coverage] gcov profile coverage............................pass (3)
[valgrind output] [flagged functions] ..............................pass (4)

    Run time: 5.85 minutes

[+] 0/0/0 OpenSSL tests passed/failed/executed
[+] 0/0/0 OpenSSL HMAC tests passed/failed/executed
[+] 4/0/4 test buckets passed/failed/executed
2014-04-26 23:04:44 -04:00
Michael Rash
b28b8b5de1 [libfko] fix double free bug in SPA parser
This commit fixes a double free condition discovered through the new
python SPA payload fuzzer.  This bug could be triggered in fwknopd with
a malicious SPA payload but only when GnuPG is used.  When Rijndael is
used for SPA packet encryption, this bug cannot be triggered due to an
length/format check towards the end of _rijndael_decrypt().  It should
be noted that only a person in possession of the correct encryption and
authentication GnuPG keys could trigger this bug.
2014-04-22 21:58:09 -04:00
Michael Rash
f4a8c0fda8 [libfko] for fuzzing purposes, added fko_set_encoded_data() to bypass encryption and authentication for SPA payloads 2014-04-18 21:39:54 -04:00
Michael Rash
ac6ffe2ec7 [server] Validate GPG sigs with libfko fko_gpg_signature_id_match() function 2014-04-09 23:56:03 -04:00
Michael Rash
2e4eea8d49 [libfko] minor formating update for strtol_wrapper() range output messages 2014-04-08 21:08:24 -04:00
Michael Rash
5752433420 [libfko] minor comment re-wording 2014-04-08 21:06:45 -04:00
Michael Rash
0b6a407392 [libfko] remove unused digest *_End(), *_Data(), and *_hex() functions in favor of better test coverage (always can be reinstantiated if needed) 2014-04-04 22:54:38 -04:00
Michael Rash
f9885d0657 [libfko] add GPG sig status to fko dump context function 2014-04-04 22:50:41 -04:00
Michael Rash
6b87710397 [libfko] fix memory leak in fko_encode_spa_data() caught by Coverity 2014-03-27 21:21:17 -04:00
Michael Rash
41f12eba81 [libfko] Memory leak bug fix in GnuPG handling
Bug fix to correct a memory leak in GnuPG SPA packet handling within
the gpg_decrypt() function.  Here is the specific valgrind leak record
that enabled the bug to be found (note that the new valgrind
suppressions usage was critical for finding this bug among all other
libgpgme memory leaks):

==23983== 1,044 bytes in 1 blocks are definitely lost in loss record 7 of 8
==23983==    at 0x4C2C494: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==23983==    by 0x4E41D3A: gpg_decrypt (fko_encryption.c:422)
==23983==    by 0x4E42520: fko_decrypt_spa_data (fko_encryption.c:626)
==23983==    by 0x1155B0: incoming_spa (incoming_spa.c:519)
==23983==    by 0x1180A7: process_packet (process_packet.c:211)
==23983==    by 0x506D857: ??? (in /usr/lib/x86_64-linux-gnu/libpcap.so.1.4.0)
==23983==    by 0x117865: pcap_capture (pcap_capture.c:270)
==23983==    by 0x10F937: main (fwknopd.c:353)
2014-03-27 16:52:13 -04:00
Michael Rash
73bc473563 [client+server] verify GnuPG signatures by default
- [server] When GnuPG is used, the default now is to require that
incoming SPA packets are signed by a key listed in GPG_REMOTE_ID for each
access.conf stanza. In other words, the usage of GPG_REQUIRE_SIG
is no longer necessary in order to authenticate SPA packets via the
GnuPG signature. Verification of GnuPG signatures can be disabled with a
new access.conf variable GPG_DISABLE_SIG, but this is NOT a
recommended configuration.
- [client+server] Add --gpg-exe command line argument and GPG_EXE
config variable to ~/.fwknoprc and the access.conf file so that the path
to GnuPG can be changed from the default /usr/bin/gpg path.
2014-03-25 19:53:13 -04:00
Michael Rash
7e290245b2 [libfko] per-SPA message type field count validation
This commit implements more rigorous SPA packet field count validation
that takes into account expected field counts for each SPA message type.
Two new libfko error codes have been added in support of this, and the
corresponding changes made in the perl and python modules.
2014-03-16 21:47:19 -04:00
Michael Rash
6de811cbc6 [libfko] minor error constant label typo fix 2014-03-16 16:37:21 -04:00
Michael Rash
da09ba7300 [libfko] dedicated parsing functions for decoding client timeout and server auth SPA fields 2014-03-16 09:08:33 -04:00
Michael Rash
5baf8a3fa9 replace malloc() with calloc() calls 2014-03-15 22:02:57 -04:00
Michael Rash
2556433bba [libfko] add digest verification and length fcns to decode routine 2014-03-15 21:37:30 -04:00
Michael Rash
5fff8a7f4f Merge branch 'ms_compatible_usernames'
This merges in work on #114 to allow MS compatible usernames, and should
help Cygwin (and Windows) users.
2014-03-14 23:02:47 -04:00
Michael Rash
f5bb43927d Merge branch 'master' of https://github.com/mrash/fwknop 2014-03-14 22:57:53 -04:00
Michael Rash
0897bd54e1 [libfko] call SPA field parsers via function pointers in fko_decode_spa_data() 2014-03-14 22:57:36 -04:00
Michael Rash
2eff0c01aa [libfko] start on refactoring fko_decode_spa_data() to put SPA field parsing into dedicated functions 2014-03-14 21:11:25 -04:00
Michael Rash
9e990c9be0 fix header non-ascii chars, and introduce test suite support for detecting this in source files 2014-03-14 09:14:35 -04:00
Michael Rash
b5eb857533 [libfko] allow MS compatible usernames
Allow usernames that are compatible with Microsoft guidelines as defined
here:

http://technet.microsoft.com/en-us/library/bb726984.aspx

This allows for greater compatibility between fwknop clients on Windows
(for example that may be deployed with Cygwin) and fwknopd on other
systems.  This change was suggested by Gerry Reno, and tracked by Github
issue #114.
2014-03-09 23:12:53 -04:00
Michael Rash
bfdbb8f260 Updated authorship and copyright information
This commit updates all authorship and copyright information to include a
standard header that references the AUTHORS and CREDITS file. This standard
header was written by the Debian legal team at the request of Franck Joncourt.
2014-03-04 17:53:10 -05:00
Michael Rash
7bb5811651 [libfko] minor bug fix to not return GPG error codes from _rijndael_decrypt() 2014-02-02 20:32:02 -05:00
Damien Stuart
1e1729905e Bumped libfko and protocol versions to 2.0.1. Added dependencies for this version to the fwknop.spec file. 2014-01-11 10:58:01 -05:00
Michael Rash
3820b64394 [libfko] ensure a NULL HMAC key is properly handled 2014-01-01 19:45:38 -05:00
Michael Rash
227d0ab947 [libfko] ensure NULL is handled properly for all fko_get_* functions 2013-12-31 23:27:05 -05:00
Michael Rash
7aa6d37fff [libfko] added NULL check for fko_set_spa_data() data arg 2013-12-30 21:56:08 -05:00
Michael Rash
5022beaf12 [libfko] < 0 checks not needed for size_t vars which are unsigned 2013-12-30 21:09:27 -05:00
Michael Rash
297d7d00fe [libfko] enc key NULL checks with fko-wrapper test support 2013-12-29 22:44:16 -05:00
Michael Rash
0c6911941b [libfko] reject negative length values
Integer lengths that are negative are never valid.  This commit also
extends the fuzzing capabilities of the test/fko-wrapper code to
validate libfko calls with negative length arguments, and one crash
scenario with a negative length for the encryption key was found (and
fixed) this way.
2013-12-29 21:05:04 -05:00