NuFW Handbook

Eric Leblond

Vincent Deffontaines

Pierre Chifflier

Revision History
Revision 1.0.32009/01/20

Added a short note about OCSP support.

Revision 1.0.22008/12/10

Updated the nuauth_command description. Synchronized nuauth and nufw output with current version in debug section.

Revision 1.0.12008/12/01

Updated the recommended setup section, fixed image inclusions. Added a version choosing section. Better documentation for nuauth's user session disconnection.

Revision 1.0.02008/11/25

This handbook is based on the original howto document, and has been dramatically enhanced (countless changes).


Table of Contents

1. License
2. Introduction
Presentation
Architecture
Requirements
General
Nuauth dependencies
nufw dependencies
User marking requirement on old kernel
Using nfnetlink and getting all latest NuFW features
Recommended setup
How to choose your NuFW version
Installing
Upgrading
Finding out the installed version
3. Compilation and installation
Default distribution kernels
Kernel preparation
Linux 2.6.14 and higher
NuFW compilation
Initial setup and tests
Certificates and client installation
Creating your own certificates
Basic nuauth setup
Testing
Setting up Netfilter rules before 2.6.14
Setting up Netfilter rules from 2.6.14
Testing the authentication system
Initial tests and debug process
4. Setting up NuFW
Using the LDAP module for acl checking
Installation of OpenLDAP server (slapd)
Slapd configuration
nuauth configuration
Using nuface, a web-based rules generator
nuaclgen configuration
Setting up NuFW authenticated connections tracking
nuauth settings
Installation of MySQL server
Installation of PostgreSQL server
SQL configuration
Life of a connection in the SQL table
Netfilter settings
Using the connection tracking
Single Sign On setup
Apache
Squid
Troubleshooting single sign on problems
User based Quality of Service
Setting up Kernel on non libnetfilter_queue system
Setting up nufw
Setting up Netfilter
Using marking modules
Using NuFW mark
Controlling nuauth finely at runtime
Time-based ACLs
Global configuration
XML period definition module
Chaining modules in nuauth
Syntax description
Some examples
Hardening NuFW
Nufw certificate verification
Authentication server (nuauth)
User authentication restrictions
On client side
Certificate authentication
Using secure LDAP (LDAPs) for ACLs checking
OS and application filtering
Intrusion Detection System (IDS)
Nuauth authentication configurations
PAM/LDAP authentication with Nuauth
PAM/Winbind authentication with Nuauth
5. Authentication Agents
Supported OSes
Windows
Linux
MacOS
UNIX and BSD systems
pam_nufw
Options
Configuration file example
6. Miscellaneous
Supported protocols
Big endian architectures
System with glibc 2.3.2
Linux distributions specific
Debian specific
Mandrake specific
Suse specific
Redhat specific
RedHat Enterprise Linux 4
Known issues
Problem with ip_queue on kernel prior to 2.6.12
Running NuFW in a bridged network
7. Appendix
Managing finer TLS settings with NuFW
Glossary

List of Figures

2.1. NuFW Algorithm resume
2.2. A Nulog screenshot
2.3. A NuFace screenshot

List of Tables

7.1. nufw daemon (command line) TLS options resume
7.2. nuauth daemon configuration TLS options resume
7.3. nutcpc command line TLS options resume
7.4. nuclient.conf TLS options resume

Chapter 1. License

This document is copyrighted by INL, and distributed under the Creative Commons by-nc-sa license. The full text of the license is available at http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode.

Chapter 2. Introduction

Presentation

NuFW is an enterprise grade firewall that performs an authentication of every single connection passing through the IP filter, by transparently requesting user's credentials before any filtering decision is taken. Practically, this means security policies can integrate with the user directory, and bring the notion of user ID down to the IP layers. NuFW lays on Netfilter, the state of the art IP filtering layer from the Linux kernel. It fully integrates with Netfilter and extends its capabilities. The daemons currently run on Linux and software clients are available for Windows, Linux, FreeBSD et Mac OSX.

NuFW can:

  • Authenticate any connection that goes through your gateway or only from/to a chosen subset or a specific protocol (iptables is used to select the connections to authenticate).

  • Perform accounting, routing and quality of service based on users and not simply on IP.

  • Filter packets with criteria such as application and OS used by remote users.

  • Be the key of a secure and simple Single Sign On system.

NuFW is composed of two daemons that can be put on different systems and the main daemon nuauth is heavily multi-threaded. nuauth uses loadable modules to add features, like SQL logging, reporting alert to IDS using Prelude, etc.

Architecture

NuFW has very little needs in terms of architecture. It is a firewall, so it needs to be installed between the client and the server, concerning connections the admin wills to authenticate. In other words, if you look at the figure below, the requisite is that the firewall running NuFW is set between the client host (M) and the server (T). It doesn't matter whether you administrate the server (T) or whether it is a random host on the internet : NuFW authentication occurs at the time the firewall decision is taken for each connection.

A very typical setup is to use NuFW on a central firewall, so that it can filter connections from LAN to DMZ, from LAN to Internet, from WAN to LAN, etc. Of course, this is no requisite and you can always chain NuFW with another implementation. Technically, NuFW has one requisite : no NAT should be applied on connections between the client and NuFW itself. If that occurs, NuFW authentication will not work. This can easily be turned around if you want to identify your users from the Internet, by setting up a VPN (road-warrior or network to network) tunnel.

A typical architecture is as follows :

Figure 2.1. NuFW Algorithm resume

NuFW Algorithm resume


  1. A standard application sends a packet.

  2. The Nufw server queues the packet and sends an auth request packet to the Nuauth server.

  3. The Nuauth server sends to all nufw agents running on the client computer an authentication request.

  4. The Nufw client run by the user whose application sent traffic sees that a connection is being initiated and sends a user request packet. The Nuauth server sums the auth request and the user request packet and checks this against an authentication authority.

  5. The Nuauth server replies to the Nufw server accordingly.

  6. The Nufw server transmits the packet following the answer given to its request.

  7. The flow of the connection is handled by Netfilter's state table (the conntrack), like for any firewalling rule.

Requirements

In this section, each invoked library will have to be installed and the header files have to be in standard places (so ./configure can find them).

General

NuFW is an advanced network filtering solution. For logging, as well as for domain integrations, it is highly recommended that all servers hosting NuFW services (nufw, nuauth, LDAP/Active Directory, and the logging server (SQLi/syslog/prelude)) be time-synchronized with a protocol such as NTP. NuFW does not provide time synchronization per se.

Nuauth dependencies

nuauth core daemon

nuauth dependencies are as follows:

  • libglib2.0: nuauth heavily uses this library which provides a set of very useful high level objects. It needs at least 2.4 release.

  • libgnutls: communications between components are encrypted using TLS v1

  • libsasl2: authentication is done via sasl

  • libtool: It's needed for the compilation of library and modules

Note

Be careful when choosing your GnuTLS version : old versions may contain security breaches. Check the GnuTLS security advisories page or make sure your distribution is reactive enough with updates.

MySQL logging

The libmysqlclient library is required for compiling of this module.

PostgreSQL logging

The libpq library is required for compiling this module.

Prelude IDS alerts

The libprelude library is required for compiling this module. Prelude allows for gathering security events at the scale of any organization, and NuFW can send Prelude the following events :

  • User authentication failures

  • User authentication successes

  • Start and end of user sessions

  • Start and end of authenticated connections

  • Rejected connections

NuFW is a native sensor for Prelude, allowing tight integration with any IDS based the IDMEF standard (RFC 4765). All information about the Prelude project is available at http://prelude-ids.org

LDAP authentication and acl check

libldap library is needed (version 2 or better).

nufw dependencies

The nufw daemon only depends on:

  • iptables: libipq.a is necessary to compile the nufw server

  • libgnutls: nufw is connected to nuauth using a TLS encrypted channel

User marking requirement on old kernel

A system with a kernel prior to 2.6.14 needs a patched version of the ip_queue module and of its "sibling" library libipq.

Using nfnetlink and getting all latest NuFW features

On kernel superior to 2.6.14, ipq is now deprecated in favor of libnetfilter_queue which uses the new nfnetlink system. On top of that nfnetlink also provides libnetfilter_conntrack which is used by NuFW to implement connection tracking, and strict time-based acls.

To use this features, the following libraries are needed:

  • libnfnetlink

  • libnetfilter_queue

  • libnetfilter_conntrack

You can find working versions of these libraries at http://nufw.org/download/libs/index.html Debian packages are available at http://www.nufw.org/debian/

