Home > Articles > Security > Software Security

This chapter is from the book

2.3 Applying Cryptography

Now that you’ve freshened your recollection of database terminology and surveyed the basics of modern cryptography, we examine how cryptography can help secure your databases against the classes of threats covered in Chapter 1.

As we discuss the types of solutions offered by cryptography, we’ll also consider the threats that cryptography is expected to mitigate. This threat analysis, as discussed previously, is an essential component of any cryptographic project, and the answers significantly shape the cryptographic solution. Unfortunately, in practice, a requirement to encrypt data is rarely supported with a description of the relevant threats. Encrypting to protect confidentiality from external attackers launching SQL injection attacks is different from protecting against internal developers with read-only access to the production database. The precise nature of the threat determines the protection.

2.3.1 Protecting Confidentiality

A breach of confidentiality occurs when sensitive data is accessed by an unauthorized individual. Encrypting that sensitive data, then, seems to make excellent sense: if the data is encrypted, you’ve secured it against unauthorized access. Unfortunately, the solution is not this simple. Cryptography only changes the security problem; it doesn’t remove it.

The initial problem was to protect the confidentiality of the business data. Encrypting that data changes the problem to one of protecting the confidentiality of the key used for the encryption. The key must be protected with very strong access controls, and those controls must cover both direct and indirect access.

Direct access is access to the key itself. An attacker with direct access may copy the key and use it without fear of detection. Indirect access is access to an application or service that has access to the key. With indirect access, an attacker can feed encrypted data to the application or service and view the decrypted information. An attacker exploiting indirect access faces additional risk, because the application or service, due to its sensitivity, is generally well monitored. From an attacker’s point of view, the advantage that might make the indirect access worth the additional risk is that the application or service will continue to provide decryption even after the key is changed. An attacker who has a copy of the key will find the key useless as soon as the data is encrypted with a different key.

The problem of securing access to the key lies behind much of the complexity of key management systems. Cryptography is often said to transform the problem of protecting many secrets into the problem of protecting one secret. Protecting this one secret, despite the complexity, is generally easier than protecting the many secrets. Because of this, encryption is a strong and preferred method of protecting confidentiality in a database.

Consider the confidentiality threats identified in the previous chapter. The potential attackers included individuals with a copy of the database, privileged administrators, IT troubleshooters, development staff using nonproduction environments, individuals with access to backup media (often stored off-site), and attackers exploiting application weaknesses. In each of these cases, encryption protects the data so long as access to the keys is tightly controlled.

While tightly controlling direct access to keys is a relatively solvable problem (this book recommends dedicated key storage hardware but offers suggestions if such protection is unavailable), controlling indirect access is more difficult. Information is stored because the business is likely to need it at a later date, and to use it at that later date, encrypted information will need to be decrypted. The application that provides the decryption service is a weak link in the security chain. Rather than attack the encryption or the controls protecting direct access to the key, a smart attacker targets the decrypting application. We’ll consider this issue in more detail in section 2.5.1, "Indirect Access of Keys."

Protecting against attackers with access to a copy of the database, whether stolen from a production machine or a backup tape, requires that the key not be stored within or, ideally, on the same machine as the database. In the case of attacks exploiting backup media, backups of keys must be stored separately from the backups of encrypted data. Access to those backups must also be restricted to different individuals. How deep that separation goes depends on the threat model. If the relevant threat is the off-site backup staff, two different staffs (perhaps two different backup companies) are all that is necessary. If the relevant threats extend all the way to internal system administrators, separate administrators should manage the backups of each system.

Protecting against administrators with full access to database or application servers is primarily a matter of strong indirect access controls to the keys. However, even with just moderate access controls protecting the keys, encryption prevents casual attacks from administrators. In particular, encryption significantly increases the amount of effort required for an administrator to compromise confidentiality and keep the risk of detection low. Such protection is often described as "keeping the honest, honest." If the threat model rates the risk of administrator compromise sufficiently low, keys may need only a moderate level of protection from indirect access.

Most threat models should identify the presence of sensitive production data in nonproduction environments as a significant threat. Because encryption does such a fine job of preserving confidentiality, encrypted production data can’t be decrypted in a nonproduction environment.2 While this is good from a security perspective, the failure in decryption typically results in a malfunctioning environment.

The best solution is to replace all the encrypted data with mock data. Ideally, the mock data reflects the entire data model specified by the application’s design, including common, general-use scenarios as well as edge cases. Depending on resource availability, the mock data might be encrypted after it is written to the database. In some cases, it might be possible to encrypt the mock data first and then update the table with the encrypted mock data wherever it is needed. This latter strategy avoids the row-by-row encryption of the mock data.

2.3.2 Assuring Integrity

Cryptography can help detect and prevent integrity attacks, which are unauthorized modifications of data. In some cases, both integrity and confidentiality protection are desired, while in other cases just integrity protection may be needed. When integrity protection alone is called for, the data itself remains unencrypted, and some other operation protects integrity.

The naive solution for both confidentiality and integrity is to simply encrypt the information with a symmetric cipher. Later, if it doesn’t decrypt properly, someone has tampered with the information.

Unfortunately, the naive solution is not very robust. A clever attacker will attack integrity in a less obvious fashion. For instance, an attacker might move encrypted fields around so that the rows containing my information now have someone else’s encrypted credit card number. Or the attacker might swap blocks within the ciphertext or between ciphertexts. In such an attack, much of the field could decrypt to the correct value, but selected portions of it would decrypt to something else. This attack might result in some garbled data, but the rest of the field would look fine.

A better solution, and one that works even if confidentiality protection is not needed, is to use a message authentication code (MAC). A MAC is generated from the plaintext and a unique ID for that row (the ID thwarts attacks that move entire fields around). To confirm the integrity of the data, we check to make sure that the MAC still corresponds to the data.

While this will detect a past integrity attack, a MAC can also prevent integrity attacks. When data and its MAC are inserted into a table, the database can first check to ensure that the MAC is the correct MAC for that data. If it is the wrong MAC (or the MAC is not included), the database can reject the change.

Every database threat model should consider integrity threats, but as described in the previous chapter, cryptographic integrity protection is typically not a good fit for databases. The threat model will help make this clear. Integrity threats against the database may be carried out by attackers directly targeting the database or by attackers targeting the application providing access to the database, which also stamps changes with the MAC. In general, attacks against the application are more likely to be successful than attacks directly against the database, so, in this context, the risk posed by the application is greater than the risk posed by the database itself. To be effective, security should be applied to the higher-risk items. Because the protection offered by a MAC further increases the difficulty of directly attacking the database successfully (which is already a lower risk), those resources should be applied to securing the application instead, thus reducing the overall risk. Refer to section 1.1.3, "Integrity Attacks," for a more detailed discussion.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020