Tuesday, March 17, 2015

IPtables : Basic 1

Set of rules to set up a Stateful Packet Inspection (SPI) firewall that will allow all outgoing connections but block all unwanted incoming connections:

# iptables -P INPUT ACCEPT
# iptables -F
# iptables -A INPUT -i lo -j ACCEPT
# iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# iptables -P INPUT DROP
# iptables -P FORWARD DROP
# iptables -P OUTPUT ACCEPT
# iptables -L -v
 
which should give the following output:

Chain INPUT (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     all  --  lo     any     anywhere             anywhere
    0     0 ACCEPT     all  --  any    any     anywhere             anywhere            state RELATED,ESTABLISHED
    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere            tcp dpt:ssh
Chain FORWARD (policy DROP 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
 
  1. iptables -P INPUT ACCEPT If connecting remotely we must first temporarily set the default policy on the INPUT chain to ACCEPT otherwise once we flush the current rules we will be locked out of our server.
  2. iptables -F We used the -F switch to flush all existing rules so we start with a clean state from which to add new rules.
  3. iptables -A INPUT -i lo -j ACCEPT Now it's time to start adding some rules. We use the -A switch to append (or add) a rule to a specific chain, the INPUT chain in this instance. Then we use the -i switch (for interface) to specify packets matching or destined for the lo (localhost, 127.0.0.1) interface and finally -j (jump) to the target action for packets matching the rule - in this case ACCEPT. So this rule will allow all incoming packets destined for the localhost interface to be accepted. This is generally required as many software applications expect to be able to communicate with the localhost adaptor.
  4. iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT This is the rule that does most of the work, and again we are adding (-A) it to the INPUT chain. Here we're using the -m switch to load a module (state). The state module is able to examine the state of a packet and determine if it is NEW, ESTABLISHED or RELATED. NEW refers to incoming packets that are new incoming connections that weren't initiated by the host system. ESTABLISHED and RELATED refers to incoming packets that are part of an already established connection or related to and already established connection.
  5. iptables -A INPUT -p tcp --dport 22 -j ACCEPT Here we add a rule allowing SSH connections over tcp port 22. This is to prevent accidental lockouts when working on remote systems over an SSH connection. We will explain this rule in more detail later.
  6. iptables -P INPUT DROP The -P switch sets the default policy on the specified chain. So now we can set the default policy on the INPUT chain to DROP. This means that if an incoming packet does not match one of the following rules it will be dropped. If we were connecting remotely via SSH and had not added the rule above, we would have just locked ourself out of the system at this point.
  7. iptables -P FORWARD DROP Similarly, here we've set the default policy on the FORWARD chain to DROP as we're not using our computer as a router so there should not be any packets passing through our computer.
  8. iptables -P OUTPUT ACCEPT and finally, we've set the default policy on the OUTPUT chain to ACCEPT as we want to allow all outgoing traffic (as we trust our users).
  9. iptables -L -v Finally, we can list (-L) the rules we've just added to check they've been loaded correctly. 

    Finally, the last thing we need to do is save our rules so that next time we reboot our computer our rules are automatically reloaded:
    # /sbin/service iptables save

 

Sunday, March 15, 2015

vCNS vs NSX High Level Functionality Compared

vCNS vs NSX High Level Functionality Compared 
vCNS NSX
Management Appliance – 1:1 with vCenterEasy UI Management Appliance – 1:1 with vCenter, plus full Api
VXLAN Supported using a hypervisor kernal.Requires Multicast VXLAN Supported using a hypervisor kernal.Does not require multicast to be enabled
Edge Service Gateway providingVPN – (site to site / SSL ), NAT, NLB, etcStatic Routing Edge Service Gateway providingVPN – (site to site / SSL ), NAT, NLB, etcStatic and Dynamic routing
Virtual aware firewall (ie resource pool object) Virtual aware Firewall (N/S) and kernal based granular to low level (ie domain users, VM tags – dynamic groups).
 Routing via virtual guest machine device  hypervisor based router

Layer 2 bridging supported to physical
Data security file scanning for keyword formats (ie health numbers, and card numbers)  Data security file scanning for keyword formats (ie health numbers, and card numbers)
vSphere  5.5 dvs features supported vSphere  5.5 dvs features supported

Monday, March 2, 2015

Configuration Maximums of vSphere 6.0

New Configuration Maximums of vSphere 6.0:

  • vSphere 6.0 Clusters now supports 64 Nodes and 8,000 VM’s (Which was 32 Nodes and 4,000 VM’s in vSphere 5.5)
  • vCenter Server Appliance (vCSA 6.0) supports upto 1000 Hosts and 10,000 Virtual Machines with embedded vPostgres database
  • ESXi 6.0 host now supports support up to 480 physical CPUs  and 12 TB RAM (which was 320 CPUs and 4 TB in vSphere 5.5)
  • ESXi 6.0 host Supports 1000 VMs and 32 Serial Ports. (which was 512 VM per host in vSphere 5.5)
  • vSphere 6.0 VM’s will support  up to 128 vCPUs and 4TB vRAM (which was 64 vCPU’s and 1 TB of memory in vSphere 5.5)
  • vSphere 6.0 continuous to support 64 Tb Datastores as same as in vSphere 5.5
  • Increased support for virtual graphics including Nvidia vGPU
  • Support for New Operating systems like FreeBSD 10.0 and Asianux 4 SP3 
  • Fault Tolerance (FT) in vSphere 6.0 now supports upto 4 vCPUs (which was only 1 vCPU in vSphere 5.5)
 Quick Comparison table between the Configuration maximums of  vSphere 5.5 and vSphere 6.0:
vSphere 6.0 Configuration Maximums

Sunday, March 1, 2015

nftables vs. iptables comparison - RHEL 7



With iptables, you need to write two rules, one for drop and one for logging:
# iptables -­A FORWARD -­p tcp -­-­dport 22 -­j LOG
# iptables -­A FORWARD -­p tcp -­-­dport 22 -­j DROP

With nftables, you can combined both targets:
# nft add rule filter forward tcp dport 22 log drop

With iptables in order to allow packets for different ports and allow different icmpv6 types, you would need to do the following:
# ip6tables -­A INPUT -­p tcp -­m multiport -­-­dports 23,80,443 -­j ACCEPT
# ip6tables -­A INPUT -­p icmpv6 -­-­icmpv6-­type neighbor-­solicitation -­j ACCEPT
# ip6tables -­A INPUT -­p icmpv6 -­-­icmpv6-­type echo-­request -­j ACCEPT
# ip6tables -­A INPUT -­p icmpv6 -­-­icmpv6-­type router-­advertisement -­j ACCEPT
# ip6tables -­A INPUT -­p icmpv6 -­-­icmpv6-­type neighbor-­advertisement -­j ACCEPT

With nftables, sets can be used on any element in a rule:
# nft add rule ip6 filter input tcp dport {telnet, http, https} accept
# nft add rule ip6 filter input icmpv6 type { nd-neighbor-­solicit, echo-­request, nd-­router-­advert, nd-­neighbor-­advert } accept

Saturday, February 21, 2015

Windows System File Checker

System File Checker is a utility in Windows that allows users to scan for corruptions in Windows system files and restore corrupted files. This article describes how to run the System File Checker tool (SFC.exe) to scan your system files and to repair missing or corrupted system files in Windows 8.1, Windows 8, Windows 7 or Windows Vista. If a Windows Resource Protection (WRP) file is missing or is corrupted, Windows may not behave as expected. For example, some Windows functions may not work, or Windows may crash.

Run the System File Checker tool (SFC.exe)

To do this, follow these steps:
  1. Open an elevated command prompt. To do this, do the following as your appropriate:
    To do this, click Start, type Command Prompt or cmd in the Search box, right-click Command Prompt, and then click Run as administrator. If you are prompted for an administrator password or for a confirmation, type the password, or click Allow.
    A screenshot for this step.
  2. At the command prompt, type the following command, and then press ENTER:
    sfc /scannow
    A screenshot for this step.


    The sfc /scannow command will scan all protected system files, and replace corrupted files with a cached copy that is located in a compressed folder at %WinDir%\System32\dllcache.
    The %WinDir% placeholder represents the Windows operating system folder. For example, C:\Windows.

    Note Do not close this Command Prompt window until the verification is 100% complete. The scan results will be shown after this process is finished.
  3. After the process is finished, you may receive one of the following messages:
    • Windows Resource Protection did not find any integrity violations.

      This means that you do not have any missing or corrupted system files.
    • Windows Resource Protection could not perform the requested operation.

      To resolve this problem, perform the System File Checker scan in safe mode, and make sure that the PendingDeletes and PendingRenames folders exist under %WinDir%\WinSxS\Temp.
    • Windows Resource Protection found corrupt files and successfully repaired them. Details are included in the CBS.Log %WinDir%\Logs\CBS\CBS.log.

      To view the detail information about the system file scan and restoration, go to How to view details of the System File Checker process.
    • Windows Resource Protection found corrupt files but was unable to fix some of them. Details are included in the CBS.Log %WinDir%\Logs\CBS\CBS.log.

      To repair the corrupted files manually, view details of the System File Checker process to find the corrupted file, and then manually replace the corrupted file with a known good copy of the file.

Wednesday, February 18, 2015

Sendmail v8.12

Sendmail  v8.12 is the first release of Sendmail to draw a distinction between the Message Submission Process (MSP) and the Mail Transfer Agent (MTA) portions of the email equation. Simply put, the MSP is the procedure used by local processes when they wish to emit email from the local machine. The MTA is the process which handles receiving email from other systems and either relaying it onwards or delivering it locally. In other words, the MTA is the process that listens on 25/tcp and the thing we want to shut off.
The problem is that the default behavior of the MSP is to attempt to deliver outgoing email by talking to the MTA over the system's internal loopback interface. This means that if we shut off the local MTA, then the default MSP will be unable to send email out of the system! This is not a feature.
It turns out that the MSP doesn't have to emit email by talking to the local MTA over the loopback interface. It can talk to any mail server on the network that the administrator desires. In this mode, the MSP is acting very much like the nullclient configuration that we discussed in the previous section. The macro configuration file is only slightly more complicated:

 include(`cf/m4/cf.m4')
 define(`confCF_VERSION', `Submit')
 define(`__OSTYPE__', `')
 define(`confTIME_ZONE', `USE_TZ')
 define(`confDONT_INIT_GROUPS', `True')
 FEATURE(`msp', `mailhost')
Again, set the pathname on the first line and the name of the machine on the last line as appropriate for your site. The configuration file produced from the above macros should be installed as /etc/mail/submit.cf on your systems.
Note that you can also simply hack the submit.cf file provided by your vendor. Just look for the line that reads

 D{MTAHost}[127.0.0.1]
Just replace [127.0.0.1] with the name of your new relay host. For example,

 D{MTAHost}mailhost
Save your changes, and you're done!
The split between MTA and MSP is also reflected in how the Sendmail daemon is started at boot time. When using Sendmail v8.12, two daemons are normally started by the system boot scripts:

 /usr/sbin/sendmail -bd -q15m
 /usr/sbin/sendmail -Ac -q15m
The first line looks identical to the normal Sendmail invocation for Sendmail v8.11 and earlier-- this is the MTA process that is listening on 25/tcp for incoming email, and which processes a queue of messages received by this process. The second line invokes a daemon for the MSP. This daemon doesn't listen on any port for incoming messages: its sole duty is to process a separate MSP queue for messages generated on the local machine but which could not be delivered immediately because the MSP's mail relay was unavailable for some reason.
So in v8.12 Sendmail, the MSP has its own message queue and its own daemon for flushing that queue on a regular basis. This means that on email "client" type machines the MTA daemon is completely unnecessary and can be shut off completely. In order to get this to happen, however, it will probably be necessary to hack the default boot script provided by your vendor. I have yet to find a vendor who has a simple configuration switch for disabling the MTA process without disabling the MSP. In fact, most vendors in my experience don't even realize that you can run the MSP without a local MTA.

Tuesday, February 10, 2015

NagiosQL

NagiosQL is a web based administration tool designed for Nagios, but might also work with forks. It helps you to easily build a complex configuration with all options, manage and use them. NagiosQL is based on a webserver with PHP, MySQL and local file or remote access to the Nagios configuration files.
The main features are:
  • create, delete, modify and copy settings
  • create and export configuration files
  • create and download configuration files
  • easy configuration import
  • auto backup configuration files
  • consistency checks
  • syntax verification
  • user management
  • instant activation of new configs
  • many translations
  • easy Installation wizard
  • MySQL database platform

Monday, February 2, 2015

FreeBSD - Security Tips

Security has always been a major topic alongside with Open Source systems. A weak entry-point in any system may allow hackers to gain access to critical servers and information and then cause a backdoor or heavy damage in the entire network.

FreeBSD
When applying security measures to a system, it is highly advised to start by securing the basic system configurations, and then up to secure the network layer so that it complies to the system policy and the organization’s security procedures. Many corporations already have a security policy that covers all configurations of  the internal technology devices. The policy should include the security configuration of workstations, user desktops, mobile devices, phones and servers.
There are some general and became-traditional steps that FreeBSD admins are always doing, such as employing password hashes & password policy enforcement or activating the Binary verification where a specific software application, intrusion prevention system (IDS), that is natively supported by FreeBSD, is to verify every change in the system files and report them to security teams. However, It is essential that you create a security plan, not just activating default procedures that hackers really know, to secure your server immediately upon installation. Do not leave it up without first securing it. Here are the basic recommended concepts, you need to do in order to secure your server:
  • Run only the services you plan on using
  • Use only the services that are necessary
  • Use secure passwords
  • Force users on your machine to use secure passwords
  • Restrict root access to a minimal set of services
  • Restrict access to these services via tcpwrappers
  • Restrict access to your box using IP Firewall services (ipfw)
  • Log events on your machine and understand what logs are being kept
  • Install some type of system change detection software, so that you can tell if your server has been compromised
  • Back up your server’s data so that if it is compromised, you can reinstall from scratch, but still have your data available
  • Finally, physical security is important. The more people who have physical access to the machine, the less secure your server is
There are some services you should not ever run, At the top of this list, is Telnet. You should access your servers using Secure Shell (SSH) as all information is encrypted. Telnet is very insecure since it passes all information in clear text across the network. In addition, other common services with this problem include FTP, POP, and IMAP. If you are just starting out as an ISP, this is your chance to work with SSH and SCP clients for your users, as well as encrypted POP and IMAP email clients, or secure Webmail servers using SSL.

Saturday, January 24, 2015

Securing Postfix

The following is a list of directives that can be used for limiting a denial of service attack:
  • smtpd_client_connection_rate_limit — The maximum number of connection attempts any client is allowed to make to this service per time unit (described below). The default value is 0, which means a client can make as many connections per time unit as Postfix can accept. By default, clients in trusted networks are excluded.
  • anvil_rate_time_unit — This time unit is used for rate limit calculations. The default value is 60 seconds.
  • smtpd_client_event_limit_exceptions — Clients that are excluded from the connection and rate limit commands. By default, clients in trusted networks are excluded.
  • smtpd_client_message_rate_limit — The maximum number of message deliveries a client is allowed to request per time unit (regardless of whether or not Postfix actually accepts those messages).
  • default_process_limit — The default maximum number of Postfix child processes that provide a given service. This limit can be overruled for specific services in the master.cf file. By default the value is 100.
  • queue_minfree — The minimum amount of free space in bytes in the queue file system that is needed to receive mail. This is currently used by the Postfix SMTP server to decide if it will accept any mail at all. By default, the Postfix SMTP server rejects MAIL FROM commands when the amount of free space is less than 1.5 times the message_size_limit. To specify a higher minimum free space limit, specify a queue_minfree value that is at least 1.5 times the message_size_limit. By default the queue_minfree value is 0.
  • header_size_limit — The maximum amount of memory in bytes for storing a message header. If a header is larger, the excess is discarded. By default the value is 102400.
  • message_size_limit — The maximum size in bytes of a message, including envelope information. By default the value is 10240000.

Sunday, January 11, 2015

Security Vulnerabilities Patched by OpenSSL Project

OpenSSL has been updated to new versions as its maintainer repaired a set of eight security glitches, most of them graded with low severity.
The risks they pose range from denial-of-service attacks, changing the fingerprint certificate, client authorization without verification message for a DH (Diffie-Hellman) certificate, client accepting the use of a temporary RSA or a handshake that leads to removing the forward secrecy from the ciphersuite.

Moderate severity flaws get fixed

Two of the flaws have been marked with moderate severity, one of them referring to a memory leak in dtls1_buffer_record, while the other caused a DTLS segmentation fault in dtls1_get_record. Exploiting any of them would result in a denial of service (DoS) condition.

“A carefully crafted DTLS message can cause a segmentation fault in OpenSSL due to a NULL pointer dereference. This could lead to a Denial Of Service attack,” reads the advisory for the former glitch identified as CVE-2015-0206.

In the case of the latter, tracked as CVE-2014-3571, certain conditions have to be met for the memory leak to occur. The possibility of an attack leveraging it would require the potential attacker to send repeated DTLS (datagram transport layer security) records that have the same sequence number but intended for the next epoch. Exhausting memory would lead to DoS.

Multiple researchers disclosed the glitches

All vulnerabilities described in the advisory affect versions 1.0.1 and 1.0.0 of OpenSSL, while some of them impact only the 0.9.8 revisions.

However, users are advised to update their OpenSSL builds to the latest releases: 1.0.1k, 1.0.0p and 0.9.8zd.

Credit for finding and reporting the weaknesses go to researchers from Cisco Systems, PROSECCO team at INRIA, Codenomicon, and Google.

It must be noted that development for the older branches (1.0.0 and 0.9.8) will be discontinued in the last day of 2015. As such, users should start thinking about the implications of moving the services that rely on OpenSSL to the current latest release.

Upgrading as soon as possible would ensure the necessary time for fixing up the quirks that may appear as a result of the operation.

Wednesday, January 7, 2015

Apache 2.4 Hardening Guide.

Keep up to Date

The Apache HTTP Server has a good record for security and a developer community highly concerned about security issues. But it is inevitable that some problems -- small or large -- will be discovered in software after it is released. For this reason, it is crucial to keep aware of updates to the software. If you have obtained your version of the HTTP Server directly from Apache, we highly recommend you subscribe to the Apache HTTP Server Announcements List where you can keep informed of new releases and security updates. Similar services are available from most third-party distributors of Apache software.
Of course, most times that a web server is compromised, it is not because of problems in the HTTP Server code. Rather, it comes from problems in add-on code, CGI scripts, or the underlying Operating System. You must therefore stay aware of problems and updates with all the software on your system.
top

Denial of Service (DoS) attacks

All network servers can be subject to denial of service attacks that attempt to prevent responses to clients by tying up the resources of the server. It is not possible to prevent such attacks entirely, but you can do certain things to mitigate the problems that they create.
Often the most effective anti-DoS tool will be a firewall or other operating-system configurations. For example, most firewalls can be configured to restrict the number of simultaneous connections from any individual IP address or network, thus preventing a range of simple attacks. Of course this is no help against Distributed Denial of Service attacks (DDoS).
There are also certain Apache HTTP Server configuration settings that can help mitigate problems:
  • The RequestReadTimeout directive allows to limit the time a client may take to send the request.
  • The TimeOut directive should be lowered on sites that are subject to DoS attacks. Setting this to as low as a few seconds may be appropriate. As TimeOut is currently used for several different operations, setting it to a low value introduces problems with long running CGI scripts.
  • The KeepAliveTimeout directive may be also lowered on sites that are subject to DoS attacks. Some sites even turn off the keepalives completely via KeepAlive, which has of course other drawbacks on performance.
  • The values of various timeout-related directives provided by other modules should be checked.
  • The directives LimitRequestBody, LimitRequestFields, LimitRequestFieldSize, LimitRequestLine, and LimitXMLRequestBody should be carefully configured to limit resource consumption triggered by client input.
  • On operating systems that support it, make sure that you use the AcceptFilter directive to offload part of the request processing to the operating system. This is active by default in Apache httpd, but may require reconfiguration of your kernel.
  • Tune the MaxRequestWorkers directive to allow the server to handle the maximum number of simultaneous connections without running out of resources. See also the performance tuning documentation.
  • The use of a threaded mpm may allow you to handle more simultaneous connections, thereby mitigating DoS attacks. Further, the event mpm uses asynchronous processing to avoid devoting a thread to each connection. Due to the nature of the OpenSSL library the event mpm is currently incompatible with mod_ssl and other input filters. In these cases it falls back to the behaviour of the worker mpm.
  • There are a number of third-party modules available through http://modules.apache.org/ that can restrict certain client behaviors and thereby mitigate DoS problems.
top

Permissions on ServerRoot Directories

In typical operation, Apache is started by the root user, and it switches to the user defined by the User directive to serve hits. As is the case with any command that root executes, you must take care that it is protected from modification by non-root users. Not only must the files themselves be writeable only by root, but so must the directories, and parents of all directories. For example, if you choose to place ServerRoot in /usr/local/apache then it is suggested that you create that directory as root, with commands like these:
mkdir /usr/local/apache
cd /usr/local/apache
mkdir bin conf logs
chown 0 . bin conf logs
chgrp 0 . bin conf logs
chmod 755 . bin conf logs
It is assumed that /, /usr, and /usr/local are only modifiable by root. When you install the httpd executable, you should ensure that it is similarly protected:
cp httpd /usr/local/apache/bin
chown 0 /usr/local/apache/bin/httpd
chgrp 0 /usr/local/apache/bin/httpd
chmod 511 /usr/local/apache/bin/httpd
You can create an htdocs subdirectory which is modifiable by other users -- since root never executes any files out of there, and shouldn't be creating files in there.
If you allow non-root users to modify any files that root either executes or writes on then you open your system to root compromises. For example, someone could replace the httpd binary so that the next time you start it, it will execute some arbitrary code. If the logs directory is writeable (by a non-root user), someone could replace a log file with a symlink to some other system file, and then root might overwrite that file with arbitrary data. If the log files themselves are writeable (by a non-root user), then someone may be able to overwrite the log itself with bogus data.
top

Server Side Includes

Server Side Includes (SSI) present a server administrator with several potential security risks.
The first risk is the increased load on the server. All SSI-enabled files have to be parsed by Apache, whether or not there are any SSI directives included within the files. While this load increase is minor, in a shared server environment it can become significant.
SSI files also pose the same risks that are associated with CGI scripts in general. Using the exec cmd element, SSI-enabled files can execute any CGI script or program under the permissions of the user and group Apache runs as, as configured in httpd.conf.
There are ways to enhance the security of SSI files while still taking advantage of the benefits they provide.
To isolate the damage a wayward SSI file can cause, a server administrator can enable suexec as described in the CGI in General section.
Enabling SSI for files with .html or .htm extensions can be dangerous. This is especially true in a shared, or high traffic, server environment. SSI-enabled files should have a separate extension, such as the conventional .shtml. This helps keep server load at a minimum and allows for easier management of risk.
Another solution is to disable the ability to run scripts and programs from SSI pages. To do this replace Includes with IncludesNOEXEC in the Options directive. Note that users may still use <--#include virtual="..." --> to execute CGI scripts if these scripts are in directories designated by a ScriptAlias directive.
top

CGI in General

First of all, you always have to remember that you must trust the writers of the CGI scripts/programs or your ability to spot potential security holes in CGI, whether they were deliberate or accidental. CGI scripts can run essentially arbitrary commands on your system with the permissions of the web server user and can therefore be extremely dangerous if they are not carefully checked.
All the CGI scripts will run as the same user, so they have potential to conflict (accidentally or deliberately) with other scripts e.g. User A hates User B, so he writes a script to trash User B's CGI database. One program which can be used to allow scripts to run as different users is suEXEC which is included with Apache as of 1.2 and is called from special hooks in the Apache server code. Another popular way of doing this is with CGIWrap.
top

Non Script Aliased CGI

Allowing users to execute CGI scripts in any directory should only be considered if:
  • You trust your users not to write scripts which will deliberately or accidentally expose your system to an attack.
  • You consider security at your site to be so feeble in other areas, as to make one more potential hole irrelevant.
  • You have no users, and nobody ever visits your server.
top

Script Aliased CGI

Limiting CGI to special directories gives the admin control over what goes into those directories. This is inevitably more secure than non script aliased CGI, but only if users with write access to the directories are trusted or the admin is willing to test each new CGI script/program for potential security holes.
Most sites choose this option over the non script aliased CGI approach.
top

Other sources of dynamic content

Embedded scripting options which run as part of the server itself, such as mod_php, mod_perl, mod_tcl, and mod_python, run under the identity of the server itself (see the User directive), and therefore scripts executed by these engines potentially can access anything the server user can. Some scripting engines may provide restrictions, but it is better to be safe and assume not.
top

Dynamic content security

When setting up dynamic content, such as mod_php, mod_perl or mod_python, many security considerations get out of the scope of httpd itself, and you need to consult documentation from those modules. For example, PHP lets you setup Safe Mode, which is most usually disabled by default. Another example is Suhosin, a PHP addon for more security. For more information about those, consult each project documentation.
At the Apache level, a module named mod_security can be seen as a HTTP firewall and, provided you configure it finely enough, can help you enhance your dynamic content security.
top

Protecting System Settings

To run a really tight ship, you'll want to stop users from setting up .htaccess files which can override security features you've configured. Here's one way to do it.
In the server configuration file, put
<Directory />
    AllowOverride None
</Directory>
This prevents the use of .htaccess files in all directories apart from those specifically enabled.
top

Protect Server Files by Default

One aspect of Apache which is occasionally misunderstood is the feature of default access. That is, unless you take steps to change it, if the server can find its way to a file through normal URL mapping rules, it can serve it to clients.
For instance, consider the following example:
# cd /; ln -s / public_html
Accessing http://localhost/~root/
This would allow clients to walk through the entire filesystem. To work around this, add the following block to your server's configuration:
<Directory />
    Require all denied
</Directory>
This will forbid default access to filesystem locations. Add appropriate Directory blocks to allow access only in those areas you wish. For example,
<Directory /usr/users/*/public_html>
    Require all granted
</Directory>
<Directory /usr/local/httpd>
    Require all granted
</Directory>
Pay particular attention to the interactions of Location and Directory directives; for instance, even if <Directory /> denies access, a <Location /> directive might overturn it.
Also be wary of playing games with the UserDir directive; setting it to something like ./ would have the same effect, for root, as the first example above. We strongly recommend that you include the following line in your server configuration files:
UserDir disabled root
top

Watching Your Logs

To keep up-to-date with what is actually going on against your server you have to check the Log Files. Even though the log files only reports what has already happened, they will give you some understanding of what attacks is thrown against the server and allow you to check if the necessary level of security is present.
A couple of examples:
grep -c "/jsp/source.jsp?/jsp/ /jsp/source.jsp??" access_log
grep "client denied" error_log | tail -n 10
The first example will list the number of attacks trying to exploit the Apache Tomcat Source.JSP Malformed Request Information Disclosure Vulnerability, the second example will list the ten last denied clients, for example:
[Thu Jul 11 17:18:39 2002] [error] [client foo.example.com] client denied by server configuration: /usr/local/apache/htdocs/.htpasswd
As you can see, the log files only report what already has happened, so if the client had been able to access the .htpasswd file you would have seen something similar to:
foo.example.com - - [12/Jul/2002:01:59:13 +0200] "GET /.htpasswd HTTP/1.1"
in your Access Log. This means you probably commented out the following in your server configuration file:
<Files ".ht*">
    Require all denied
</Files>
top

Merging of configuration sections

The merging of configuration sections is complicated and sometimes directive specific. Always test your changes when creating dependencies on how directives are merged.
For modules that don't implement any merging logic, such as mod_access_compat, the behavior in later sections depends on whether the later section has any directives from the module. The configuration is inherited until a change is made, at which point the configuration is replaced and not merged.

Thursday, January 1, 2015

Windows Server 2008 R2 Hardening Guide



sasquatch.jpg





Ever since it’s debut, Microsoft Windows 2008 Server has awed security and systems administrators with its complex and innovative features.
With threats becoming each day more immanent and efficient, security system administrators face the tedious task of protecting Microsoft’s new giant. In this article we compiled some of the industries best practices such as NIST to show you some of the features and ways to reduce your windows 2008 servers’ exposure.





1. Configure a security policy





The first step in securing the 2008 server is to configure a security policy. In order
to configure a security policy, you will need to use the SCW (
Security Configuration Wizard),
which can be installed through “add and remove windows components”.
 

The SCW detects ports and services, and configures registry and audit settings according to the servers “role” or installed applications. The SCW uses a set of XML templates which can easily be deployed and managed. The version of SCW in Windows Server2008 includes over 200server role configurations and security settings than the version of SCW in Windows Server2003. Also, by using the version of SCW in Windows Server2008, you can:
  • * Disable unneeded services based on the server role.
  • * Remove unused firewall rules and constrain existing firewall rules.
  • * Define restricted audit policies.


SCW_ConfigAction_Fig1_small.png






The server’s operating system will be changed according to the profile or template  selected.Administrators can create custom profiles and deploy them using a set o XML files.




2. Disable or delete unnecessary accounts, ports and services


Attackers often gain access to servers through unused or not configured ports and services

To limit entry points, server hardening includes blocking unused ports and protocols as well as disabling services that are not required. Although this can be done as seen above using the SCW, the server administrator would need to double check to see if all the services are configured properly and that only the necessary ports are open.During the installation of the 2008 server, by default, three local user accounts are automatically created: the Administrator, Guest and Help Assistant. The Administrator account bears
high privileges, and requires special diligence. As a security best practice the administrator account should be disabled or renamed to make it more difficult for an attacker to gain access.
Both Guest and Help Assistant accounts provide an easy target for attackers which exploited this vulnerability before on the earlier Windows Server 2003. These accounts should be disabled at all times.



3. Uninstall Unnecessary Applications
Remember, your server is a vital part of your network and services that you provide. The number of applications installed on these servers should be role related and set to a minimum.
It is a good idea to test these applications out in a separate environment before deploying them on the production network. Some applications make use of service backdoors, which can sometimes compromise the overall security of the server. After installing each application, make sure that you double check to see if the application created any firewall exception or created a service user account.






      • * Belarc Advisor :
        The Belarc Advisor “builds a detailed profile of your installed software and hardware,
        missing Microsoft hot fixes, anti-virus status, and displays the results in your Web
        browser.” This tool is free for personal use. Commercial, government, and non-profit
        organizations should look at their other products which include many more features
        for managing security on multiple computers.


      • *
        Microsoft SysInternal Tools
        :
        Microsoft provides a set of tools which can be used to monitor the server’s activity.
        These tools include: REGMON, FILEMON,
        Process Explorer, Root Kit Revealer. These tools are great for understanding what
        a certain application or software does “under the sheets”.


4. Configure the windows 2008 Firewall
Windows 2008 server comes with a phenomenal built in firewall called the Windows Firewall with Advanced Security. As a security best practice, all servers should have its own host based firewall. This firewall needs to be double checked to see if there are no unnecessary rules or exceptions. I have outlined some of the new features that the Windows Server 2008 provides.






      • * GUI interface:
        a MMC snap-in available for the Advanced Firewall Configuration.


      •   *Bi-directional filtering:
        the firewall now filters outbound traffic as well as inbound traffic.

      • * IPSEC operability:
        now the firewall rules and IPSEC encryption configurations are integrated into one
        interface. 
      • * Advanced Rules configuration:
        you can create firewall rules using Windows Active Directory objects, source amp;
        destination IP addresses and protocols.




wfas.jpg






5. Configure Auditing






One of the most significant changes on Windows Server 2008 auditing is that now you can not only audit who and what attribute was changed but also what the new and old value was.
This is significant because you can now tell why it was changed and if something doesn’t look right you’re able to easily find what it should be restored to.





Another significant change is that in the past Server versions you were only able to turn auditing policy on or off for the entire Active Directory structure. In Windows Server 2008 the auditing policy is more granular.

As a security best practice, the following events should be logged and audited on the Windows Server 2008.

        • * Audit account logon events
        • *Audit account management
        • *Audit directory service access
        • * Audit logon events
        • * Audit object access
        • * Audit policy change
        • * Audit privilege use
        • *Audit process tracking
        • * Audit system events


audit.png



Most log events on the event viewer have registered incident ID numbers; these numbers can be used to troubleshoot the server. http://www.eventid.net/ is a good site which aids security and system administrators in finding out what actually happened with their servers. A best practice would also be to forward these audit
logs to a centralized server as required by PCI DSS 10.5.3 and other industry standards. Windows Server 2008 offers a native log subscription feature which forwards all system and security audit logs to a centralized server.







6. Disable unnecessary shares


Unnecessary shares pose a great threat to vital servers. After a server or application deployment,
system and security administrators should check to see if the server has any unnecessary shares. This can be done using the following command:
· Net Share


This will display a list of all shares on the server. If there is a need to use a share, system and security administrators should configure the share as a hidden share and harden all NTFS and Share permissions.



C:\Documents
and Settingsgt;net share


Share
name Resource Remark
——————————————————————————-
ADMIN$ C:\WINDOWS Remote
Admin
C$ C:\ Default
share
IPC$ Remote
IPC




  In order to create a hidden share, put a $ sign after the share name. The share will still be accessible; however it will not be easily listed through the network. Example:
· Accounting$



7. Configure Encryption on 2008 server

According to industry best practices, such as HIPAA and GLBA require that certain servers which host sensitive information should make use of encryption. Windows Server 2008 provides a built in whole disk encryption feature called BitLocker Drive Encryption (BitLocker). BitLocker protects the operating system and data stored on the disk. In Windows Server 2008, BitLocker is an optional component that must be installed before it can be used. To install BitLocker, select it in Server Manager or type the following at a command prompt:

· ServerManagerCmd
-install BitLocker –restart




bit.jpg






8. Updates amp; Hot fixes

Updates and hot fixes are key elements when hardening a server. System and security administrators
should be constantly updating and patching their servers against zero day vulnerabilities.
These patches are not limited to the operating system, but also any application which is hosted on them. Administrators should periodically check the vendor’s websites for updates. Windows Server 2008 offers a set of tools which helps administrator update and patch their servers.


·
*
WSUS: Windows
Server Update Services (WSUS) provides a software update service for Microsoft
Windows
operating systems and other Microsoft software. By using Windows Server Update Services, administrators can manage the distribution of Microsoft hot fixes and updates released through Automatic Updates to computers in a corporate environment. WSUS helps administrators track the “update health” of each individual server.





·
*
MBSA: Microsoft
Baseline Security Analyzer (MBSA) is an easy-to-use tool designed for the IT professional
that helps small- and medium-sized businesses determine their security state in accordance
with Microsoft security recommendations and offers specific remediation guidance.
Improve your security management process by using MBSA to detect common security misconfigurations and missing security updates on your computer systems.






wsus.gif







9. Anti Virus amp; NAP



Anti Virus software is also a crucial step for hardening a server. Windows Server 2008
offers a set of tools which can help combat unauthorized network access and malicious code execution.
Windows Server 2008 offers a Network Access Protection (NAP), which helps administrators to
isolate viruses from spreading out into the network. Windows server 2008 NAP uses a set of policies which cleans the affected machines and when they are healthy, permits them access to parts of your production network.
NAP
consists of client server technology which scans and identifies machines that don’t have the latest virus signatures, service packs or security patches.Some of the key functions of a Windows Server 2008 NAP server includes: 
        • * Validating Machines:
          The mission of NAP is to preserve the integrity of the network by allowing only healthy machines to have IP addresses.
        • * Restricting Network Access:
          Computers or servers which don’t meet the established policy standards can be restricted to a “quarantine” subnet where they would later be remediate the security issues.
        • * Fixing Unhealthy Machines:
          Windows Server 2008 NAP has the ability to direct hosts to a remediation server, where the latest antivirus signatures and patches are deployed through SMS packages.

vista-nap.jpg




10. Least Privilege



The concept of least privilege has been adopted by many of today’s industry standards.
A hardened server needs to have all its access reduced to a bare operational minimum.
Most of the known security breaches are often caused by elevated privileges bared by accounts. Server services should not be configured using enterprise wide administrator accounts. Windows Server 2008 has a couple of tools which can aid administrator to grant or revoke access to specific sections of the server.



  • * Script Logic’s Cloak: Script Logic Cloak is a product which enhances the Windows NT File System (NTFS) by providing increased security, more accurate audits and a vastly streamlined experience for users of the network.



  • * PolicyMaker Application Security: PolicyMaker is an add-on for the Group Policy Management Console (GPMC). This tool allows administrators to adjust application privilege levels to the lowest possible point in order to limit damages stemming from network attacks or user error. The ability to control security at such a granular level also helps organizations comply with regulatory mandates such as the Sarbanes-Oxley, HIPAA and Gramm-Leach-Bliley acts.