323 Commits

Author SHA1 Message Date
Michael Rash
409c08ac5c Renamed ChangeLog -> ChangeLog.old for new ChangeLog handling
The ChangeLog will be derived from commit messages.
2011-08-18 21:10:09 -04:00
Michael Rash
b9122f648e Update to add any missing iptables jump rules
Upon the receipt of a valid SPA packet, a check is done to make sure that
a jump rule from the appropriate built-in iptables chains exists to the
fwknop chains.  Such rules could have been deleted by other manipulations
of the iptables policy, so it is important to ensure they exist.  Running
in foreground (-f) mode, here is an illustration of the jump rule being
added after it got deleted:

SPA Packet from IP: 127.0.0.1 received.
Added jump rule from chain: INPUT to chain: FWKNOP_INPUT
Added Rule to FWKNOP_INPUT for 127.0.0.1, tcp/22 expires at 1313680648
2011-08-18 20:37:31 -04:00
Michael Rash
acdf15f158 Update to force base64 check for all SPA data
Previous to this change a check was done for base64 characters in incoming
SPA data only up to MIN_SPA_DATA_SIZE.  This check may be reinstantiated for
SPA packets that are delivered over HTTP (and the packet data is embedded
within a URL that may also contain non-base64 chars), but in the meantime the
fwknopd daemon should not accept SPA packets over arbitrary ports with any
non-base64 chars.
2011-08-17 21:24:03 -04:00
Michael Rash
92b7e2588e Updated replay warnings to include proto/port info
Replay warnings now include port and protocol information.  Here is an example:

SPA Packet from IP: 127.0.0.1 received.
Replay detected from source IP: 127.0.0.1
        Destination proto/port: 17/62201
            Original source IP: 127.0.0.1
       Original dst proto/port: 17/62201
                 Entry created: 08/17/11 21:06:07
                  First replay: 08/17/11 21:06:32
                   Last replay: 08/17/11 21:06:45
                  Replay count: 7
2011-08-17 21:07:35 -04:00
Michael Rash
df96e42c51 Added stack protection, PIE, fortify source, etc.
Added various security options that can be enabled at compile time.  These
options include everything that the "hardening-check" script written by Kees
Cook checks for.  After this change, the hardening-check script produces the
following output against the fwknopd binary:

$ hardening-check server/.libs/fwknopd
server/.libs/fwknopd:
 Position Independent Executable: yes
 Stack protected: yes
 Fortify Source functions: yes
 Read-only relocations: yes
 Immediate binding: yes

One of the compile outputs (for example) that shows the new options is:

/bin/bash ../libtool --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I. -I..     -g -O2 -fstack-protector-all -fPIE -pie -D_FORTIFY_SOURCE=2 -Wl,-z,relro -Wl,-z,now -MT fko_decode.lo -MD -MP -MF .deps/fko_decode.Tpo -c -o fko_decode.lo fko_decode.c

From the hardening-check man page, here is a description of each of these
options:

NAME
       hardening-check - check binaries for security hardening features

SYNOPSIS
       Examine a given set of ELF binaries and check for several security
       hardening features, failing if they are not all found.

DESCRIPTION
       This utility checks a given list of ELF binaries for several security
       hardening features that can be compiled into an executable.  These
       features are:

       Position Independent Executable
               This indicates that the executable was built in such a way
               (PIE) that the "text" section of the program can be relocated
               in memory.  To take full advantage of this feature, the
               executing kernel must support text Address Space Layout
               Randomization (ASLR).

       Stack Protected
               This indicates that the executable was compiled with the
               gcc(1) option -fstack-protector.  The program will be
               resistant to have its stack overflowed.

       Fortify Source functions
               This indicates that the executable was compiled with
               -D_FORTIFY_SOURCE=2 and -O2 or higher.  This causes certain
               unsafe glibc functions with their safer counterparts (e.g.
               strncpy instead of strcpy).

       Read-only relocations
               This indicates that the executable was build with -Wl,-z,relro
               to have ELF markings (RELRO) that ask the runtime linker to
               mark any regions of the relocation table as "read-only" if
               they were resolved before execution begins.  This reduces the
               possible areas of memory in a program that can be used by an
               attacker that performs a successful memory corruption exploit.

       Immediate binding
               This indicates that the executable was built with -Wl,-z,now
               to have ELF markings (BIND_NOW) that ask the runtime linker to
               resolve all relocations before starting program execution.
               When combined with RELRO above, this further reduces the
               regions of memory available to memory corruption attacks.
