Home > Articles > Security > General Security and Privacy

This chapter is from the book

1.5 Tamperproofing

One of the uses of obfuscation is to add so much confusion to a program that an adversary will give up trying to understand or modify it. But what if Axel is able to break through Doris’ obfuscation defenses, then what? Well, in addition to obfuscating her code, Doris can also tamperproof it. This means that if Axel tries to make modifications to Doris’ program, he will be left with a program with unintended side effects: The cracked program may simply refuse to run, it could crash randomly, it could destroy files on Axel’s computer, or it could phone home and tell Doris about Axel’s attack, and so on.

In general, a tamperproofing algorithm performs two duties. First, it has to detect that the program has been modified. A common strategy is to compute a checksum over the code and compare it to an expected value. An alternative strategy is check that the program is in an acceptable execution state by examining the values of variables.

Once tampering has been detected, the second duty of a tamperproofing algorithm is to execute the tamper response mechanism, for example causing the program to fail. This is actually fairly tricky: You don’t want to alert the attacker to the location of the tamperproofing code since that will make it easier for him to disable it. For example, tamperproofing code like

if (tampering-detected()) abort()

is much too weak because it’s easy for the attacker to trace back from the location where the program failed (the call to abort()) to the location where tampering was detected. Once he has that information, the tamperproofing is easy to disable. A good tamperproofing system separates the tamper detection from the tamper response in both space and time.

1.5.1 Applications of Tamperproofing

Tamperproofing is important in digital rights management systems where any change to the code could allow Axel to enjoy media for free. Here’s a top-level view of a DRM system:

static final long key = 0 xb0b5b0b5 ;
void play ( byte [] media ) {
   // if (! hasPaidMoney (" Bob ")) return ;
   System . out . print ( key );    
   byte [] clear = decrypt (key , media );
   System . out . print ( clear );  
   float [] analog = decode ( clear );
   System . out . print ( analog ); 
   device . write ( analog );
}

Notice how Axel has been able to delete a check (light gray) that prevented him from playing the media if he had no money, and to insert extra code (dark gray) to dump the secret cryptographic key and the decrypted (digital and analog) media. In general, tampering with a program can involve deleting code, inserting new code, or modifying original code. All can be equally devastating.

Another common use of tamperproofing is to protect a license check. Doris inserts a check in the code that stops Axel from running the program after a specific date or after a certain number of executions, or to let no more than a given number of Axel’s employees run the program at any one time. Axel, being an unscrupulous user, locates and disables the license check to give him unlimited use of the program. Doris can obfuscate her program (to make it hard for Axel to find the license code), but she can also tamperproof the license check so that if Axel finds and alters it, the program will no longer function properly:

There are situations where simply failing when tampering is detected isn’t enough; you also need to alert someone that an attack has been attempted. For example, consider a multi-player online computer game where, for performance reasons, the client program caches information (such as local maps) that it won’t let the player see. A player who can hack around such limitations will get an unfair advantage over his competitors. This is a serious problem for the game manufacturer, since players who become disillusioned with the game because of rampant cheating may turn to another one. It’s therefore essential for the game administrators to detect any attempt at tampering so that anyone who tries to cheat can immediately be ejected from the game. The term we use for this problem is remote tamperproofing. The goal is to make sure that a program running on a remote untrusted host is the correct, unadulterated version, and that it is running in a safe environment. “Safe” here can mean that the program is running on the correct hardware (and not under a hacked emulator), that the operating system is at the correct patch-level, that all environment variables have reasonable values, that the process has no debugger attached, and so on. As long as the client code determines that it is running safely and hasn’t been tampered with, it sends back a stream of surreptitious “I’m-OK” signals to the server:

In this figure, the program is using steganographic techniques to embed this secret bitstream in TCP/IP headers.

Even if you don’t intend to cause harm to a cheating game player, monitoring your protected programs for evidence of an ongoing attack can still be useful. We know of at least one major software protection company that includes a phone home facility in their code that allows them to watch, in real time, an attack in progress. Being able to see which strategies the attacker is using, see which strategies are successful, measure how long an attack takes to complete and thus, ultimately, get a feel for which protection algorithms are effective and which are not is definitely useful. However, we know that other software protection companies eschew such eavesdropping because of its problematic privacy issues.

1.5.2 An Example

If you have ever run a signed Java applet or installed a program signed by Microsoft, you’ve already had experience with programs designed to detect tampering. A signed program carries a certificate issued by a known authority that can be used to detect if some part of the program has been changed. Usually such detection is extrinsic to the program itself. For example, if you try to install a signed Microsoft program that has been tampered with, the OS will check that the signature is one that Microsoft trusts and that the program has not been altered since it was signed. Unfortunately, the obvious way of extending such a scheme to allow a program to check itself for tampering is not effective. To see this, have a look at the program in Listing 1.5▸36, which converts temperatures expressed in Fahrenheit into Celsius. The function bad-check-for-tampering protects the program from tampering by comparing a checksum of the program file to a checksum computed when the program was compiled. If they’re not the same, the program simply quits.

Can you think of any difficulties in writing such a program? One problem is that checksum is embedded in the program and as a result affects the checksum itself! To successfully construct such a program requires searching for a value that, when inserted into the program as a checksum, results in the program having that value as a checksum.

A further problem is that in spite of its clever construction, once a function has been identified by the attacker as a tamper-detection function, it’s easy to remove any calls to it.

The function better-check-for-tampering is slightly better. Instead of merely checking for tampering, it incorporates the output of the checksum into the code itself. If the program is altered, the value returned by this function changes, which in turn makes the program subtly incorrect.

In spite of the improvements, better-check-for-tampering remains vulnerable to the same attack as bad-check-for-tampering. Both tamper-checking functions are easy to identify, because programs rarely attempt to read themselves. Once a function is identified as a tamper-checking function, it can be replaced by a simple function that returns the original checksum as a constant. Thereafter, an attacker can go ahead and modify the program arbitrarily.

These weaknesses notwithstanding, checksumming code forms the basis of many tamperproof detection techniques used in practice. You’ll see some of them in Chapter 7 (Software Tamperproofing).

Listing 1.5. A self-checking program in Java.

import java.io.*;
import java.security.*;

public class tamper {

   public static int checksum-self () {
      File file = new File("tamper.class");
      FileInputStream fr = new FileInputStream (file);
      DigestInputStream sha = new DigestInputStream (fr,
                              MessageDigest.getInstance ("SHA"));
      while (fr.read () != -1) {}
      byte[] digest = sha.getMessageDigest().digest ();
      int result = 12;
      for (int i=0; i < digest.length; i++) {
         result = (result + digest[i]) % 16;
      }
   }
   public static boolean bad-check-for-tampering () throws Exception {
      return checksum-self() != 9;
   }
   public static int better-check-for-tampering () throws Exception {
      return checksum-self();
   }
   public static void main (String args[]) throws Exception {
      if (bad-check-for-tampering()) System.exit (-1);
      float celsius=Integer.parseInt (rgs[0]);
      float fahrenheit=better-check-for-tampering() * celsius / 5 + 32;
      System.out.println (celsius + "C = " + fahrenheit + "F");
    }
}

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