Guarding against database anti-forensics

Database hacking has gone mainstream and is becoming harder to detect

Database hacking has gone mainstream and is becoming harder to detect because of the increasingly sophisticated anti-forensic procedures hackers use to cover their tracks.

Knowing forensics inside and out, as well as the tricks hackers use to foil forensics, is essential for professionals responsible for protecting the integrity of corporate data.

Databases contain a high percentage of confidential data, yet many organizations lack the budget and management buy-in to implement protections. According to studies, 60% of organizations have experienced a breach in the past 12 months, 80% expect database attacks to increase and 40% on average fail security audits.

There are plenty of tools to help thwart attacks -- such as vulnerability management products that include vulnerability assessment and user monitoring functionality -- but the trick is to deploy comprehensive solutions that help in forensics and provide visibility into how attackers cover their tracks.

Common anti-forensics methodologies

Where database actions are traced by different logging mechanisms such as backup, trace, transaction and operating system logs, sophisticated attackers try to hide their activities by gaining database administrator privileges to manipulate those logs.

Some common ways attackers obtain administrator privileges include:

* Exploiting a vulnerability.

* Finding a valid login and password (by brute force, guessing, stealing or with the help of a trojan).

* Taking advantage of weak or missing access controls.

* Exploiting a vulnerability in an application or in the operating system.

Attackers interfere with logs using the following techniques:

* Disable logging. Some logging mechanisms can be disabled by administrators by just running a command in the database server. This is the easiest way to avoid some logging mechanisms.

* Intercept and modify logging mechanisms. On most database management systems (DBMS), it's possible to extend functionality by loading external libraries. These libraries have code that can be executed inside the database server process. As a result, the code will have unrestricted access to all database process memory and components, allowing an attacker to manipulate logs at will. The attacker will be able to modify database server memory to intercept and avoid logging, insert backdoors, hijack user sessions and so on.

* Impersonate other database users. Because some DBMS allow privileged users to execute commands under different user accounts, it's possible to impersonate any user. When logs are reviewed after an attack they will point to an innocent user and send forensic investigators after false leads.

* Abuse logging mechanism design. With some database servers it's possible to delete and/or overwrite logs. Some logging mechanisms are designed to reuse log space after certain conditions are met. Log space can also be reduced with specific commands, forcing the oldest log entries to be deleted and/or overwritten. Attackers can force these conditions or execute commands to delete and/or overwrite log entries.

Comprehensive user rights review capabilities will ensure you have appropriate access controls in place, security features enabled, security patches applied and strong password use enforced. By ensuring your databases are properly locked down, you can block an outside attacker's entry into your system or an insider's ability to escalate his privileges in a system he has legitimate access to.

Page Break

Integrated vulnerability management in the database

There are a number of solutions available to help organizations fight back, but the choices are convoluted so it is essential to develop a comprehensive vulnerability management program. Because attackers are looking for data they can monetize, and that confidential information spends 99% of its time in a database, it's clear that's where the focus should be.

The first step toward creating a comprehensive security and compliance strategy at the database level is discovering your database assets. For example, if an attack happens, your remediation strategies grow much more cumbersome if you are unsure of exactly how many database instances you have. Are their multiple copies of those databases? Are there undiscovered databases?

Not only will a comprehensive discovery process help you understand what you have to protect, it will help prioritize what to do with those instances containing the most sensitive data. Because an attacker can take over a poorly protected low-priority system and use that access as a launching pad to gain access to a high-priority system, it's key to protect everything connected to your network.

Controlling access: Limit roles and privileges

A critical component in protecting sensitive enterprise information is ensuring the segregation of duties in the database. Most organizations have no idea who has access to what data, and this makes them vulnerable to malicious insiders. It also means they're facing potentially non-compliant status if they were to be audited.

Having an all-encompassing view of all user rights, roles and privileges across the enterprise allows internal audit teams and IT organizations to identify how certain privileges within one particular role were obtained -- and the potential vulnerabilities created with that role simply existing. For example, if a human resources person leaves a company, there is probably still a role that was created for that ex-employee in specific databases. It's worth examining that role to see the level of access, the criticality of the information stored and initiate steps to ensure that role is eliminated.

Not only is this an important component of the vulnerability management life cycle, but demonstrating the segregation of duties is a critical component of many compliance mandates, including The Sarbanes-Oxley Act, the Health Insurance Portability and Accountability Act and others.

Know what they're doing

Another integral part of developing a comprehensive vulnerability management program is implementing database activity monitoring of user activity that will detect attacks of varying types. Preserving the evidence of the attack in a protected repository outside of a hacker's reach helps establish a powerful front against attackers who are applying anti-forensics methods.

Database monitoring (DAM) is all about privileged database users who can manipulate this functionality, monitoring the health and performance of the database, to avoid and/or disable monitoring as previously explained. These privileged users are by definition given access to the innermost zones. Even in a heavily secured environment, trust and verification drive the need for DAM in any system.

DAM can be performed using third-party tools that can track all database activity based on predefined policies. When suspicious activity is detected by these tools, like anti-forensic procedures, they can fire alerts, block current activity, record the entire session and so on. When these tools are not part (not "inside") of the database server they can also closely monitor database administrators activities.

Network-based monitoring can monitor multiple databases concurrently, but they can't see encrypted traffic or monitor local sessions (i.e., a database administrator using SSH to log on remotely and then connect locally to the database server). Host-based tools can monitor local and remote sessions but can only monitor databases running on the same server.

As database hacking cases involving sophisticated anti-forensic procedures continue to climb, these attacks will require equally sophisticated countermeasures. Understanding the fundamentals of forensics and the techniques hackers use to foil forensics are essential for professionals responsible for protecting the integrity of corporate data.

Proactive security teams that establish a baseline of controls and segregation of duties at the database level and deploy the right mix of comprehensive database security, risk and compliance solutions will be able to protect the crown jewels of the organizationc -- enterprise data.

Cerrudo is a Team SHATTER Researcher with Application Security.