If you plan to use NuFW time-based acls, it is best to use a kernel superior to 2.6.18 or to apply patches provided on NuFW site.

Recommended setup

This section's aim is to provide the best practises to help admins start a NuFW installation. We recommend that you use :

  • A MySQL database for logs. Though nuauth as well as single sign on modules support PostgreSQL logging, NuLog PostgreSQL support should be considered experimental for now.

  • A NuLog installation. This is not a formal requisite for setting up and using NuFW, but NuLog is a great tool to keep track of what is going on on your firewall. It analyses data from a ulog SQL database.

    Figure 2.2. A Nulog screenshot

    A Nulog screenshot


  • A NuFace installation. NuFace is INL's tool to build consistent Netfilter + nuauth rules. You really should consider using NuFace unless you plan to write your own tool : dealing with filtering rules by hand can be tricky because you need to synchronise authenticating rules at Netfilter and nuauth levels.

    Figure 2.3. A NuFace screenshot

    A NuFace screenshot


  • A ulogd daemon setup for Netfilter logging. Ulogd can log Netfilter flows into the same database as nuauth, in order to provide a consistent log for both authenticated and unauthenticated connections. For now we recommend you use ulogd in version 1.X. Ulogd should run on the same host as your nufw daemon, and log in the same MySQL database as nuauth. The Installation of MySQL server section describes a MySQL installation.

  • A user directory, supported by PAM. This means Active Directory, LDAP, Novell e-directory, and other directories are supported. This is actually a PAM matter, see section Nuauth authentication configurations for details. A plaintext nuauth module exists for user authentication, but it should be used for quick testing only. We really advise you have nuauth lay on a user directory. For instance, adding/removing users from the plaintext file requires that you restart nuauth, while those changes are transparent if nuauth uses the system module.

  • A LDAP (local) directory, to store nuauth ACLs. Again, user authentication can be setup on a plaintext file, but this means you will need to handle it by hand, with a text editor, and warranty that your nuauth rules are consistent with Netfilter rules. On the other hand, Nuface can deal with both Netfilter and LDAP rules. Again, nuauth will need to be restarted if you make changes in the plaintext file, while the LDAP changes will apply on the fly. The LDAP ACL directory needs not formally be local, it can be hosted on any LDAP directory that nuauth can reach. See the Using the LDAP module for acl checking section for details about how to setup your LDAP acl tree.

How to choose your NuFW version

Installing

If you are installing NuFW from scratch, it is advised that you use the latest stable version. You should avoid distribution packages if they distribute old versions, especially if security upgrades have been notified in latest versions. NuFW security announces are always available at this URL.

Note

Up to date Debian packages are distributed by INL, and can be used on your Debian systems by setting :

          deb http://packages.inl.fr/ testing/
         

or

          deb http://packages.inl.fr/ stable/
         

to your /etc/apt/sources.list file. Also note that this URL makes the inl-keyring package available, for package GPG signatures.

Unless you are a developer or a very advanced user, we recommend that you do not attempt to use the trunk version of NuFW.

Upgrading

You should upgrade your installation at least when security announces are released in new versions. Security announces are always available at this URL.

Finding out the installed version

You can easily find out which version of the software you are using, with each NuFW component, by using the -V switch with any program that we distribute :

# nuauth -V
nuauth (version 2.2.18 ($Revision: 5020 $))
# nufw -V
NuFW (version 2.2.19)
# nutcpc -V
nutcpc (version 2.2.19 $Revision: 5350 $)
        

As an alternative, you can also use your distribution's package manager to find out, for instance :

$ dpkg -l nutcpc
[...]
ii  nutcpc         2.2.19-1+inl1  The authentication firewall [client]
        

Chapter 3. Compilation and installation

Default distribution kernels

The following distributions do NOT need a kernel recompilation to run NuFW [1]:

  • Fedora Core 6 (kernel 2.6.18)

  • Debian Etch (kernel 2.6.18)

  • Debian Lenny

Please note that a Linux kernel recompilation will only be needed on the Firewall itself (the host running the nufw daemon). The nuauth daemon should run on any POSIX system, and clients are, by essence, multi-platform (meaning, NO kernel dependency).

Kernel preparation

You only need to patch your kernel sources with patch-o-matic if you want to use userid marking (from Linux 2.6.14 there is no need to patch the kernel as this option is available in vanilla). This is necessary if you need to mark your network flows depending on the originating user ID, for instance, to perform per user Quality of Service. This is not needed to use NuFW. To do so, install patch-o-matic as usual and run

$./runme ip_queue_vwmark

Important note : it seems 2.6.24 netfilter_netlink capabilities only work if they are compiled as modules. Always compile these options as modules :

  • CONFIG_NETFILTER_NETLINK

  • CONFIG_NETFILTER_NETLINK_QUEUE

  • CONFIG_NETFILTER_NETLINK_LOG

  • CONFIG_NF_CT_NETLINK

Most distribution kernels come with these options compiled as modules.

Linux 2.6.14 and higher

If you run a kernel higher than 2.6.14 (and you should!), you should set the following options:

