368 Commits

Author SHA1 Message Date
Michael Rash
a1f4a65f27 interim commit to add major functionality to the fwknop test suite 2011-10-12 23:37:28 -04:00
Michael Rash
4a41ecc955 removed 2011-10-12 23:36:51 -04:00
Michael Rash
88d8eb03b3 minor update to switch to stdout when exiting with success 2011-10-12 23:36:04 -04:00
Michael Rash
41c0be29b7 switched --help output to stdout from stderr 2011-10-06 23:02:29 -04:00
Michael Rash
26f58a705d minor update to account for hardening-check return values 2011-10-06 22:53:27 -04:00
Michael Rash
1a3e1caffe Initial start on a test suite
This commit begins development on a comprehensive test suite for fwknop.
The initial tests are focused on compilation correctness and security options
as determined by the "hardening-check" script from Kees Cook of the Debian
security team.
2011-10-04 23:15:04 -04:00
Michael Rash
05f3cec96a Added --help usage information
With the --help command line argument, the following information is printed:

$ ./fwknop-launcher-lsof.pl --help

Usage: fwknop-launcher-lsof.pl [options]

Options:

    -c,  --config     <file>   - Path to fwknop-launcher.conf config file.
    -l,  --lsof-cmd   <path>   - Path to lsof command.
    -f,  --fwknop-cmd <path>   - Path to fwknop client command.
    -s,  --sleep   <seconds>   - Specify sleep interval (default:
                                 1 seconds)
    -n   --no-daemon           - Run in foreground mode.
    -u,  --user   <username>   - Specify username (usually this is not
                                 needed).
         --home-dir <dir>      - Path to user's home directory (usually
                                 this is not needed).
    -v   --verbose             - Print verbose information to the terminal
                                 (requires --no-daemon).
         --help                - Print usage info and exit.
2011-09-25 21:12:30 -04:00
Michael Rash
71ea0c6bfd Merge branch 'master' into fwknop-launcher 2011-09-25 21:02:54 -04:00
Michael Rash
7748423b15 Added the fwknop lsof launcher under the extras/ directory
The fwknop lsof launcher (extras/fwknop-launcher/fwknop-launcher-lsof.pl) is a
lightweight daemon that allows the user to not have to manually run the fwknop
client when attempting to gain access to a service that is protected by Single
Packet Authorization via fwknopd.  This is accomplished by checking the output
of lsof to look for pending connections in the SYN_SENT state, which (usually)
indicate that a remote firewall is blocking the attempted connection.  At this
point, the launcher executes the fwknop client with the --get-key arg (so the
user must place the key in the local filesystem) to generate an SPA packet for
the attempted connection.  The remote fwknopd daemon will reconfigure the
firewall to allow temporary access, and this usually happens fast enough that
the original connection attempt will then succeed.

The idea for this was originally for a pcap-based connection watcher by
Sebastien Jeanquier.
2011-09-24 22:31:18 -04:00
Michael Rash
35ee5a202d Merge pull request #5 from maxkas/master
Fwknop client for iPhone devices - contributed by Max Kastanas
2011-09-21 18:10:16 -07:00
Max Kastanas
668ed9033f Codebase of Fwknop client for iOS (iPhone) devices 2011-09-16 22:51:53 -07:00
Michael Rash
35abc349ab minor typo fix: fwkop -> fwknop 2011-09-12 23:04:41 -04:00
Damien Stuart
f693a2721c Merge branch 'master' of https://github.com/mrash/fwknop 2011-09-10 11:30:09 -04:00
Damien Stuart
e07ccdd550 Added the cmd_opts.h file to server and client's Makefile.am so they are included with make dist. 2011-09-10 11:25:08 -04:00
Michael Rash
87416c0cdf Replaced all strcpy() calls with strlcpy()
OpenBSD especially gives compiler warnings whenever strcpy() is used.  All such
calls have been replaced with strlcpy().
2011-09-09 22:09:37 -04:00
Michael Rash
0b8c489075 Added read-only relocations and immediate bindings
Commit 4248b2687054b38e79e2ab9eecf71e5b299172f4 removed read-only relocations
and immediate bindings for FreeBSD systems (and the same was done for OpenBSD
systems too).  This commit adds these security features back in as linker
options by only changing LDFLAGS as opposed to also adding the corresponding
flags to CFLAGS.  The end result is that the following errors are fixed:

