User-level firewalling with Portsmith
The Linux packet filter iptables lacks a function that dynamically enables ports for authenticated users. Portsmith plugs this gap, allowing users to enable their own connections.
Check Point and Cisco administrators are familiar with firewalls that enable ports after a user logs in. Unfortunately, this technique, sometimes referred to as Client Authentication or Cut-Through Proxy, is often subject to restrictions. Because of the problems associated with authenticating firewalls, iptables does not include this functionality out of the box. Of course, you could add your own custom authentication feature with some scripting, but few admins go to so much effort.
Portsmith  offers a free and easy option for authentication at the firewall, and this innovative tool even lets authenticated users enable ports in their own web browsers. To avoid potential security threats, the administrator still keeps control of the permissions. Each user is assigned a set of required communication links and can only access the resources assigned to those links. This approach stops users from simply punching holes in the firewall ruleset anytime they feel the urge.
One potential application for a Portsmith firewall is as a replacement for a virtual private network (VPN). The traffic is stopped at the firewall until a user authenticates, and once the user logs in, only traffic from the user's IP address is admitted. By ensuring that a specific service is only available to the authenticated user, the admin can avoid the need for a dedicated VPN server. On the other end, the client also does not need special software to initiate the connection. According to the Portsmith website, "… you can take control of your office computer from home, from a friend's house, from a WiFi hotspot, or from any other location with Internet access. Since there is no software requirement, after you leave the location, there will be no trace that you were ever there, and nothing is installed on the computer you were using." Another of Portsmith's goodies is an integrated, browser-based backup solution. Just point and click to write the ruleset, critical files, and database to a CD.
Portsmith prefers Ubuntu 8.0.4 Server LTS . Of course, you can also use other distributions, although you will need to modify the paths and component handling to match Portsmith's requirements. Portsmith is designed to work with the Apache web server , the PHP5 module , and the PostgreSQL database module . Tough luck if you prefer a different database system; other systems are not supported.
The web server acts as a front end for the administrator and users. Accounts are stored in the database. The dynamic ruleset is also stored in the database and retrieved from the database whenever it is needed. Scripts running in the background regularly generate the corresponding iptables commands from database extracts and then add them to the ruleset.
To start, install the Ubuntu 8.04 server framework. If you opt for a more complex partitioning scheme for security or performance reasons, you are well advised to swap out the /var filesystem, which is where both the logfiles and the database reside later on.
The Portsmith documentation tells you to install the ubuntu-desktop package macro, which provides a complete, Gnome-based user interface. However, you will not actually need a full Gnome desktop, unless the thought of using vi and the command line worries you. On the other hand, the documentation does not tell you anything about more meaningful tasks, such as basic hardening of the operating system. (Because Portsmith has a direct Internet connection, it requires far more attention to security than a normal end-user system.)
The next step is to configure the network interfaces and then go on to install the remaining packages. Users working on a graphical desktop can use the GUI tools for this; everyone else should just fire up their favorite editor and edit /etc/network/interfaces.
aptitude install -y openssh-server apache2 libapache2-mod-php5 libapache2-mod-auth-pgsql postgresql-8.3 php5-pgsql
drops the required packages onto your system. If you will be using the internal backup solution, you will additionally need the mkisofs and cdrecord packages.
Setting up the web servers takes a couple more steps. If you haven't configured DNS entries for your firewall, set the ServerName parameter, then enable the SSL module with a2enmod ssl.
To avoid transmitting user logins in the clear, it makes sense to use SSL-encrypted connections. Whether you use self-signed certificates or have them signed by a commercial CA is up to you and your company's security policy.
Portsmith is a 17MB ISO image download  , which you can either burn onto a CD or mount by typing:
mount -o loop /tmp/Portsmith_4.iso /media/cdrom
The Portsmith package includes a number of tarballs with shell and PHP scripts, the database table structure, and a sample configuration that helps you set up your Portsmith machine as a DNS or DHCP server. On top of this, you will find a short installation guide, as well as two Windows binaries (one for Internet Explorer and the other for Firefox) that support the use of RDP (Remote Desktop) via a Portsmith-empowered firewall.
To install Portsmith, unpack the tarball:
tar xvf /media/cdrom/server/ports.tar -C /
The shell scripts, which are copied into /usr/local/bin, contain variables that reflect the network structure; the Portsmith admin will need to modify the scripts accordingly. The scripts are located in the fw_policy and fw_lookup files. Among other things, you need to specify the external network and the official firewall IP address. It is easier to have a static IP address; however, users with a dynamic IP can use DynDNS  or a scripting workaround to publish the current address.
According to the documentation, you should launch Portsmith directly by adding it to your /etc/rc.local file. If your firewall has a direct Internet link, this would mean the firewall and the networks hiding behind it would not be protected by the packet filter for a short period after you launch the machine because the firewall would be the last item processed at boot time. When you enable the network interfaces, you might prefer to run an init script or call Portsmith.
The database also needs some preparation. Unfortunately, the documentation tells users to cut and paste, an error-prone process; psql < /media/cdrom/server/TABLES.txt is an easier approach. Because the hard work in the background is handled by a couple of shell scripts that need to run periodically, you need to set up cron entries for the scripts.
Relaunch the server by typing /etc/init.d/apache2 restart, and Portsmith should be up and running.
Administrators can use their browser for all system management activities: https://Firewall/ports/ takes you to a login window. The login defaults to admin with admin as the password. Although the documentation points out that you should change this, it could be too late if your firewall is already connected to the Internet – these defaults are very easy to guess.
After logging in, administrative users can configure the system, manage users, and enable a couple of features for themselves. The two main areas of system management are user administration and the ruleset. The list of users is fairly simple, and it gives administrators a large selection of entries and search functions (Figure 1). The drop-down list at top right lets you sort, add, modify, or delete accounts. When adding or modifying, you need to specify a username and password. The user is then assigned a role as a standard user or an admin; admins have full access to the system.
Instead of deleting accounts you no longer need, you can simply disable them. However, Portsmith does not have a time-controlled function for blocking temporary accounts; again manual attention by the admin is required. The admin can also set up a default rule, revoke rules, or add new rules. Ruleset management is similar to user management (Figure 2). Again, the Portsmith admin can search for, modify, add, and delete rules.
When adding or modifying, you can specify the protocol to use (TCP, UDP, ICMP), the action to perform (permit or forward), and the target port. Also, you can target a host via its IP or (assuming you have DNS name resolution working) its hostname. The admin interface also gives you access to a couple of useful tools: the Log Manager (Figure 3) tells you exactly which rules were enabled by which users from which IP. A handy search function helps you keep track of a larger number of log entries.
The tools button takes you to four more helpers that are worth examining. The Login Analyzer (Figure 4) not only gives the administrator a useful overview of who logged in when, but it also reports the number and times of recent invalid login attempts.
To avoid brute force attacks, the client source IP is blocked after 3 logins until the administrator resets it. The locking function does not rely on a packet filter; instead, the potential attacker is told You are up to no good – you are now going to be blocked, and the username and password fields disappear to prevent login attempts with an alternative user account. If worst comes to worst, the administrator will not even be able to use an administrative account to unblock the account, in which case, the only alternative is to modify the database manually.
Under normal circumstances, you can also release a computer blocked because of an excessive number of login attempts through the Login Analyzer. Unfortunately, this function is fairly well hidden: You need to enable the checkbox to the left of the entry and then click Submit.
The status display lists the current Firewall ruleset, although this is just the output from iptables -L -v. Anybody who is not familiar with iptables will probably be more confused after reading the list; a more readable report would be useful for newcomers.
The restart button restores the original status of any rules that were set by admins and users. This step keeps any existing connections.
Portsmith is really easy from the user's point of view. As with admin access, user access is browser-based, and users need to enter their credentials. After logging in, users are shown a list of available firewall rules. A user can select a rule and then click it to enable.
As you can see from Figure 5, the list of enabled functions is fairly technical. Most end users are unlikely to understand the meanings of the individual ports and really do need a description in plain English. Some creativity is required from the administrator, since the database restricts the length of the description to 25 characters. Of course, you could change the size of the database column manually.
In contrast to a VPN, Portsmith does not send connections directly to the target machine; instead, it forwards incoming packets from the firewall once the user is authenticated. End users might therefore need to take some action. For example, if you want to access an internal printer remotely, you would have to set up a printer on the client side for the user to select.
It is a good idea to start with a clear definition of the tasks you want to handle with Portsmith (e.g., the previous example with the printer would be easy enough to implement, but you have to question the security of transmitting printed output in the clear across the Internet.)
Buy this article as PDF
Bug database has a bug of its own that could allow an intruder to create an unauthorized account.
Report focuses federal resources on achieving universal Internet access.
Leading browser makers say “no” to porous encryption algorithm
Report from the X-Force group says attackers are using TOR to hide their crimes
Future Firefox extensions will be compatible with Chrome.
Better read this if you bought your computer before 2011
Users should upgrade to the new version as soon as possible
Xen project announces a privilege escalation problem for Qemu host systems
Attackers can compromise an Android phone just by sending a text message
PC vendor will pre-install Ubuntu on portables in India.