CONFIG_NETFILTER_XT_TARGET_NFQUEUE=Y or m
CONFIG_NETFILTER_NETLINK=Y or m
CONFIG_IP_NF_CONNTRACK=m (we advise you don't set this option statically)
CONFIG_IP_NF_CONNTRACK_EVENTS=Y

Setting these options will allow you to use the NFQUEUE target, and use very simple Netfilter rules.

NuFW compilation

Extract the source to the directory of your choice and go to the created directory.

NuFW uses autoconf and automake for compilation and a standard configure script is provided. Above standard options, the following flags (among other) are provided:

  • --with-mysql-log Support user activity logging in MySQL database

  • --with-pgsql-log Support user activity logging in PostgreSQL database

  • --with-system-auth Support PAM+NSS authentication

  • --with-ldap Support LDAP directory for users and acl lookups

A detailed list of the options is available via

$./configure --help

Thus you can run ./configure with the options you want and launch compilation and installation:

$ ./configure --with-ldap --with-system-auth --with-mysql-log \\
		--sysconfdir=/etc/nufw/
$ make
$ sudo make install

If you want to install default configuration files :

sudo make install-conf

This will only copy new configuration files when an old version of the file does not already exist in your $prefix/conf directory

Initial setup and tests

Certificates and client installation

This is about copying the default certificates. Don't do that unless on very early tests ; you probably want to generate your own certificates: see next section.

For nufw

cp conf/certs/nufw-*.pem /etc/nufw/

For nuauth:

cp conf/certs/nuauth*.pem /etc/nufw/
cp conf/certs/NuFW*.pem /etc/nufw/

Creating your own certificates

The management of certificates, or the use of a Public Key Infrastructure (PKI), is not covered in this howto. Using a dedicated software, like OpenCA or EBJCA, is suggested.

See section Hardening NuFW for details on how certificates are used in NuFW.

The following commands show how to quickly create a Certificate Authority, and some certificates for nufw and nuauth.

Generating your own Certificate authority:

mkdir private
chmod 700 private
openssl req -new -x509 -keyout private/CAkey.pem -out private/CAcert.pem

You have to set a strong password here and keep it secret.

Generating nufw and nuauth private keys:

openssl genrsa -out private/nufw-key.pem

openssl genrsa -out private/nuauth-key.pem

Generating Certificate Signing Requests for both nufw and nuauth keys:

openssl req -new -key private/nufw-key.pem -out nufw.csr

openssl req -new -key private/nuauth-key.pem -out nuauth.csr

Having our keys signed by the certificate authority we created:

openssl x509 -req -days 365 -in nufw.csr -CA private/CAcert.pem \
      -CAkey private/CAkey.pem -CAcreateserial -out nufw-cert.pem

openssl x509 -req -days 365 -in nuauth.csr -CA private/CAcert.pem \
      -CAkey private/CAkey.pem -CAcreateserial -out nuauth-cert.pem

Then, as in previous section, copy the files where needed: For nufw:

cp private/nufw-key.pem /etc/nufw/

cp nufw-cert.pem /etc/nufw/

For nuauth:

cp private/nuauth-key.pem /etc/nufw/

cp nuauth-cert.pem /etc/nufw/

And don't forget your key files (here, nufw-key.pem and nuauth-key.pem) should always remain private.

Basic nuauth setup

NuFW sources provide a sample configuration file for nuauth nuauth.conf which is available in the conf directory.

The two most important configuration variables are: nuauth_client_listen_addr which sets the address where nuauth listens for client requests and nuauth_nufw_listen_addr which sets the address where nuauth listens for nufw requests. The list of nufw servers authorized to connect to server nuauth is the nufw_gw_addr.

The next thing to do after setting this variable is to choose your authentication and acl checking module. Authentication modules for user have to be chosen in:

  • plaintext: user credentials are stored in a text file. It is advised not to use this module, except for quick testing : you need to restart nuauth when updating the text file. Instead, on production, you should run the system module. This format supports both plaintext and encrypted passwords, see the sample config file (named users-plaintext.nufw) for formatting and details.

  • system: authentication is done against PAM and groups are system groups. This provides a convenient way to use nss features and/or pam-modules. This is the recommended way, as it lets you authenticate against your LDAP, Active Directory, or any directory.

This is set with the option nuauth_user_check_module which default is libsystem (if not set in config file). Further choice for the acl checking module has to be done if you choose:

  • libldap : this is the recommended ACL checking module, as it is modular, and does not require a reload of the nuauth server when updating rules. You can manage iptables and LDAP rules in a consistent way, by using NuFace

  • plaintext : this module is intended to be used for quick testing only. It requires that you reload nuauth when modifying rules.

by setting the variable nuauth_acl_check_module.

Testing

To be able to proceed quickly to test, we will use the system module for user and the plaintext module for acl. A sample file for the plaintext acl check module is available in the conf directory, acls.nufw. Copy it to /etc/nufw and adjust the group of the ssh acl to have it matching the group of a system user you will use later to authenticate on the system.

Setting up Netfilter rules before 2.6.14

We will test the setup by connecting from the local host ssh server. For this we need to add filtering rules to ask for authentication:

iptables -A OUTPUT -s 192.168.75.0/24 -p tcp --dport 22 -m state --state NEW --syn -j QUEUE
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

[2]

Setting up Netfilter rules from 2.6.14

We will test the setup by connecting from the local host ssh server. For this we need to add filtering rules to ask for authentication:

iptables -A OUTPUT -s 192.168.75.0/24 -p tcp --dport 22 -m state --state NEW --syn -j NFQUEUE
iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

[3]

Testing the authentication system

First, the daemons need to be started. We start nuauth in a terminal

nuauth -vvvvvvvvv

then we start

nufw -s -vvvvvvvvv

in another terminal.

Note

When starting nufw or nuauth daemons without the -D switch, they do not run as daemon : they remain attached to the console. In such conditions, both programs log to STDOUT/STDERR instead of using syslog. On production, you should always start the daemons with the -D option.

Next, we can try to connect a user. Under Linux it can be done with:

nutcpc -N -d -U [USERNAME] -H [NUAUTH IP]

Next step is to enter the user's password. Without the -U option, the current system user's name is used.

At nuauth level, we should see something like:

user bill@nufw uses OS Linux, 3.0.10, #1 Tue Oct 19 23:51:32 CEST 2008

If your PAM setup is based on shadow file, you will not be able to authenticate a user different from the one running nuauth. On this kind of setup, nuauth needs to be run as root to authenticate other users. [4]

Initial tests and debug process

Let's authenticate a ssh connection from the computer.

  • nufw gets a packet from Netfilter:

    [PID] Sending request for 12

    12 is the ID of the packet inside the kernel.

  • nuauth receives nufw's request:

    * Message: NuFW Packet: src=127.0.0.1 dst=127.0.0.1 proto=6 sport=48505 dport=22, IN=lo OUT=, packet_id=12, mark=0
  • nuauth sends an authentication request to the clients on IP source:

    ** Message: Warn client(s) on IP 127.0.0.1
  • nuauth receives packet from the client:

    ** Message: User Packet: src=127.0.0.1 dst=127.0.0.1 proto=6 sport=48504 dport=22, mark=0, user=regit, \\
    OS=Linux 2.6.26-1-amd64 #1 SMP Wed Sep 10 15:31:12 UTC 2008, app=/usr/bin/ssh

  • nuauth sends back response to nufw:

    ** Message: Answ Packet: src=127.0.0.1 dst=127.0.0.1 proto=6 sport=48505 dport=22, decision=ACCEPT, IN=lo OUT=, \\
    packet_id=12, mark=1000, user=regit, OS=Linux 2.6.26-1-amd64 #1 SMP Wed Sep 10 15:31:12 UTC 2008, app=/usr/bin/ssh

  • nufw pushes the packet back in the kernel:

    [PID] (*) Accepting packet with id=12



[2] Only SYN packets are sent to QUEUE. This is not enough to do advanced user activities logging, but enough for traffic authentication.

[3] Only SYN packets are sent to NFQUEUE. This is enough to do advanced user activities logging, because events on the connections will be automatically sent to nufw by Netfilter. This requires, in particular, that the CONFIG_IP_NF_CONNTRACK_EVENTS kernel option be set.

[4] Never launch nutcpc against 'localhost' or '127.0.0.1', even if nuauth is on the same computer. Packets sent to nuauth by the firewall will hardly have the address of the loopback but rather have a source address which is one of the network interface.



[1] Please let us know if you find others ;)

Chapter 4. Setting up NuFW

Using the LDAP module for acl checking

Installation of OpenLDAP server (slapd)

OpenLDAP server installation is standard. Use your Linux distribution packages, example with Debian:

apt-get install slapd

Read OpenLDAP Software Administrator's Guide, section "Building and Installing OpenLDAP Software" to get more information.

Slapd configuration

The file acls.schema has to be put in /etc/ldap/schema and a line

include         /etc/ldap/schema/acls.schema

has to be added at the beginning of the /etc/ldap/slapd.conf. In the level of access setup in this file, one can add:

#INL access for acls
access to  dn="ou=acls,dc=nufw,dc=org"
       by dn="uid=nufw,ou=Users,dc=nufw,dc=org" write
       by dn="uid=nuauth,ou=Users,dc=nufw,dc=org" read
       by dn="cn=admin,dc=nufw,dc=org" write
       by * none

nufw user is able to modify the policy and the nuauth user can only read the acls.

To speed up search request you can add the following index to your slapd.conf:

index OsName,OsRelease,OsVersion,AppName pres,eq
index SrcIPStart,SrcIPEnd,DstIPStart,DstIPEnd pres,eq
index Proto,SrcPortStart,SrcPortEnd,DstPortStart,DstPortEnd pres,eq
index SrcPort,DstPort pres,eq

You can start with a LDIF file such as:

dn: dc=nufw,dc=org
objectClass: top
objectClass: dcObject
objectClass: organization
o: nufw.org
dc: nufw
structuralObjectClass: organization

dn: ou=Users,dc=nufw,dc=org
objectClass: organizationalUnit
ou: Users
structuralObjectClass: organizationalUnit

dn: ou=acls,dc=nufw,dc=org
objectClass: organizationalUnit
ou: acls
structuralObjectClass: organizationalUnit

dn: uid=nuauth,ou=Users,dc=nufw,dc=org
objectClass: top
objectClass: simpleSecurityObject
uid: nuauth
userPassword: nuauth

dn: uid=nufw,ou=Users,dc=nufw,dc=org
objectClass: top
objectClass: simpleSecurityObject
uid: nufw
userPassword: nufw

nuauth configuration

To use LDAP support for acl checking, we need to modify the nuauth.conf file:

nuauth_acl_check_module="ldap"

and we have to setup the connection parameters:

ldap_bind_dn="uid=nuauth,ou=Users,dc=nufw,dc=org"
ldap_bind_password="secretpassword"
ldap_basedn="dc=nufw,dc=org"
ldap_acls_base_dn="ou=Acls,dc=nufw,dc=org"

Using nuface, a web-based rules generator

INL has released a powerful Netfilter rules generator system for NuFW and Netfilter. It is called Nuface and it is available at: http://software.inl.fr/trac/wiki/EdenWall/NuFace It generates a set of rules for NuFW and Netfilter that can directly be applied from the web interface. All Netfilter rules generated by Netfilter use the stateful capabilities of Netfilter, without user intervention.

nuaclgen configuration

nuaclgen is a script that can help you maintain a simple set of acls in an LDAP tree.

It is advised that you use Nuface rather than Nuaclgen, if possible, since it makes things simpler. In particular, be aware that when you use nuaclgen, you need to also modify by hand your Netfilter rules.

The file nuaclgen.conf contains the informations about LDAP connections. It needs to be modified to suit your configuration, for example:

