92 Commits

Author SHA1 Message Date
Franck Joncourt
7296d3f3bf * Interim commit to add a dump function to dump the FKO context shared
by both the server and client. mrash/fwknop#95
2013-08-05 23:28:07 +02:00
Michael Rash
24c4c5e208 continued zeroing out of sensitive data buffers in support of issue #93 2013-07-08 23:00:18 -04:00
Franck Joncourt
c2e1a00154 s/GNU Public/GNU General Public/g 2013-06-30 22:21:22 +02:00
Michael Rash
68acbaadc4 remove newline chars from log_msg() calls 2013-06-19 23:42:58 -04:00
Franck Joncourt
b48295c69b Interim commit to make the log_msg strategy.
* log_msg : New log_set_verbosity(): It sets the default verbosity for the
    log module according to the verbose option set by the user through the command
    line.
  * Remove useless checks of the verbose option when log_msg() is invoked.
2013-06-16 19:12:06 +02:00
Michael Rash
382099e85a Updated copyright dates, removed NEWS file in favor of the ChangeLog 2013-06-02 14:07:01 -04:00
Michael Rash
54872acfc3 Convert strncmp() calls to constant_runtime_cmp() at various places
This commit is a follow up to Ryman's report (#85) of a potential timing attack
that could be leveraged against fwknop when strncmp() is used to compare HMAC
digests.  All strncmp() calls that do similar things have been replaced with a
new constant_runtime_cmp() function that mitigates this problem.
2013-06-01 21:55:45 -04:00
Michael Rash
52462e7dba Use {0} initializer for all stack allocated char arrays
Lots of places in the code were already using {0} to initialize stack char
arrays, but memset() was being used as well.  This commit removes all
unnecessary memset() calls against char arrays that are already initialized
via {0} (which sets all members to zero for such arrays).
2013-05-21 22:00:15 -04:00
Michael Rash
fb80575209 [server] minor memory leak bug fix during SPA digest calculation found by Coverity 2013-05-13 20:52:14 -04:00
Michael Rash
d60870740d [server] fix pointer NULL check after strdup() - found by Coverity 2013-05-13 20:41:25 -04:00
Michael Rash
1caf6035d9 [server] fixed potential double-free condition found by Coverity
Within the access loop always call fko_destroy() right up front whenever
ctx != NULL to ensure a clean slate each time through the loop regardless of
what state may have been reached the previous time through the loop.
2013-05-12 20:54:44 -04:00
Michael Rash
50f0ee2f7d [server] bug fix for GPG 'nesting level does not match indentation' issue (discovered by Coverity) 2013-05-07 22:53:20 -04:00
Shawn Wilson
9dc1d26d6a fixed more typos 2013-05-01 10:59:48 -04:00
Shawn Wilson
e50d776ff7 correct variable name typo 2013-05-01 10:42:13 -04:00
Shawn Wilson
52e35b735d add ip address to messages where appropriate 2013-05-01 10:31:44 -04:00
Michael Rash
a6e8919728 [server] fix minor CLANG static analyzer bugs
These are simple logic fixes that would not have impacted run time to address
the following warnings generated by the CLANG static analyzer:

incoming_spa.c:433:17: warning: Value stored to 'attempted_decrypt' is never read
                attempted_decrypt = 1;
                ^                   ~
incoming_spa.c:647:13: warning: Value stored to 'acc' is never read
            acc = acc->next;
            ^     ~~~~~~~~~