2011-08-17 20:36:28 -04:00
Michael Rash
60b6a5a4d8 Minor variable cleanup to fix compiler warnings
Minor cleanup to fix compiler warnings about unused variables.
2011-08-14 22:46:09 -04:00
Michael Rash
e7d275ee31 Added fwknop-2.0.0rc2 openwrt support from Jonathan Bennett
Applied a patch sent from Jonathan Bennett to add fwknop-2.0.0rc2 support to
openwrt.  One thing to note about this patch is that the +libgdbm library
dependency has been removed because fwknop now implements its own digest
tracking file without needing gdbm/ndbm on the system.
2011-08-14 21:55:29 -04:00
Michael Rash
878fae8e8a Implemented memory clean up for digest cache list
Upon fwknopd shutdown, a new function free_replay_list() is now called in order
to free heap allocated memory dedicated to SPA digest tracking.  Without this
fix, valgrind reports the following (some output snipped):

valgrind --leak-check=full ./server/.libs/fwknopd -f -i lo -P "udp port 62201"

==30864== 431 (48 direct, 383 indirect) bytes in 1 blocks are definitely lost in loss record 17 of 17
==30864==    at 0x4C27480: calloc (vg_replace_malloc.c:467)
==30864==    by 0x407CB7: replay_check_file_cache (replay_cache.c:461)
==30864==    by 0x407B69: replay_check (replay_cache.c:413)
==30864==    by 0x405813: incoming_spa (incoming_spa.c:363)
==30864==    by 0x406275: pcap_capture (pcap_capture.c:223)
==30864==    by 0x40317D: main (fwknopd.c:297)
2011-08-14 19:42:50 -04:00
Michael Rash
5ee6715cff Consolidated replay warnings in a single function
For both the simple digest file cache and the gdbm/ndbm tracking methods, all
replay warnings are generated by a single function "replay_warning()".
2011-08-14 12:36:25 -04:00
Michael Rash
c13cca4aa1 Added digest file import code
The digest file is now imported as a linked list of digest cache entries at
init time for SPA replay attack detection.
2011-08-13 22:35:52 -04:00
Michael Rash
941a4aa9a3 Added source port and protocol to digest tracking
Added the source port and protocol fields to valid SPA packets in the digest
cache.  This can help to discover replay trends.  The format of the digest
file cache is now:

<digest> <proto> <src_ip> <src_port> <dst_ip> <dst_port> <time>
2011-08-13 21:00:54 -04:00
Michael Rash
6982a72c07 Added dst IP to tracked SPA data
The digest cache now contains destination IP addresses of valid SPA packets.
The complete format is now:

<digest> <src_ip> <dst_ip> <creation time>
2011-08-12 22:00:44 -04:00
Michael Rash
4197e51c9d Started on code to parse the digest cache file
At init time fwknopd will read in the digest cache file into the in-memory
linked list of digests for SPA replay detection. This commit starts on this
code, but the file format does not yet include destination IP addresses
(to be added in an upcoming commit).
2011-08-12 21:43:07 -04:00
Michael Rash
459cfb4d45 Implemented linked list cache of SPA digests
When not using gdbm/ndbm support (the default now), fwknopd implements a linked
list of SPA packet digests for replay attack detection along with writing
digest data in ascii text down to disk (in the CONF_DIGEST_FILE file).
2011-08-12 20:16:00 -04:00
Michael Rash
e443550e5f Merge branch 'master' into optional_dbm_support 2011-08-10 22:41:18 -04:00
Michael Rash
d2c5085843 Added --pcap-filter to the fwknopd command line
To override the value of the PCAP_FILTER variable in the fwknopd.conf
config file, a new fwknopd command line argument "--pcap-filter" was
added.  This assists in various activities by making it trivial to
change how fwknopd acquires packet data without editing the fwknopd.conf
file.  Here is an example:

