Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Microsoft Exchange Server Attacks
Stay protected against emerging threats
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats
SpiderLabs Blog

Encrypting Data at Rest

12925_d7310136-7aa7-4faf-9b03-ab3a3f9efe5fData should be encrypted at rest and in motion. In this post, I'll discuss encrypting data files rather than securing database communications.

There are several different approaches to encrypt data:

There's encryption in the application that feeds to the database where extra code is written to automatically encrypt selecting, inserting or updating of data.

Secondly, there are file system capabilities where everything that gets written to a disk is encrypted. This protects sensitive information from physical theft but doesn't protect from rogue DBAs copying/selecting details in a table. This option protects data as long as it is on the filesystem that supports encryption: once the data is copied, the protection is lost.  For example, if a DBA copies backups to optical media than they become cleartext and unprotected.

And third, we have Transparent Data Encryption (TDE) that utilizes the functionality that the database vendor has provided to encrypt data without modifying the application or depending on the capabilities of the file system. Changes to the database will be required depending on the implementation - from changing database options to changing column attributes.

The three major database vendors (Oracle, Sybase and Microsoft) provide database-level encryption functionality in their products. Oracle started shipping TDE as part of the Oracle Advanced Security Option in Oracle Database 10g R2 Enterprise Edition. TDE in Oracle has significantly improved it in newer database releases. Sybase Adaptive Server Enterprise (ASE) encrypted columns feature debuted in version 12.5.4 and is quite advanced in the Sybase ASE 15.5. In addition, Microsoft has shipped TDE in the Microsoft SQL Server 2008 Enterprise edition.

The main idea is simple - user-specified columns or entire database files are encrypted with a strong encryption algorithm so that data in the files can't be read by an attacker without knowing the encryption key(s).  This is done without any change to the application code. When the application issues a SELECT query, the database decrypts data and returns clear text to the application. In the same way when the application saves data via INSERT/UPDATE, the database encrypts the values and saves to the disk encrypted data. By doing so, this prevents privileged OS users on the database host from reading sensitive data as well as keeping data and backup files safe. Encryption is required to comply with certain government and industry regulations such as PCI, HIPPA, etc.


Most implementations use symmetric key encryption to encrypt the data. Usually there are two-tiers: first, symmetric keys are used to encrypt columns/data files and then there is a master key used to encrypt the column encryption keys themselves. This master key can be protected by a password (Oracle Database) or can be an asymmetric key (Microsoft SQL Server). In each implementation there are differences how the keys are stored, what is the scope of the encryption, what algorithms could be used and so on.

Oracle Databases store master keys in an external security module (ESM) which can be the Oracle Wallet (file), Hardware Security Module (HSM), or external PKCS#11 compatible key management system. HSM is a hardware device that receives encrypted column keys from the database and returns keys in clear text so the master key never leaves the device.

Microsoft SQL Server 2008 allows protecting the database encryption key by using an asymmetric key stored in an extensible key management (EKM) module which is very similar to the HSM concept: via EKM third-party EKM/HSM vendors to register their modules in SQL Server.

Sybase ASE stores a key encryption key which encrypts column encryption keys (master key) in the database and encrypts it by system encryption password, or a login password, or a user-provided password. Sybase implementation also requires special 'decrypt' permission to be granted to read clear text data.

Performance Impact

Usually the columns encrypted should be limited to ones containing sensitive or Personally Identifiable Information (PII) such as Social Security Numbers, credit card numbers, etc. in order to minimize the performance footprint.  There might be some storage overhead too depending on the strategy used.

According to the Oracle whitepaper "Oracle Advanced Security Transparent Data Encryption Best Practices," the performance impact is 4% to 8% in end-user response time, and an increase of 1% to 5% in CPU usage. Oracle Database can leverage hardware-based cryptographic acceleration in Intel Xeon 5600 CPUs with AES-NI which makes performance impact very small. Before implementing database-level encryption the impact on CPU and memory should be researched.


Index usage might be limited for certain comparison operations. In some implementations, anything except equality comparison of encrypted column's value will cause a full table scan. Not all data types are supported for the encrypted columns, for instance FILESTREAM DATA in Microsoft SQL Server 2008 is not supported. Consult your database documentation for more details on particular implementation.

Comparison Matrix

  Oracle Database 11.2 Sybase ASE 15.5 Microsoft SQL Server 2008 R2
Supported encryption algorithms AES, TRIPLE DES AES AES, TRIPLE DES
Supported key lengths 128, 192, 256 bits for AES, 168 bits for TRIPLE DES 128, 192, 256 bits 128, 192, 256 bits for AES, 192 bits for TRIPLE DES
Encryption scope Tablespace, Column Column Database (page-level)
Key assignment granularity Key per table Key per column Key per database
Encryption keys storage Wallet, HSM (hardware security module), external PKCS#11 compatible key management system, data dictionary, tablespace files Database (not necessarily encrypted one) Database
Special key management database roles No Yes No
Special permission required to read encrypted data No Yes No
Optional 'salt' support to protect against pattern analysis Yes Yes Entire files are encrypted: salt per value does not make sense.


Here are some examples that enable database-level encryption in different products.

In Oracle Database we must first configure The Oracle Wallet file location if wallet is used to store master key and create the wallet. Next the Wallet must be open via:


Then table definition can be updated to encrypt some columns:


Now the database will store password columns value encrypted on the disk. Note that the Oracle Wallet must be opened each time the database starts. Alternatively it can be configured to auto-open via 'auto-open' wallet. For more details consult Oracle documentation.

The following SQL code is used to enable simplest form of column encryption in the Sybase ASE 15.5:

   EXECUTE sp_configure 'enable encrypted columns', 1'
EXECUTE sp_encryption 'system_encr_passwd', 's1mpl3p4ssw0Rd''
ALTER TABLE Users MODIFY Password ENCRYPT decrypt_default '***'

Note that using encryption in Sybase ASE requires licensing option ASE_ENCRYPTION. First, we enable encrypted columns support, then set system encryption password and create encryption key bound to AES256 encryption algorithm. This key will be the default. It will be used in subsequent ALTER TABLE for example, since there is no explicit key name provided. The ALTER TABLE provides decrypt_default value which will be seen by users who are not granted explicit decrypt permission but still can select from the table column.

The following code is for Microsoft SQL Server 2008 Enterprise edition:

   USE master

Once it is executed, do not forget to backup the certificate used for encrypting the database encryption key and the private key associated with the certificate. The database is now encrypted.


Examine options your database provides for data encryption at rest, consider exiting limitations and your application specifics. It may be a good choice to implement database-level encryption.


Database Encryption:

Oracle Advanced Security Transparent Data Encryption Best Practices:

Encrypted Columns in ASE 15:

Understanding Transparent Data Encryption (TDE):

Latest SpiderLabs Blogs

Welcome to Adventures in Cybersecurity: The Defender Series

I’m happy to say I’m done chasing Microsoft certifications (AZ104/AZ500/SC100), and as a result, I’ve had the time to put some effort into a blog series that hopefully will entertain and inform you...

Read More

Trustwave SpiderLabs: Insights and Solutions to Defend Educational Institutions Against Cyber Threats

Security teams responsible for defending educational institutions at higher education and primary school levels often find themselves facing harsh lessons from threat actors who exploit the numerous...

Read More

Breakdown of Tycoon Phishing-as-a-Service System

Just weeks after Trustwave SpiderLabs reported on the Greatness phishing-as-a-service (PaaS) framework, SpiderLabs’ Email Security team is tracking another PaaS called Tycoon Group.

Read More