$ldap_host="localhost";
$username="uid=nufw,ou=Users,dc=nufw,dc=org";
$password="writepasswd";
$basedn="ou=Acls,dc=nufw,dc=org";

[5]

To allow ssh for users of group 513 if they use /usr/bin/ssh application, we can use:

nuaclgen --Aclname cn=ssh,ou=Acls,dc=nufw,dc=org -p 6 --dport 22 -AppName "/usr/bin/ssh" -j ACCEPT -g 513

Or for access directed to a web server:

nuaclgen --Aclname cn=apt,ou=Acls,dc=nufw,dc=org -p 6 --dport 80 \
  -AppName "/usr/lib/apt/methods/http" -j ACCEPT -g 1042

This ACL gives access to group 1042 which is used by root user of some server of ours. Thus root user can only get file to update the computer, but other users can not access the web.

Setting up NuFW authenticated connections tracking

nuauth settings

To achieve NuFW connection tracking it is necessary to have these options in nuauth.conf:

nuauth_log_users_sync=1
nuauth_log_users=9

Installation of MySQL server

MySQL server installation is standard. Use your Linux distribution packages, example with Debian:

apt-get install mysql-server

Read MySQL Documentation, section "2 Installing and Upgrading MySQL" to get more information.

Installation of PostgreSQL server

PostgreSQL server installation is standard. Use your Linux distribution packages, example with Debian (replace 8.2 by the latest server version):

apt-get install postgresql-8.2

Read PostgreSQL Documentation, section "III. 14. Installation Instructions" to get more information.

Note

Note that, even though nuauth PostgreSQL support is complete, you probably want to use a MySQL server for now, if you want to use Nulog. Single Sign On modules (apache and squid) have PostgreSQL support.

SQL configuration

The connection tracking system is really useful with SQL logging modules. We will describe here the setup of the MySQL module.

You have to create the SQL database from the dump file available in the conf/ subdir of the archive. Create a SQL account, which must have UPDATE, INSERT privileges on the "conntrack_ulog" table. You will have to set the credentials for that user in the nuauth.conf file.

You may choose between to schema an IPv4 only one and an IPv4/IPv6 one. Recent tools like Nulog2 are able to use the IPv6 schema. If you have old script or older tools, you better use the IPv4 only schema. To import the IPv4 schema into a newly created database, you can use:

mysqladmin create nufw
cat nulog.ipv4.mysql.dump | mysql nufw

For the IPv6 schema, simply use:

mysqladmin create nufw
cat nulog.ipv6.mysql.dump | mysql nufw

You may also want to rotate the "ulog" table, so that it doesn't grow to infinite size with time. The ulog_rotate.py script is available in the Nulog project tarball. At the present time, it is assumed those scripts are run as the root SQL user, as cronjobs. Of course the better way to go is to create a separate user for this and grant it the needed privileges. Please provide updates for this document if you implement this before we do.

Life of a connection in the SQL table