fwknopd -i lo -f --pcap-filter "udp port 12345"
2011-08-10 22:38:01 -04:00
Michael Rash
52c795634b Updated digest file path for gdbm/ndbm support
If fwknopd is compiled with --disable-file-cache to the ./configure script
then it will assume that the default filename is "digest_db.cache" for the
digest cache.  If the file cache method is used (this is the default), then
"digest.cache" is the default filename.  A new variable DIGEST_DB_FILE in
the fwknopd.conf file controls the digest filename if gdbm/ndbm support is
required.
2011-08-10 22:07:25 -04:00
Michael Rash
0525cd4a5c Added autoconf support for non-dbm file cache.
This change starts on support for a simple file-based cache mechanism
for tracking SPA digests.  This removes the libgdbm/libndbm dependency
by default, but it can be re-enabled with the --disable-file-cache
argument to the ./configure script.
2011-08-10 20:56:42 -04:00
Michael Rash
2dd7c4aac7 Minor rename in support of non-dbm file cache
Added the optional_dbm_support branch and made a minor renaming change
on this branch for the coming non-dbm file cache support.
2011-08-08 22:49:28 -04:00
Michael Rash
1e47243574 Bug fix for uninitialized variable found with splint static analyzer
In the save_args() function the args_str_len variable was being used before
being initialized as reported via the splint static code analysis tool.  Here
is the splint output that found this bug:

client/fwknop.c:650:13: Variable args_str_len used before definition
  An rvalue is used that may not be initialized to a value on some execution
  path. (Use -usedef to inhibit warning)