2013-04-25 21:29:37 -04:00
Michael Rash
f02cc0ddd2 Added HMAC support to GPG encryption modes, closes #58 2013-04-22 20:45:59 -04:00
Michael Rash
7e784df387 [server] allow long Rijndael command messages
This change allows SPA clients to include long messages in command mode and
generally allows decryption operations to dictate success/failure instead of
SPA packet length to gate decryption attempts.  Closes #40.
2013-03-16 14:43:15 -04:00
Michael Rash
22dde8eb35 SPA with HMAC SHA256 and SHA384 now works
This is a fairly significant commit that lays the groundwork for getting
selectable HMAC modes working for both the client and server.  One libfko API
change was required so that the hmac_type is passed into fko_new_with_data().
This allows the server to set the hmac_type via access.conf stanzas.  The
effort in this commit will be extended to allow HMAC MD5, SHA1, and SHA512
also function properly.
2013-03-10 14:26:05 -04:00
Michael Rash
a413c6cf94 Continue atoi() replacement with strtol() wrapper, closes issue #21
This commit completes the conversion to the strtol() wrapper function in order
to remove all atoi() calls.  In addition, variable max values are enforced
using more broadly defined RCHK_* values.
2013-02-19 23:11:01 -05:00
Michael Rash
1afc8db96a Added strtol_wrapper() libfko utility function for atoi() replacement (#21)
This commit replaces most atoi() calls (which don't report errors) with a strtol()
wrapper function for stronger string -> integer conversion validation.
2013-02-18 19:32:53 -05:00
Michael Rash
47ea800889 merged in fwknop-2.0.4 changes 2013-01-18 17:25:16 -05:00
Michael Rash
66ad134708 [server] Added '--pcap-file <file>' option
Added a new '--pcap-file <file>' option to allow pcap files to
be processed directly by fwknopd instead of sniffing an interface.  This
feature is mostly intended for debugging purposes.
2012-11-08 21:33:23 -05:00
Michael Rash
5daaca01ea merged master 2.0.3 changes 2012-08-31 21:43:55 -04:00
Michael Rash
e8386dbe6c added encryption mode flags for each access stanza 2012-08-26 15:47:24 -04:00
Michael Rash
b0bf7f3699 minor paren's syntax bug fix 2012-08-18 16:30:34 -04:00
Michael Rash
6199180c69 minor paren's syntax bug fix 2012-08-18 16:29:08 -04:00
Michael Rash
8d6bc05295 merged from master 2012-08-17 21:19:52 -04:00
Michael Rash
66187a22af minor defensive fko_destroy() calls in two error condition blocks 2012-08-14 22:21:34 -04:00
Michael Rash
47795d41e2 merged from master 2012-08-10 22:30:07 -04:00
Michael Rash
27ccfe35d3 [server] Added GPG_ALLOW_NO_PW variable and associated test suite support
For GPG mode, added a new access.conf variable "GPG_ALLOW_NO_PW" to make it
possible to leverage a server-side GPG key pair that has no associated
password.  This comes in handy when a system requires the user to leverage
gpg-agent / pinentry which can present a problem in automated environments as
required by the fwknopd server.  Now, it might seem like a problem to remove
the passphrase from a GPG key pair, but it's important to note that simply
doing this is little worse than storing the passphrase in the clear on disk
anyway in the access.conf file.  Further, this link help provides additional
detail:

http://www.gnupg.org/faq/GnuPG-FAQ.html#how-can-i-use-gnupg-in-an-automated-environment
2012-08-10 22:20:30 -04:00
Michael Rash
1528697aaa merged replay prefix and IP resolve tests 2012-08-01 23:05:51 -04:00
Michael Rash
016098a254 Replay attack bug fix (encryption prefixes)
Ensure that an attacker cannot force a replay attack by intercepting an
SPA packet and the replaying it with the base64 version of "Salted__"
(for Rindael) or the "hQ" prefix (for GnuPG).  This is an important fix.
The following comment was added into the fwknopd code:

/* Ignore any SPA packets that contain the Rijndael or GnuPG prefixes
 * since an attacker might have tacked them on to a previously seen
 * SPA packet in an attempt to get past the replay check.  And, we're
 * no worse off since a legitimate SPA packet that happens to include
 * a prefix after the outer one is stripped off won't decrypt properly
 * anyway because libfko would not add a new one.
*/

Conflicts:

	lib/cipher_funcs.h
2012-08-01 21:52:56 -04:00
Michael Rash
060fbb607f [server] replay attack detection memory leak bug fix
This commit fixes the following memory leak found with valgrind:

44 bytes in 1 blocks are definitely lost in loss record 2 of 2
   at 0x482BE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
   by 0x490EA50: strdup (strdup.c:43)
   by 0x10CD69: incoming_spa (incoming_spa.c:162)
   by 0x10E000: process_packet (process_packet.c:200)
   by 0x4862E63: ??? (in /usr/lib/i386-linux-gnu/libpcap.so.1.1.1)
   by 0x4865667: pcap_dispatch (in /usr/lib/i386-linux-gnu/libpcap.so.1.1.1)
   by 0x10DABF: pcap_capture (pcap_capture.c:226)
   by 0x10A798: main (fwknopd.c:299)
2012-07-30 22:33:24 -04:00
Michael Rash
afc71b7df3 Replay attack bug fix (encryption prefixes)
Ensure that an attacker cannot force a replay attack by intercepting an
SPA packet and the replaying it with the base64 version of "Salted__"
(for Rindael) or the "hQ" prefix (for GnuPG).  This is an important fix.
The following comment was added into the fwknopd code:

/* Ignore any SPA packets that contain the Rijndael or GnuPG prefixes
 * since an attacker might have tacked them on to a previously seen
 * SPA packet in an attempt to get past the replay check.  And, we're
 * no worse off since a legitimate SPA packet that happens to include
 * a prefix after the outer one is stripped off won't decrypt properly
 * anyway because libfko would not add a new one.
*/
2012-07-29 23:31:15 -04:00
Michael Rash
6d379aba6e [server] replay attack detection memory leak bug fix
This commit fixes the following memory leak found with valgrind:

44 bytes in 1 blocks are definitely lost in loss record 2 of 2
   at 0x482BE68: malloc (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
   by 0x490EA50: strdup (strdup.c:43)
   by 0x10CD69: incoming_spa (incoming_spa.c:162)
   by 0x10E000: process_packet (process_packet.c:200)
   by 0x4862E63: ??? (in /usr/lib/i386-linux-gnu/libpcap.so.1.1.1)
   by 0x4865667: pcap_dispatch (in /usr/lib/i386-linux-gnu/libpcap.so.1.1.1)
   by 0x10DABF: pcap_capture (pcap_capture.c:226)
   by 0x10A798: main (fwknopd.c:299)
2012-07-28 00:08:30 -04:00
Michael Rash
175374337d merged crypto_update after fwknop-2.0.1 merge to crypto_update from master 2012-07-24 17:10:00 -04:00
Michael Rash
c6b674617c completed merge from master after fwknop-2.0.1 release 2012-07-24 16:19:48 -04:00
Michael Rash
5ef07c73e2 Better SPA message validation upon SPA decrypt/decode.
Added SPA message validation calls to fko decoding routines to help
ensure that SPA messages conform to expected values.
2012-07-21 15:32:15 -04:00
Michael Rash
29fe16d29f post-merge fix after merged crypto_update branch changes 2012-07-10 22:16:54 -04:00
Michael Rash
d7c4572521 merged test suite changes from the crypto_update branch 2012-07-10 22:03:56 -04:00
Michael Rash
47e39272ed Make encrypt/decrypt code accept integer key lengths instead of using strlen()
Now that encryptions keys and hmac keys may be acquired from /dev/random with
--key-gen (and base64 encoded), they may contain NULL bytes.  This emphasizes
the need to not leverage code that assumes C-style strings when making use of
key information.
2012-07-10 21:44:06 -04:00
Michael Rash
7145cdd8a1 Merge from master minor bug fix to include default encryption mode
When getting raw digest for replay attack detection specify the default
encryption mode (which doesn't actually get used when passing a NULL key).
2012-07-10 08:30:11 -04:00
Michael Rash
dc8a034a4d merged usage() information from master 2012-07-08 22:00:13 -04:00
Michael Rash
be4193d734 Only cache replay digests for SPA packets that decrypt
This change ensures that we only cache replay digests for those SPA packets
that actually decrypt.  Not doing this would have allowed an attacker to
potentially fill up digest cache space with digests for garbage packets.
2012-07-08 08:36:30 -04:00
Michael Rash
ba3b7d1d11 Bug fix for multi-stanza key use and replay attack detection
This commit fixes a bug where the same encryption key used for two stanzas in
the access.conf file would result in access requests that matched the second
stanza to always be treated as a replay attack.  This has been fixed for
the fwknop-2.0.1 release, and was reported by Andy Rowland.  Now the fwknopd
server computes the SHA256 digest of raw incoming payload data before
decryption, and compares this against all previous hashes.  Previous to this
commit, fwknopd would add a new hash to the replay digest list right after
the first access.conf stanza match, so when SPA packet data matched the
second access.conf stanza a matching replay digest would already be there.
2012-07-07 21:31:30 -04:00
Michael Rash
92e403a242 added initial HMAC-SHA256 support for the client side 2012-07-02 23:50:45 -04:00
Michael Rash
3095f0ee43 Added key generation support with --key-gen
Added --key-gen to allow KEY_BASE64 and HMAC_KEY_BASE64 keys to be created from
reading random data from /dev/random.  These keys can be placed within server
access.conf files and corresponding client .fwknoprc files for SPA
communications.  The HMAC key is not used yet with this commit, but that is
coming.
2012-06-27 23:06:17 -04:00
Michael Rash
adbc6a8f39 Bug fix to not force asymmetric gpg decryption
fwknopd access stanzas can have both Rijndael and GnuPG keys, so this
commit fixes a bug where any gpg info would force only gpg decryption
attempts even if a Rijndael key is provided in the stanza.
2012-06-23 15:13:03 -04:00
Michael Rash
4c3d2188a1 Update to make AES encryption modes selectable
This is a significant update to allow AES encryption modes to be selected on a
per-key basis.  For now, only ECB and CBC (recommended) modes are supported.
The default is ECB modes in order to maintain backwards compatibility with the
older perl version of fwknop and the Crypt::CBC CPAN module.  This will likely
be changed to use CBC mode by default because of its better security
properties.

In the access.conf file on the server side, there is a new configuration
variable "ENCRYPTION_MODE" that controls the mode for the corresponding AES
key.  On the client side, a new command line argument "--encryption-mode"
controls how the client encrypts SPA packets.
2012-01-24 20:26:21 -05:00