If nuauth is configured to log network flow information in a SQL database, here is how the logging system works :

  • When the connexion opening datagram is authenticated (for TCP, that is the SYN datagram), nuauth creates an entry in database, with a request looking like this (for TCP) :

    INSERT INTO conntrack_ulog (state, oob_time_sec, ip_protocol, ip_saddr, ip_daddr, oob_in, oob_out, oob_prefix, user_id,
    username, client_os, client_app, tcp_sport, tcp_dport) VALUES (... our datagram values ...);

    If nuauth decision for that datagram is to drop or reject it, log of the "connexion" stops here. The connexion will never be opened, and this database entry will no longer be manipulated by nuauth.

  • At the time when connection changes state (For TCP, and for any accepted connection, state changes to ESTABLISHED as soon as the server answers the SYN datagram), this request is performed by nuauth, if the nufw daemon is run with "-C" :

    UPDATE conntrack_ulog SET state=ESTABLISHED, start_timestamp=FROM_UNIXTIME(timestamp)
    WHERE (ip_daddr=%s AND ip_saddr=%s "AND tcp_dport='%hu' AND tcp_sport='%hu' AND state=OPEN)
    

    The only fields that are altered by this request are "state", which changes to "ESTABLISHED", and start_timestamp, which wasn't set before. It is important to note that no information is lost when this modification is performed. It is indeed obvious that the connection was previously in "OPEN" state, since that's a TCP preamble to the "ESTABLISHED" state, and the database keeps track of the timestamp when the connection was opened in the "oob_time_sec" field. The "start_timestamp" field simply marks the timestamp of switch to the "ESTABLISHED" state.

  • When the connection expires, this request is executed by nuauth, if the nufw daemon is run with "-C" :

    UPDATE conntrack_ulog SET end_timestamp=FROM_UNIXTIME(timestamp), state=CLOSE, packets_in=%d , packets_out=%d , bytes_in=%d , bytes_out=%d
    WHERE (ip_saddr=%s AND ip_daddr=%sAND tcp_sport='%hu' AND tcp_dport='%hu' AND (state=OPEN OR state=ESTABLISHED))
    

    State is updated, it becomes "CLOSE", and we set the end_timestamp field, which was empty before this, as well as packet number and byte number counters for the now dead connexion. Time of opening and time of establishment of the connection remain available in the oob_time_sec and start_timestamp fields.

The SQL logging feature keeps track of the whole history of each connexion, and updates that nuauth performs on the database do never erase data that was previously logged. This log mode is the most powerful one that a firewall can achieve, because it is very synthetic : one single SQL entry is maintained for each connection ; and it keeps the whole history of all elements of connections.

Netfilter settings

Settings on post 2.6.14 kernel

This is the good case compared to pre 2.6.14. To enable authenticated connection tracking, you only have to add the -C to nufw command line. This flag asks nufw to send any ESTABLISHED and DESTROY message coming from Netfilter connections tracking to nuauth.

As an important number of events can be sent through this mean, nufw offers the capability to only send a subset. It uses the fact that the initial mark can be put with CONNMARK on every packets of the connection. This mode is activated via the -M flag of nufw. On Netfilter side, the following rules have to be added:

iptables -A PREROUTING -t mangle -j CONNMARK --restore-mark
iptables -A POSTROUTING -t mangle -m mark ! --mark 0 -j CONNMARK --save-mark

In short, you should always use -C if you use libnetfilter_conntrack (this is available from linux 2.6.14), and you should use -M if you want all your connections marked per userID (please note that you need to apply transmit_mark patch on your kernel to use this). Library compatibility is better with a >=2.6.16 kernel.

Settings on pre 2.6.14 kernel

NuFW stores the following states in the life of a TCP connection:

  • opening: bit SYN is set

  • established: SYN ACK is sent

  • closed: the tcp flags are FIN or FIN,ACK

To match those packets we need to use the --syn and the --tcp-flags options. Let's use the following configuration as an example: our web servers are protected by a NuFW firewall. They are in the network $DMZ. The following rules achieve to realize a user connection tracking on the web server outgoing connections.

iptables -A FORWARD -p tcp -m state --state ESTABLISHED --tcp-flags ACK,FIN NONE -j ACCEPT
iptables -A FORWARD -d $DMZ -p tcp -m state --state ESTABLISHED --dport 80 --tcp-flags SYN,RST,ACK RST -j QUEUE
iptables -A FORWARD -d $DMZ -p tcp -m state --state ESTABLISHED --dport 80 --tcp-flags FIN FIN -j QUEUE
iptables -A FORWARD -s $DMZ -p tcp -m state --state ESTABLISHED --sport 80 --tcp-flags SYN,ACK SYN,ACK -j QUEUE
iptables -A FORWARD -p tcp -m state --state ESTABLISHED -j ACCEPT
iptables -A FORWARD -d $DMZ -p tcp --syn --dport 80 -m state --state NEW -j QUEUE

The first rule optimizes the filter by matching an important part of the ESTABLISHED traffic. The last rule with --state ESTABLISHED is the standard accepted established packets. It has to be put after NuFW flags matching rules.

Settings on >= 2.6.14 kernel

No special complicated rule should be set, the kernel will automatically send new events on connections to NuFW. This is the reason why you don't want to use a pre-2.6.14 kernel ;)

Using the connection tracking

nutop is a perl script provided with nufw sources. It is a top like tool that displays the active and authenticated connections in real-time.

The best way[6] to use the logs generated by the connection tracking is to install nulog which provides a convenient web interface. nulog is available under GPL on this page: http://software.inl.fr/trac/wiki/EdenWall/NuLog



[6] as far as the author of this document knows at the time of the writing of this document

Single Sign On setup

Apache

All you need to do is to setup a SQL user with SELECT permissions on the "conntrack_ulog" table. Then setup mod_auth_nufw to use the configured SQL user/database/table. The source code of the apache module is available at NuFW Apache SSO page

Squid

All you need to do is to setup a SQL user with SELECT permissions on the "conntrack_ulog" table. Then setup squid_nufw_helper to use the configured SQL user/database/table. The source code of the squid helper is available at NuFW Squid SSO page

Troubleshooting single sign on problems

General information

If you experience problems with Single Sign On problems, one common way to find out where the problem lays is to check whether the SSO code performs SQL lookups correctly. You can check it out easily at the database level. On MySQL, check you have in my.cnf something like:

log             = /var/log/mysql/mysql.log

This ensures that MySQL logs request that it receives. Then all you need to do is test the module, while running

tail -f /var/log/mysql/mysql.log

If the Single Sign On module is doing its job, you should see lines such as :

SELECT DISTINCT username FROM conntrack_ulog WHERE (tcp_sport=50423 AND ip_saddr=3232235761 AND tcp_dport=80 AND ip_daddr=3232235761 AND (state=1 OR state=2))

in the log, revealing that the Single Sign On module actually requests the database. If you run a PostgreSQL database, you can do similar operations by setting

log_min_duration_statement = 0

in postgresql.conf. On Debian, the default PostgreSQL log file is probably located in /var/log/postgresql/postgresql-8.X-main.log.

Apache module troubleshooting

Like any Apache module, the mod_auth[n]_nufw module dumps verbose/debug information in the Apache error log when you set :

Loglevel debug

in the Apache httpd.conf file.

User based Quality of Service

Setting up Kernel on non libnetfilter_queue system

Official Linux kernels are not able to mark packets with ip_queue framework before 2.6.14 release. It is thus necessary to patch the kernel (if pre 2.6.14), this has to be done by using the ip_queue_vwmark patch available in the patch-o-matic-ng from netfilter. This will generate a modified version of both ip_queue module and libipq.a file.

Once the new libipq.a is installed, you can now compile nufw:

./configure --with-user-mark ${EXTRA_OPTIONS_YOU_LIKE}
make
make install

Setting up nufw

nufw can now be run with -m to use userid marking. This option is compatible with -M.

Setting up Netfilter

As nufw only works with initialization packets it can not pull the userid mark of each packet of a connection. Thus, this is necessary to use CONNMARK[7] which is a target able to propagate marks across connections. A basic setup is the following:

iptables -A PREROUTING -t mangle -j CONNMARK --restore-mark
iptables -A POSTROUTING -t mangle -j CONNMARK --save-mark

First line restores the existing mark when a packet arrives and second line saves mark on the connection so it can be restored later.

Using marking modules

The nuauth variable nuauth_finalize_packet_module lists module which attach a hook called just before nuauth answer to nufw about a packet. It is usually used to modify the mark of the packet following a given strategy. By splitting the mark in different part, this is possible to define complex marking policy which can later be used by Linux routing and QoS systems.

Extensive documentation can be found in the file README.mark

Using NuFW mark

Netfilter mark can be use by the Quality of Service system and the routing system of Linux.

So it is possible to do differentiated routing between different users by using command like:

ip rule add fwmark XXX lookup TABLE

This is almost the same for QoS, by using tc filter one needs to put user's flows in a specific class:

tc filter add dev IFACE  prio 5 protocol ip handle 102 fw flowid FLOWID

For more information about routing and quality of service you can read lartc.



[7] CONNMARK is only available in patch-o-matic before 2.6.11, it is included in 2.6.12+ kernels

Controlling nuauth finely at runtime

NuFW 2.2.0 introduced new nuauth control capabilities, thanks to nuauth_command. This command should be installed when you install nuauth, and it can be run by the administrator, on the same server as nuauth. nuauth_command connects to nuauth, and lets you do the following tasks :

  • help display inline help with a summary of available subcommands

  • version display nuauth version

  • users list connected users

  • firewalls list connected nufw firewalls

  • packets count display number of decision waiting packets

  • refresh cache refresh all caches

  • refresh crl refresh the TLS crl file

  • disconnect (ID|regexp) disconnect a user with his session identifier or a regular expression apply on logging name.

  • disconnect all disconnect all users

  • uptime display nuauth starting time and uptime

  • reload reload the configuration and reload the modules

  • reload periods reload the time periods

  • display debug_level

  • display debug_areas

  • debug_level LEVEL

  • debug_areas AREAS

  • help display this help

  • quit disconnect

You can, for instance, use the disconnect task, in order to force a user reconnect, and have their groups reloaded.

Note

As a POSIX compliance, nuauth checks the user's authentication, as well as groups, at the time the user's NuFW agent connects. It is never refreshed, until the client disconnects, or the administrator forces a disconnect. Nuauth configuration file nuauth.conf can also force all users to reconnect regularly, by setting the nuauth_session_duration parameter.

Time-based ACLs

Global configuration

NuFW can be used to implement strict time-based acls. When a period using time interval is defined (like say 08am-6pm) a authenticated connection can only start in the interval and is destroyed at the end of the interval.

Configuration is done by defining a set of periods and using them (by their name) in the acls backend. The plaintext acl backend uses the period key to defined the period to apply to the acl. The LDAP acls backend uses the TimeRange atttribute.

Definition of periods is done by modules and the corresponding option is nuauth_periods_module. For now, the only available module is xml_defs.

XML period definition module

xml_defs is a period definition module. It uses a XML formatted file to store the periods. The path to this file can be set by using the xml_defs_periodfile:

xml_defs_periodfile="/etc/nufw/periods.xml"

The XML structure of the file is the following:


<?xml version="1.0"?>
<periods>
<period name="5x8" desc="open hour">
    <perioditem>
        <days start="1" end="5"/>
        <hours start="8" end="18"/>
    </perioditem>
</period>
<period name="long" desc="date example">
    <perioditem>
        <dates start="1128282" end="323232323"/>
    </perioditem>
</period>
<period name="interval" desc="one hour interval">
    <perioditem>
        <!-- Duration in second (1 hour) -->
        <duration length="3600"/>
    </perioditem>
</period>
</periods>

There are two major types of period definitions:

  • Time interval: the period is defined by using specifying days, hours or dates interval. Days and hours can be combined to define more complex period.

  • Duration: the period is defined by a duration expressed in seconds.

Multiple perioditem can be put in the same period to increase the flexibility of period definition.

Note

When using Nuface to manage filtering rules, time-based ACLs can be setup through the web interface, without editing any file by hand.

Chaining modules in nuauth

Syntax description

The syntax is the following: Each option that sets up the use of a hook is a space separated list of modules.

For each module type, the syntax is as follows : name[:type[:config file]] If syntax is:

  • name: loads module "name" with config file included in nuauth.conf

  • name:type: loads module "type" with config file CONFIG_DIR/modules/name.conf

  • name:type:conf: loads module "type" with config file "conf"

Some examples

Let's analyze the following line: nuauth_user_logs_module="syslog dblocal:mysql maindb:mysql:/etc/nufw/mainmysql.conf" Packet will be logged multiple times:

  1. In syslog

  2. In a MySQL database using configuration file /etc/nufw/modules/dblocal.conf

  3. In a second MySQL database using configuration file /etc/nufw/mainmysql.conf

Hardening NuFW

Nufw certificate verification

It is highly recommended to install nuauth and nufw on a dedicated server, hardened for security. Other projects like GrSec [8] or SELinux [9] can be used to increase local (system) security.

Note

Since NuFW 2.2.19, a SeLinux configuration is distributed in the selinux/ directory of the archive. Read the README.selinux file there if you want to implement SELinux policies to the NuFW daemons. However, this security policy set is not yet considered stable and is distributed for testing purpose. You are welcome to send the NuFW team feedback about it!

To ensure confidentiality of communications between nufw, nuauth, and the clients, all connections are encrypted using TLSv1.

As the firewall policy is applied by nuauth, the trust relationship between nufw and nuauth should be verified. The certificate provided by nuauth during the TLS negotiation will be checked if a certificate authority is configured in nufw. This is done by using the -a option at start of nufw followed by the name of the certificate authority file. With this option set, nufw will require a signed certificate from nuauth, and verify it.

The CN (complete name) field from nufw certificate must contain the FQDN (fully qualified domain name) of nufw server.

Since release 2.2.18, NuFW runs in TLS strict mode by default. It means nufw will not start if nuauth certificate is:

  1. Not verifiable against an authority

  2. Invalid

  3. Revoked

  4. Without signer

  5. Signed, but the signer is not a CA

  6. With an insecure algorithm (if GnuTLS is compiled with its support)

  7. Not yet activated

  8. Expired

See the Managing finer TLS settings with NuFW section of this document for advanced TLS options of nufw and other components.

Warning

Since release 2.2.18, this mode is now activated by default. You can disable it, at your own risks, using the -s option of nufw.

To run nufw with strict TLS checking, you will have to specify the following option:

  • -a: Specify the authority file to use.

  • -k: Specify the key file to use.

  • -c: Specify the certificate file to use.

  • -r: Specify the certificate revocation list file to use (if available). A nufw restart or a SIGHUP signal will be needed if you want change to the file to be taken into account.

  • -d: Fully qualified domain name of the nuauth server.

Thus a typical nufw command line should look like:

nufw -d nuauth.nufw.org -a localCA-cacert.pem -k server.nufw.org-key.pem -c server.nufw.org-cert.pem -r localCA-crl.pem

Note

OCSP is currently not supported by NuFW 2.2.X. OCSP support is being worked on in the trunk (currently unstable) branch of NuFW. Please contact NuFW developers if you need OCSP in 2.2.X, maybe we can add it to the 2.2 TODO list.

Authentication server (nuauth)

The option nuauth_tls_request_cert defines if client certificates are optional or not. Possible values are:

  • 0: nuauth will not ask client to provide a certificate, they won't send one even if they have some to give.

  • 1: client is asked to send a certificate, but the server will not refuse connection if none is provided.

  • 2: client is asked to send a certificate, and the server will drop the connection if none is provided.

The default setting (nuauth_tls_request_cert=2) is that nuauth will require and verify client certificates for all connections (clients, and NuFW servers). Certificates are used to verify the identity of all components of a NuFW installation (nufw, nuauth, and clients), and ensure that no forgery or false representation has occurred.

All components must share the same certificate authority (CA). See the Managing finer TLS settings with NuFW section of this document for advanced TLS options of nuauth and other components.

The CN (complete name) field from nuauth certificate must contain the FQDN (fully qualified domain name) of nuauth server. All clients and nufw servers will check that the DNS name of nuauth server matches the name in the certificate.

Note

It is possible to generate a certificate with additional names, using the subjectAltName extension (See Section 4.2.1.7 of RFC 3280).

You have to:

  1. Configure the certificate authority (nuauth_tls_cacert)

  2. Configure nuauth certificate (nuauth_tls_cert) and key (nuauth_tls_key) files.

  3. Deploy client certificates. If you only want to verify server identity, you can share a certificate between several clients. If you want to use certificates for authentication, or if you will revoke certificates, you have to deploy a certificate for each client.

Warning: since release 2.2.18, this mode is now activated by default. You can disable it, at your own risks, by setting nuauth_tls_request_cert=0 in nuauth configuration file.

nuauth will check that the CN (complete name) field from nufw certificate contains the FQDN (fully qualified domain name) of the nufw server. You can disable it, at your own risks, by setting nuauth_tls_disable_nufw_fqdn_check=1 in nuauth configuration file.

You should also configure a Certificate Revocation List (CRL), with the nuauth_tls_crl parameter in nuauth configuration file. This file contains the list of all revoked certificates, in standard CRL format. You have to create a planified task (cron job) to update this file periodically, nuauth will check for modifications every nuauth_tls_crl_refresh seconds and will reload the file if necessary. You can use the HUP signal or the refresh crl command to force an update of the CRL.

Note

Note that currently, private keys cannot be password protected : neither nufw nor nuauth support entering a passphrase. The reference documentation mentions the nuauth_tls_key_passwd option, but it is not implemented for now.

User authentication restrictions

You can restrict the number of simultaneous nuauth clients, per user or per IP address.

  1. nuauth_single_user_client_limit: maximum number of nuauth clients per user

  2. nuauth_single_ip_client_limit: maximum number of nuauth clients per IP

On client side

nuauth client (nutcpc or nuapplet) will verify nuauth certificate when connecting, if a certificate authority is configured on the client (option -A of nutcpc). The certificate of the nuauth server will be verified, and the DNS name must match the CN field of the certificate. See the Managing finer TLS settings with NuFW section of this document for advanced TLS options of nutcpc and other components.

You can disable, at your own risks, the verifications:

  1. If no certificate authority is defined, the trust relation with nuauth will not be checked. Other attributes of nuauth certificate (expiration,etc.) will be checked, though.

  2. Option -N disables the verification of the DNS name of nuauth server.

  3. Option -Q disables warnings if no certificate authority is configured.

Clients should provide a client certificate, signed by the same authority.

  1. If the certificate is used to login, the name of the user must be stored in the CN field of the client certificate.

  2. If the certificate is not used to login, the CN field of the client certificate is not checked.

The nutcpc client supports multiple options to achieve a strict verification of nuauth certificates:

  • -A: Specify the authority file to use.

  • -K: Specify the key file to use.

  • -C: Specify the certificate file to use.

  • -R: Specify the certificate revocation list file to use. A nutcpc restart or a SIGHUP signal will be needed if you want change to the file to be taken into account.

  • -H: Fully qualified domain name of the nuauth server.

To sum up a typical nutcpc command line should look like:

nutcpc -H nuauth.nufw.org -A localCA-cacert.pem -K client.nufw.org-key.pem -C client.nufw.org-cert.pem -R localCA-crl.pem

It is possible to use the configuration file nuclient.conf to specify value for these options and be able to run client without having to specify all options on the commandline. A typical nuclient.conf should look like.

# Name of the nuauth server (fully qualified domain name, or IP address).
nuauth_ip=nuauth.nufw.org
# Certificate authority used to check the validity of nuauth certificate
nuauth_tls_ca=/etc/nufw/localCA-cacert.pem
# Certificate file used to negotiate the TLS connection to nuauth.
nuauth_tls_cert=/etc/nufw/client.nufw.org-cert.pem
# Key of the certificate file from the nuauth_tls_cert option.
nuauth_tls_key=/etc/nufw/client.nufw.org-key.pem
# Certificate revocation list file to use.
nuauth_tls_crl=/etc/nufw/localCA-crl.pem

To combine strict TLS usage and login/password authentication, the recommended setup for client certificate deploiement is to deploy a per-computer certificate with FQDN matching computer domain name with the associated CA and key in the configuration directory of NuFW (usually /etc/nufw/). By setting the correct values in /etc/nufw/nuclient.conf (as previously seen), the computer user will be able to run client without providing any options (omit for -U option which is needed if the local user name is different from the nuauth user name).

Certificate authentication

Certificates can be used to authenticate clients, if a user provides a client certificate during the TLS negotiation. Nuauth will extract the username based on the CN of the provided certificate. The username computation is made by taking the CN string till a slash or a comma is encountered. For example, for admin/email=admin@inl.fr, it will return admin. The obtained username must match a known user on the system. Nuauth will check the certificate, and if validated, will mark the user as authenticated (no password asked).

To activate this functionality, nuauth configuration file must include:

nuauth_tls_auth_by_cert=1

Note that, nuauth_tls_request_cert has to be set to 1 or 2 in the mean time. If set to 2, certificates authentication is mandatory.

Using secure LDAP (LDAPs) for ACLs checking

If the LDAP server supports TLS connections, you should setup nuauth to have the LDAP acls checking module using LDAP over SSL.

To do so, edit nuauth.conf and modify LDAP port to 636 (LDAPs):

ldap_server_port=636

Then, edit /etc/ldap/ldap.conf to indicate the policy used for SSL connections. If you only want to encrypt data, you can simply add to ldap.conf:

TLS_REQCERT never

The recommended setup is to fill in ldap.conf with the path to certificate authority. ldap.conf should look like:

TLS_CACERT /etc/ldap/cacert-ldap.pem
TLS_REQCERT demand

Please note that the certificate must precisely match the hostname set in the ldap_server_addr option in nuauth.conf.

See the TLS section in LDAP Configuration guide, and OpenLDAP TLS FAQ for more information.

OS and application filtering

On client side, system needs to be trustworthy to perform valuable application and OS filtering. You must never forget that it is the application on client side which tells the application name as well as the operating system name and version: these informations CAN and WILL be spoofed if a malicious user installs a modified NuFW agent.

Thus, the value of application and OS filtering depends on the trust you have on the system which issues the authentication. On a secure system (for ex. SELinux) where users can not install software, this sort of filtering is "quite secure".

Intrusion Detection System (IDS)

NuFW is free software, and as such does not duplicate features from other softwares, but prefer to integrate with them, to benefit from their experience, and specific features.

For example, NuFW is a native Prelude[10] sensor, using the nuprelude module. This allows to send alerts (user login success or failure, connections, etc.) to Prelude, and use correlation, for ex., to combine a Network IDS like Snort[11].

See Prelude user manual, and Configuring NuFW for Prelude for more information.

Note

It is to be noted that, for now, all TLS certificates of your installation must be signed by the same CA, for valid checks to be performed. It is planned to implement support of chained CAs in a future release (possibly 2.2.20). Currently, using chained CAs might work, and might not. The behavior of NuFW with chained CA is considered to be unspecified for now.



[8] http://www.grsecurity.net/

[9] http://www.nsa.gov/selinux/

[10] http://www.prelude-ids.com

[11] http://www.snort.org/

Nuauth authentication configurations

PAM/LDAP authentication with Nuauth

PAM is a very convenient way for extending authentication to "exotic" directories. In particular, PAM lets one interface nuauth on NT domains, Active Directory, Radius, etc.

Note

When using PAM authentication for local users (shadow file), nuauth must run as root to be able to read system files. This is the only case where nuauth should be run as root ! It is, however, advised, that you use a real directory (LDAP, Active Directory...) rather than authenticating users against the shadow file.

To have nuauth authenticate users based on PAM/ldap, use the system user checking module in nuauth.conf:

nuauth_user_check_module="system"

In addition, PAM needs to be properly setup, which is external to NuFW, and basically out of the scope of this document. Here are a couple of files to set on Debian to get PAM/LDAP working with nuauth: /etc/pam.d/nuauth:

#This is to set PAM-LDAP, modify to suit your needs!
  auth    required      /lib/security/pam_env.so
  auth    sufficient    /lib/security/pam_ldap.so
  auth    required      /lib/security/pam_deny.so

  account required      /lib/security/pam_ldap.so

  session required      /lib/security/pam_limits.so
  session optional      /lib/security/pam_ldap.so

The /etc/nsswitch.conf file also needs to be tuned:

#This is to set PAM-LDAP, modify to suit your needs!
  passwd:         compat ldap
  group:          compat ldap
  

(leave the other lines unchanged). And you probably also need to tune the /etc/pam_ldap.conf file. This file works for us, provided there is no line beginning with "uri":

  host 127.0.0.1
  ldap_version 3
  scope one
  pam_password crypt
  nss_base_passwd         ou=Users,dc=nufw,dc=org?one
  nss_base_group          ou=Group,dc=nufw,dc=org?one
  

You also need to install and configure libnss-ldap. Configuration that works for us (still on Debian) in /etc/libnss-ldap.conf:

  host 127.0.0.1
  base replace_with_your_base
  ldap_version 3
  rootbinddn cn=admin,dc=replace_with_your_base
  #Optional, set if you need these:
  nss_base_passwd ou=users,dc=nufw,dc=org?one
  nss_base_group ou=groups,dc=nufw,dc=org?one
  

Of course, tune this to suit your needs, and be aware that these system instructions may not be accurate for other distributions!

PAM/Winbind authentication with Nuauth

On Debian/Ubuntu, you will need the following packages:

    krb5-user
    krb4-config
    samba
    winbind
   

The /etc/krb5.conf file should contain something like:

[libdefaults]
        default_realm = DOMAIN.NAME
# The following krb5.conf variables are only for MIT Kerberos.
        krb4_config = /etc/krb.conf
        krb4_realms = /etc/krb.realms
        kdc_timesync = 1
        ccache_type = 4
        forwardable = true
        proxiable = true

[realms]
        DOMAIN.NAME = {
                kdc = 10.0.122.5
                admin_server = 10.0.122.5
                default_domain = DOMAIN.NAME
        }

[domain_realm]
        .domain.name = DOMAIN.NAME
        domain.name = DOMAIN.NAME
        shortname = DOMAIN.NAME
        .shortname = DOMAIN.NAME
   

It is very important that your system is time-synchronized with the AD/NT server. You should setup NTP to achieve this!

The /etc/samba/smb.conf file should also be customized:

[global]
# Change this to the workgroup/NT-domain name your Samba server will part of
   realm = DOMAIN.NAME
   password server = AD-SERVER
   netbios name = NUAUTH-SERVER
   workgroup = SHORTNAME

# server string is the equivalent of the NT Description field
   server string = %h server sexa-prn1 (Samba, Ubuntu)

####### Authentication #######

   security = ads
   encrypt passwords = true
   guest account = nobody

############ Misc ############

   socket options = TCP_NODELAY
   domain master = no

# Some defaults for winbind (make sure you're not using the ranges
# for something else.)
   idmap uid = 10000-20000
   idmap gid = 10000-20000
   template shell = /bin/bash

   template homedir = /home/%D/%U
   client use spnego = yes
   client ntlmv2 auth = yes
   restrict anonymous = 2
   

To join the Windows Domain:

kinit administrator@DOMAIN.NAME

net ads join -U administrator

The last command should display the short domain name, and should specify that the machine was successfully added to the domain.

Winbind (or winbindd) should be running on your system. You can check things are going fine by reading samba logs (probably in /var/log/samba/*).

You will then have to declare that you want to use winbind authentication for nuauth by cooking a /etc/pam.d/nuauth file:

#This is to set PAM-winbind, modify to suit your needs!
  auth    required      /lib/security/pam_env.so
  auth    sufficient    /lib/security/pam_winbind.so
  auth    required      /lib/security/pam_deny.so

  account required      /lib/security/pam_winbind.so

  session required      /lib/security/pam_limits.so
  session optional      /lib/security/pam_winbind.so

To be able to use winbind group fetching, the /etc/nsswitch.conf file should look like:

passwd:         compat winbind
group:          compat winbind
shadow:         compat

hosts:          files dns mdns
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis
   



[5] The nuaclgen.conf file contains sensitive data and thus must have limited rights.

Chapter 5. Authentication Agents

Supported OSes

Windows

NuWinC (NuFW Windows Client) provides NuFW authentication for Microsoft Windows 95/98/NT/2000/XP/2003/Vista. This software is available from INL. NuWinC can provide, when installed on machines of a Windows domain, a 100% transparent behavior, meaning users will not even notice it starting or running. For more information about NuWinC, see http://www.inl.fr/NuWINc,68.html.

Linux

Several clients run on Linux :

  1. nutcpc : the lightest, command line agent.

  2. Nuapplet2 : The graphical client.

  3. PAM authentication, through the pam_nufw module. This provides transparent authentication on nuauth.

MacOS

MacOS X is supported by the Nuapplet2 graphical client. The nutcpc command line client also runs on MacOS X.

UNIX and BSD systems

nutcpc is known to work on FreeBSD. For other systems, test feedbacks are greatly welcome! Porting NuFW agents to *NIX systems should be fairly easy, too.

pam_nufw

The pam_nufw PAM module enables transparent user authentication to NuFW. Of course, this will only work if the login and password you use to login to the pam_nufw system are the same as requested by nuauth, ie in your user directory!

Options

pam_nufw accepts the following command line options:

  • server=nuauth_ip: Nuauth server IP/hostname

  • port=nuauth_port: Nuauth port/service name

  • lock=.pam_nufw: Lock filename

  • noauth=user1,user2,(...): Don't authenticate these users.

Default values:

  • port is 4129

  • lockfile is .pam_nufw, located in $HOME/.nufw/

Configuration file example

PAM configuration files are located in /etc/pam.d/. Each program which uses PAM may have its own file (eg. /etc/pam.d/ssh and /etc/pam.d/kdm) ; it is up to the administrator to choose which programs should trigger the pam_nufw authentication. Of course, requisite are :

  • The program concerned by the configuration is about opening a session.

  • The program concerned by the configuration runs on the userID you want to authenticate connections for.

  • The authentication is performed through a login and password.

A typical configuration file looks like this:

 #%PAM-1.0
 auth    requisite       pam_nologin.so
 auth    required        pam_env.so
 @include common-auth
 auth optional pam_nufw.so server=nuauth.inl.fr port=4129
 @include common-account
 session required        pam_limits.so
 @include common-session
 session optional pam_nufw.so server=nuauth.inl.fr port=4129
 @include common-password

We use auth because we have to know user's password in order to authenticate on nuauth. The pam module closes the connection to nuauth when the application closes the pam session. You can comment out the session line to suppress disconnection at logout.

Note

Make sure you use the same lock file for all pam_nufw config files on a given system, or connections will be authenticated multiple times.

pam_nufw respects the nuclient.conf configuration file for all options. See section Hardening NuFW for more information about nuclient.conf usage and TLS setup.

Chapter 6. Miscellaneous

Supported protocols

The NuFW daemons can virtually support any protocol, provided a stateful inspection exists in Netfilter to deal with the given protocol. However, the main concern about protocol support is client-side.

  • TCP: TCP is supported by all existing clients (Linux, MacOS X, Windows).

  • UDP: Requires some administrator operations, for now only the Windows client supports UDP.

  • ICMP: Uses raw socket. We are unsure whether this can be authenticated at all. For now, no client supports ICMP.

  • IPv6: IPv6 is supported since branch 2.2, with the same restrictions as IPv4.

  • other: No support. Contact us if you feel some other protocol could be supported.

Big endian architectures

Big endian architectures are supported since version 1.0.11. Prior releases do not work on big endian.

System with glibc 2.3.2

Glibc 2.3.2 is buggy and you need to set system_glibc_cant_guess_maxgroups to the maximum number of groups for a single user.

Linux distributions specific

Packages can be provided by some distributions. However, these packages can be modified by the maintainer, or might not be up to date, so check the local modifications carefully.

While these packages can be good, it is encouraged to use the official releases from nufw.org, which are officially supported by the developers.

Debian specific

NuFW packages are part of the Debian main distribution.

Note

However, we recommend that you use the latest available NuFW version. Debian packages are available at packages.inl.fr

Mandrake specific

NuFW is packaged in Mandriva Corporate Server 4.

Suse specific

Suse version 9 seems to use a very old Glib, which is not compatible with NuFW. It seems this is true for all Suse versions until v9.

Redhat specific

RedHat Enterprise Linux 4

As RHEL4 is shipped with a 2.6.9 kernel that is subject to the ip_queue problem mentioned later in this document. With this kernel the bug occurs systematically (at least on SMP machines).

Known issues

Problem with ip_queue on kernel prior to 2.6.12

There's an ip_queue bug on kernels prior to 2.6.12. It can hang the system when an ACCEPT decision is done on the INPUT chain. Thus DO NOT use a QUEUE target on INPUT with these kernels or it could freeze your computer. And anyway, you should use a recent kernel and NFQUEUE, as explained here-up in this howto.

Running NuFW in a bridged network

NuFW should run seamlessly in bridge networking. However it seems a bug in some kernel does not allow the use of nfnetlink without problems. The following facts were reported (with NuFW 2.2.14, but NuFW versioning is not the matter) :

  • Kernel 2.6.22 BUG : No network traffic when launching the nufw daemon.

  • Kernel 2.6.24 Everything works.

Chapter 7. Appendix

Managing finer TLS settings with NuFW

Table 7.1, “nufw daemon (command line) TLS options resume” describes the TLS options that the nufw daemon accepts. All these options are accepted since the 2.2.18 release (some options existed earlier).

Table 7.1. nufw daemon (command line) TLS options resume

OptionDescription
-kspecifies as argument the filename of the (private) key to use.
-cspecifies as argument the filename of the (public) certificate to use.
-aspecifies as argument the filename of the certificate authority file.
-NIf you use this switch, nufw will skip the nuauth CN check.
-rspecifies as argument the filename of the certificate revocation list. The daemon will also re-read the revocation list if it is disconnected from nuauth and needs to reconnect. Since 2.2.19, nufw reloads this file when receiving a HUP signal.
-nspecifies as argument the string of the expected DN that should be received by nuauth. The DN advertised by nuauth will have to match the string exactly, else nufw will drop the connection. If you do not specify this option, the DN of the certificate will be checked against the FQDN of the nuauth server (nufw will obtain it from a reverse DNS lookup on nuauth IP address).
-SRequest that nufw strictly validates the TLS connection when opening the connection to the nuauth server. This means that the nuauth certificate has to be signed by the CA, that it is not revoked, and that the DN of the certificate is also checked (see the -n) option. Since 2.2.18, this is the default behaviour of the nufw daemon.
-sOpposite of -S. This means all TLS checks are disabled. Use at your own risk!!


Table 7.2, “nuauth daemon configuration TLS options resume” describes the TLS options that the nuauth daemon accepts (in nuauth.conf). All these options are accepted since the 2.2.18 release (some options existed earlier).

Table 7.2. nuauth daemon configuration TLS options resume

OptionDescription
nuauth_tls_keyspecifies as argument the filename of the (private) key to use.
nuauth_tls_certspecifies as argument the filename of the (public) certificate to use.
nuauth_tls_cacertspecifies as argument the filename of the certificate authority file.
nuauth_tls_crlspecifies as argument the filename of the certificate revocation list.
nuauth_tls_crl_refreshspecifies the time period (in seconds) at which nuauth refreshes the nuauth_tls_crl file.
nuauth_tls_request_certWhether nuauth performs TLS checks. Since 2.2.18, the default value is 2, which means that all certificates need to be signed by the CA, must not have expired, and must not be revoked. If you specify 0, nuauth will perform no TLS check at all (use at your own risk!!). If you specify 1, nuauth will ask the clients and nufw to provide a certificate, but will not fail if no certificate is provided. You should always use the default setting of 2 if you want a safe installation!
nuauth_tls_disable_request_warningIf you set nuauth_tls_request_cert to an insecure value, nuauth will complain in the log everytime a client connects, but will not reject connections. If you want to prevent such logging from nuauth, you can set this option to 1. The default value is 0.
nuauth_tls_disable_nufw_fqdn_checkIf you set nuauth_tls_request_cert to 2 (the default value), the nufw daemon certificate DN will be checked against the nufw fully qualified domain name (which nuauth obtains thanks to a reverse DNS lookup). If they do not match, nuauth will reject the connection. You can set this parameter to 1 if you want nuauth to accept the connection without checking this match.
nuauth_tls_auth_by_certThis lets clients authenticate with a certificate, rather than with a login/password.


Table 7.3, “nutcpc command line TLS options resume” describes the TLS options that the nutcpc client accepts on command line. All these options are accepted since the 2.2.18 release (some options existed earlier). You can also get nutcpc to read configuration from nuclient.conf config file (see below).

Table 7.3. nutcpc command line TLS options resume

OptionDescription
-Cspecifies as argument the filename of the (public) certificate to use.
-Aspecifies as argument the filename of the certificate authority file.
-Kspecifies as argument the filename of the (private) key.
-Wif you use a keyfile (with -K), and it is password-protected, you can specify the password to use with this switch. Use with -q for security reasons.
-Rspecifies as argument the filename of the certificate revocation list. This file is only checked when nutcpc is launched : you currently need to stop and restart nutcpc if the revocation list is changed. Since 2.2.19, nutcpc reloads this file when receiving a HUP signal.
-aspecifies as argument the string to use to check the CN nuauth certificate contains. If you do not use this option, nuauth certificate DN will be checked against nuauth fully qualified domain name, which will be found by performing a reverse DNS lookup on nuauth IP address.
-NIf you use this switch, nutcpc will skip the nuauth CN check.
-QBy default, nutcpc leaves with an error if the CA is not configured (see -A), and (since 2.2.19) forces user to type "yes" to bypass the warning. If you use this option, the problem will be ignored. Use at your own risk!!


Table 7.4, “nuclient.conf TLS options resume” describes the TLS options that the libnuclient client accepts on command line. All these options are accepted since the 2.2.18 release (some options existed earlier). Currently, these options work with nutcpc, as well as nuapplet.

Table 7.4. nuclient.conf TLS options resume

OptionDescription
nuauth_tls_certspecifies as argument the filename of the (public) certificate to use.
nuauth_tls_caspecifies as argument the filename of the certificate authority file.
nuauth_tls_keyspecifies as argument the filename of the (private) key.
nuauth_tls_crlspecifies as argument the filename of the certificate revocation list. This file is checked when the client is launched, and anytime the client is disconnected from nuauth and needs to reconnect.
nuauth_suppress_fqdn_verifIf set to 1, the client will skip the nuauth CN check.


Glossary

nufw

nufw is the server running on the firewall which receives the packets coming from kernel and send them to the authentication server and wait a response.

nuauth

nuauth is the authentication server which receives the packets coming from nufw and the packets coming from user and send back a decision to nufw.