2011-08-08 22:24:22 -04:00
Damien Stuart
69f41eb399 Set FD_CLOEXEC on pid file descriptor.
Added support for setting the URL for resolving source IP via command-line or the .fwknoprc file.
2011-07-07 08:12:49 -04:00
Michael Rash
ca5f82c067 Removed legacy $Id$ tags from svn
$Id$ tags don't really mean anything to git so they have been removed from all
source files.
2011-06-18 20:53:40 -04:00
Damien Stuart
39e7412bb8 Added a no-digest-cache configure option and capability (though it is not recommended).
git-svn-id: file:///home/mbr/svn/fwknop/trunk@313 510a4753-2344-4c79-9c09-4d669213fbeb
2011-03-27 02:38:41 +00:00
Damien Stuart
03361fea74 Fix check and handling of ndbm as an option for the digest cache.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@312 510a4753-2344-4c79-9c09-4d669213fbeb
2011-03-26 16:33:02 +00:00
Damien Stuart
6c050b481c Added python/fko.py to Makefile.am so it is also included in distributions. Minor tweak to address compile error on Mac os X.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@311 510a4753-2344-4c79-9c09-4d669213fbeb
2011-02-12 13:18:31 +00:00
Damien Stuart
4b0c280948 Minor update to the android README
git-svn-id: file:///home/mbr/svn/fwknop/trunk@310 510a4753-2344-4c79-9c09-4d669213fbeb
2011-01-02 03:32:46 +00:00
Damien Stuart
a24a2eed8f Adding Max Kastanas's fwknop client app code for Android
git-svn-id: file:///home/mbr/svn/fwknop/trunk@309 510a4753-2344-4c79-9c09-4d669213fbeb
2011-01-02 02:58:53 +00:00
Damien Stuart
d8f282143e Removed unnecessary include.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@308 510a4753-2344-4c79-9c09-4d669213fbeb
2011-01-01 21:00:24 +00:00
Damien Stuart
225e36414d Additional docs and classes added to the fko python module. Minor tweak and bumped version in the fwknop.spec file.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@307 510a4753-2344-4c79-9c09-4d669213fbeb
2010-12-05 15:44:01 +00:00
Damien Stuart
9d821548e7 Fixed bug where libfko would segfault if fko_get_spa_data() was called before fko_spa_data_final() was called (and successful). Added include of time.h in fko.h.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@306 510a4753-2344-4c79-9c09-4d669213fbeb
2010-12-05 14:57:01 +00:00
Damien Stuart
966b9bdccc Do not need parens around expression in if statements in python (still learning).
git-svn-id: file:///home/mbr/svn/fwknop/trunk@305 510a4753-2344-4c79-9c09-4d669213fbeb
2010-12-04 21:57:34 +00:00
Damien Stuart
4e5326660c Added pydoc text to the fko python module. Minot tweak to setup.py.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@304 510a4753-2344-4c79-9c09-4d669213fbeb
2010-12-04 04:12:17 +00:00
Damien Stuart
b6bf1d28bf Added the Fko class code to wrap the _fko wrapper around libfko.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@303 510a4753-2344-4c79-9c09-4d669213fbeb
2010-11-27 03:18:58 +00:00
Damien Stuart
00bc99a966 Minor comment and documentation tweaks. Add the python directory which contains my first cut at a libfko Python wrapper module.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@302 510a4753-2344-4c79-9c09-4d669213fbeb
2010-11-26 15:51:00 +00:00
Damien Stuart
04ebf6c2ad Added code to zero out rcfile path before setting it. Also added a bounds check to that as well.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@301 510a4753-2344-4c79-9c09-4d669213fbeb
2010-11-14 00:16:32 +00:00
Damien Stuart
0f6ca00ac4 Updated the GPL blurb at the top of the source files. Added some missing copyright statements (Thanks to Franck Joncourt).
git-svn-id: file:///home/mbr/svn/fwknop/trunk@300 510a4753-2344-4c79-9c09-4d669213fbeb
2010-11-13 03:04:36 +00:00
Damien Stuart
67af7f7921 Updated perl module for additional error messages.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@299 510a4753-2344-4c79-9c09-4d669213fbeb
2010-11-10 15:30:09 +00:00
Damien Stuart
781218e7e1 Bumped version to rc3 (even though we may go straight to release) and lib rev to 3.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@298 510a4753-2344-4c79-9c09-4d669213fbeb
2010-10-31 01:45:28 +00:00
Damien Stuart
d84112adca Update added HAVE_ERRNO_H 1 to win32/config.h.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@297 510a4753-2344-4c79-9c09-4d669213fbeb
2010-10-31 01:36:25 +00:00
Damien Stuart
a3bafdb364 Needed to bump libfko revision to 2 do identify as part of newer dist.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@295 510a4753-2344-4c79-9c09-4d669213fbeb
2010-10-30 16:19:54 +00:00
Damien Stuart
3c83e899cb Put the usleep back pcap_capture (oops).
git-svn-id: file:///home/mbr/svn/fwknop/trunk@293 510a4753-2344-4c79-9c09-4d669213fbeb
2010-10-23 17:34:47 +00:00
Damien Stuart
ce6fe8c705 Tweaks to the fwknop.spec file
git-svn-id: file:///home/mbr/svn/fwknop/trunk@291 510a4753-2344-4c79-9c09-4d669213fbeb
2010-10-21 02:39:57 +00:00
Damien Stuart
bbe8c9d7a1 Set pcap non-block mode back on unless it is a freebsd system. Server verbose output no longer shows access key or GPG password.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@290 510a4753-2344-4c79-9c09-4d669213fbeb
2010-10-21 01:53:04 +00:00
Damien Stuart
4f504848a0 Fixed handling of man page generation in Makefile.am so it works from alternate build directories.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@289 510a4753-2344-4c79-9c09-4d669213fbeb
2010-10-17 02:52:21 +00:00
Damien Stuart
f1e82bc7ae Minor fwknopd man page tweak.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@288 510a4753-2344-4c79-9c09-4d669213fbeb
2010-08-29 02:06:13 +00:00
Damien Stuart
1381f18374 Made autoconf print an error message indicating ipf is not supported if it is specified. Changelog updates.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@287 510a4753-2344-4c79-9c09-4d669213fbeb
2010-08-29 01:50:58 +00:00
Damien Stuart
6bcebe565c Made fw_cleanup not remove rules from the expired rule set. Added code to read in any existing expired rules into the rule_map at startup.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@286 510a4753-2344-4c79-9c09-4d669213fbeb
2010-08-29 01:32:04 +00:00
Damien Stuart
ff9dad6fd9 Wrapped #ifdef around a linux-specific chunk.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@285 510a4753-2344-4c79-9c09-4d669213fbeb
2010-08-27 22:09:36 +00:00
Damien Stuart
c4c158c1ba Missed a config file update on the last check-in.
git-svn-id: file:///home/mbr/svn/fwknop/trunk@284 510a4753-2344-4c79-9c09-4d669213fbeb
2010-08-26 22:56:47 +00:00
Damien Stuart
cdff077bb6 Added rule expire and purge for ipfw. Almost there...
git-svn-id: file:///home/mbr/svn/fwknop/trunk@283 510a4753-2344-4c79-9c09-4d669213fbeb
2010-08-24 03:09:35 +00:00