gcc: -z: linker input file unused because linking not done
gcc: relro: linker input file unused because linking not done
2011-09-08 23:44:50 -04:00
Michael Rash
c65e25c656 Check for active_rules > 0 before decrementing
In the fw_config struct the active_rules member is unsigned, so this change
ensures that we don't try to decrement it below zero whenever a firewall rule
is deleted or an error condition occurs.
2011-09-08 21:33:52 -04:00
Michael Rash
88b6d44f1f Update to make _exp_ string a #define
Replaced all instances of "_exp_" with the #define EXPIRE_COMMENT_PREFIX so
that the prefix can easily be changed. so
that the prefix can easily be changed. so
that the prefix can easily be changed. so
that the prefix can easily be changed.
2011-09-08 00:20:20 -04:00
Michael Rash
2531896ebf Added the ability to delete PF rules
This commit adds the ability to fwknopd to delete PF rules after the SPA timer
expires.  The strategy implemented is similar to iptables and ipfw, except
that all PF rules are added to an 'anchor', and deleting a specific expired
rule is done by listing all rules in the anchor and reinstantiating it via
'pfctl -a <anchor> -f -' with the expired rule deleted.  fwknopd uses the
"_exp_<expire time>" convention in a PF rule label similarly to how fwknopd
interfaces with iptables (via the 'comment' match), and ipfw (via the
"//<comment>" feature).
2011-09-07 23:24:18 -04:00
Michael Rash
f9810904c3 minor comment typo fixes 2011-09-03 21:00:12 -04:00
Michael Rash
d60dde17b7 PF rules are now added to the fwknop anchor
This commit implements the ability to add PF firewall rules to the fwknop
anchor after a valid SPA packet is sniffed off the wire.  A subsequent commit
will add the ability to delete these rules.
2011-09-03 14:50:28 -04:00
Michael Rash
6938f7a6ae Minor copyright holder update
Minor copyright holder update
2011-08-28 13:37:23 -04:00
Michael Rash
10ff421e1e For PF firewalls implemented a check for an active fwknop anchor
This commit ensures that for PF firewalls that the fwknop anchor is active and
linked into the running PF policy.  This is accomplished by looking for the
string 'anchor "fwknop"' in the output of "pfctl -s rules".  If the anchor
exists, then fwknopd will be able to influence traffic via rules added and
removed from the fwknop anchor.
2011-08-28 13:27:15 -04:00
Michael Rash
5bc5ef4305 Added --fw-list info to --help
Added --fw-list output to usage info when --help is specified from the command
line.
2011-08-27 11:07:19 -04:00
Michael Rash
0649ef924a PF support on OpenBSD in progress, fwknop --fw-list now works
This is the first commit that has fwknopd interact with the PF firewall on
OpenBSD (via fwknopd --fw-list to show any active fwknopd rules).
2011-08-27 10:57:17 -04:00
Michael Rash
dcf2d94bf6 Added autoconf check for pf firewalls
On OpenBSD systems fwknop now checks for pf firewalls via autoconf.  The next
step will be to fill in support for pf via the C code.
2011-08-24 23:55:36 -04:00
Michael Rash
649b7a88c1 Disabled read-only relocations and immediate binding compiler protections
Similarly to FreeBSD systems, gcc throws the following warnings with read-only
relcations and immediate binding protections - disbabled for now:

gcc: -z: linker input file unused because linking not done
gcc: relro: linker input file unused because linking not done
gcc: -z: linker input file unused because linking not done
gcc: now: linker input file unused because linking not done
2011-08-24 23:17:45 -04:00
Michael Rash
47da588003 removed 2.0.0 branch specific ChangeLog, ShortLog and diffstat files 2011-08-22 21:39:28 -04:00
Michael Rash
17beb2d348 bumped version to 2.0.0rc4 2011-08-21 14:06:41 -04:00
Michael Rash
b937ae2347 Added version specific ChangeLog, ShortLog, and diffstat files.
Added version specific ChangeLog, ShortLog, and diffstat files (these go all
the way back to the beginning of the svn import since 2.0.0 will be the
first official non-"rc" release of the new C code).
2011-08-21 14:02:25 -04:00
Michael Rash
4ed4558192 Updated ChangeLog with all changes from 2.0.0-rc3
Updated ChangeLog with all changes from 2.0.0-rc3
2011-08-21 14:00:16 -04:00
Michael Rash
35456877fa Bug fix for ipfw firewalls to not always require seeing 'Dynamic' rules
This commit fixes an issue on ipfw firewalls where fwknopd would always require
seeing ipfw 'Dynamic' rules associated with newly added connections.  But, such
connections may never be established for various reasons.  Previous to this
commit the following warning was frequently generated by fwknopd:

Unexpected error: did not find 'Dynamic rules' string in list output.
2011-08-21 13:50:16 -04:00
Michael Rash
4b2a96578b Bug fix for missing set existence check on ipfw firewalls
This commit fixes an issues on systems running the ipfw firewall where the
'set' where fwknopd puts new access rules was attempted to be deleted without
first checking to see whether it exists.  The following errors would be
generated (now fixed):

ipfw: rule 16777217: setsockopt(IP_FW_DEL): Invalid argument
Error 17664 from cmd:'/sbin/ipfw delete set 1':
Fatal: Errors detected during ipfw rules initialization.
2011-08-21 13:28:16 -04:00
Michael Rash
03859387b6 Bug fix to create the digest.cache file at init
Bug fix to ensure that the digest.cache file gets created at fwknopd init time
so fwknopd does not throw the following error:

Error opening digest cache file. Incoming digests will not be remembered.
2011-08-20 22:34:24 -04:00
Michael Rash
04afd2846d On FreeBSD, made gpgme header path inclusion optional
If gpgme is installed on FreeBSD systems it appears that
-I/usr/local/include/gpgme must be added to the include path, but this change
only adds the path if gpgme is installed and going to be used.
2011-08-20 22:02:21 -04:00
Michael Rash
6eeb413094 Fixed a few minor compiler warnings on FreeBSD
This commit fixes a few warnings about possible uninitialized and unused
variables.
2011-08-20 13:33:00 -04:00
Michael Rash
4248b26870 On FreeBSD disable read-only relocations and immediate binding protections
gcc on FreeBSD generates the following errors when the -Wl,-z,relro -Wl,-z,now
flags are used:

gcc: -z: linker input file unused because linking not done
gcc: relro: linker input file unused because linking not done
gcc: -z: linker input file unused because linking not done
gcc: now: linker input file unused because linking not done
2011-08-20 13:19:33 -04:00
Michael Rash
ff7c4219e8 Update to suppress additional compiler warning
This change fixes the following compiler warning that was seen with many of
the source files in server/

fwknopd_common.h:223: warning: ‘config_map’ defined but not used
2011-08-20 12:56:30 -04:00
Michael Rash
ab7226092d Minor restructuring to suppress compiler "defined but not used warnings"
This commit fixes several compiler warnings like the following (now that -Wall
is the default):

config_init.h:68: warning: ‘cmd_opts’ defined but not used
2011-08-20 12:34:57 -04:00
Michael Rash
db681fb791 minor commit to fix minor compilations warnings 2011-08-19 22:00:16 -04:00
Michael Rash
637f7a4c93 Added -Wall for all gcc warnings during compile
Enable gcc compilation to include -Wall for all warnings (can be disabled
with --disable-wall to ./configure).
2011-08-19 21:14:24 -04:00
Michael Rash
bf59c2688f Bug fix for ./configure args to disable compile time security options
The ./configure script would generate the following error for the attempted
use of the --without-stackprotector (and other related options like
--without-pie):

configure: WARNING: unrecognized options: --without-stackprotect
2011-08-19 20:51:50 -04:00
Michael Rash
41fc93407e added the VERSION file 2011-08-18 22:26:52 -04:00
Michael Rash
8b0787c270 Bumped version to fwknop-2.0.0-rc3
Bumped version to fwknop-2.0.0-rc3
2011-08-18 22:25:12 -04:00
Michael Rash
1e494aba2e Added ChangeLog derived from git commit messages.
There will be branch and release specific ChangeLog files as well.
2011-08-18 21:13:58 -04:00
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