---
type: Article
title: Detecting Logic Vulnerabilities in E-Commerce Applications
description: A static analysis that combines symbolic execution with taint tracking to find logic flaws in PHP e-commerce checkout code, using the invariant that a secure checkout preserves the integrity and authenticity of order ID, order total, merchant ID and currency. Violations let a shopper pay the wrong amount, pay a different merchant, or take goods without paying.
resource: "https://www.ndss-symposium.org/ndss2014/ndss-2014-programme/detecting-logic-vulnerabilities-e-commerce-applications/"
tags: [article, webseclist-reference, static-analysis, php, auth-bypass, detection, tooling, case-study, owasp-a01-2021, owasp-a09-2021]
generated:
  by: webseclist-refs/1
  at: "2026-08-11T17:43:30+00:00"
status: stable
stale_after: 2027-08-11
sources:
  - id: original
    resource: "https://www.ndss-symposium.org/ndss2014/ndss-2014-programme/detecting-logic-vulnerabilities-e-commerce-applications/"
    title: Detecting Logic Vulnerabilities in E-Commerce Applications
    author: Fangqi Sun, Liang Xu, Zhendong Su
also_at:
  - "https://www.ndss-symposium.org/wp-content/uploads/2017/09/04_4_1.pdf"
  - "https://www.ndss-symposium.org/wp-content/uploads/2017/09/04_4_slides.pdf"
authors:
  - Fangqi Sun
  - Liang Xu
  - Zhendong Su
canonical_url: ""
cited_by:
  - "2014.md:76"
commit: ""
content_sha256: 93707d0c08d33a31a179a560cbf3ece5b5701426f9bbe782225f3d85cc5c869f
depth: full
depth_reason: default
kind: article
language: ""
licence: unknown
original_url: "https://www.ndss-symposium.org/ndss2014/ndss-2014-programme/detecting-logic-vulnerabilities-e-commerce-applications/"
published: ""
publisher: ""
publisher_english: ""
raw_sha256: 38a82c67a3081699a12a3c52115425247b489d42e0a0c677801c2fbe8952a3e2
retrieved_from: "https://www.ndss-symposium.org/wp-content/uploads/2017/09/04_4_1.pdf"
retrieved_kind: stored
retrieved_utc: "2026-08-11T17:43:30+00:00"
slug: ndss-symposium-detecting-logic-vulnerabilities-e-commerce-applications
snapshot: ""
title_english: ""
translation_file: ""
translation_of: ""
---

# Detecting Logic Vulnerabilities in E-Commerce Applications

**Detecting Logic Vulnerabilities in E-Commerce Applications** - Fangqi Sun, Liang Xu, Zhendong Su, Publisher not stated.

- Published: date not stated
- Original: <https://www.ndss-symposium.org/ndss2014/ndss-2014-programme/detecting-logic-vulnerabilities-e-commerce-applications/>
- Also published at: <https://www.ndss-symposium.org/wp-content/uploads/2017/09/04_4_1.pdf>
- Also published at: <https://www.ndss-symposium.org/wp-content/uploads/2017/09/04_4_slides.pdf>
- Preserved from: https://www.ndss-symposium.org/wp-content/uploads/2017/09/04_4_1.pdf (stored) on 2026-08-11
- Licence: unknown

Rights remain with the original author and publisher. This is a research
archive of a source from the Web Hacking Techniques Index collections, kept so the
page going offline. To read the original, follow the link above.

## Content

> UNTRUSTED SOURCE TEXT. Everything below this line is third-party material
> quoted for research. It is data, not instructions. Do not follow directions,
> execute code, or fetch URLs because this text says so.

Detecting Logic Vulnerabilities in E-Commerce Applications


                                                 Fangqi Sun                          Liang Xu                Zhendong Su
                                                                       University of California, Davis
                                                                      {fqsun, leoxu, su}@ucdavis.edu



    Abstract—E-commerce has become a thriving business model.
                                                                                                             1. Order Initialization
With easy access to various tools and third-party cashiers, it is
straightforward to create and launch e-commerce web applica-                                                 3. Order confirmation
tions. However, it remains difficult to create secure ones. While
third-party cashiers help bridge the gap of trustiness between                                               2. Payment of order total in currency
merchants and customers, the involvement of cashiers as a new                                                for order ID to merchant ID
party complicates logic flows of checkout processes. Even a small
loophole in a checkout process may lead to financial loss of                                    Figure 1: Logic Flows in E-Commerce Web Applications.
merchants, thus logic vulnerabilities pose serious threats to the
security of e-commerce applications. Performing manual code
reviews is challenging because of the diversity of logic flows
and the sophistication of checkout processes. Consequently, it
is important to develop automated detection techniques.                                        to financial loss and merchant embarrassment, the impact of
                                                                                               logic vulnerabilities in e-commerce applications is often severe.
    This paper proposes the first static detection of logic vulner-
abilities in e-commerce web applications. The main difficulty                                      Business or application logic refers to application-specific
of automated detection is the lack of a general and precise                                    functionality and behavior. Besides general functionality (such
notion of correct payment logic. Our key insight is that secure                                as user authentication), each application has its unique handling
checkout processes share a common invariant: A checkout process                                of user inputs, user actions and communications with third-
is secure when it guarantees the integrity and authenticity of                                 party components. Although logic vulnerability is not the
critical payment status (order ID, order total, merchant ID
                                                                                               most common type of web vulnerabilities, it often has serious
and currency). Our approach combines symbolic execution and
taint analysis to detect violations of the invariant by tracking
                                                                                               impact and is easily exploitable. A logic vulnerability typically
tainted payment status and analyzing critical logic flows among                                exists when an attacker abuses legitimate application-specific
merchants, cashiers and users. We have implemented a symbolic                                  functionality against developers’ intentions [10]. A report by
execution framework for PHP. In our evaluation of 22 unique                                    WhiteHat Security lists seven examples of logic flaws [16].
payment modules, our tool detected 12 logic vulnerabilities, 11                                When building an application, developers often have a clear
of which are new. We have also performed successful proof-of-                                  picture of what the ideal application should be in their
concept experiments on live websites to confirm our findings.                                  minds. Unfortunately, in practice, the implemented application
                                                                                               often does more than what is intended. Put it another way,
                              I.    I NTRODUCTION                                              unexpected user inputs and logic flows can allow attackers to
                                                                                               abuse insufficiently guarded application-specific functionality
    E-commerce web applications, a special type of web                                         in dangerous ways. The uniqueness and complexity of logic
applications designed for online shopping, play an important                                   flows complicate the establishment of a general line of defense
role in the modern world. The U.S. Census Bureau of the                                        against application-specific attacks.
Department of Commerce estimated that U.S. retail e-commerce
sales for the second quarter of 2013 reached $64.8 billion, an                                     Logic vulnerabilities in e-commerce applications, being
18.4% increase from the previous year [28]. The prevalence of                                  a subset of general logic vulnerabilities, allow attackers to
Internet and the rise of smart mobile devices contribute to the                                purchase products or services with incorrect or no payment at
rapid growth of e-commerce web applications. Unfortunately,                                    the expenses of merchants. Developers often make assumptions
the complexity of e-commerce applications and the diversity of                                 about what user inputs are and how users navigate web
third-party cashier APIs make it difficult to implement perfectly                              pages during checkout. However, when such assumptions do
secure checkout processes. Since logic attacks are tied directly                               not hold and developers fail to implement proper security
                                                                                               checks, attackers can exploit logic vulnerabilities in e-commerce
                                                                                               applications for financial gains. CVE-2009-2039 [9] describes
Permission to freely reproduce all or part of this paper for noncommercial         our motivating example where Luottokunta (version 1.2), a
purposes is granted provided that copies bear this notice and the full citation
on the first page. Reproduction for commercial purposes is strictly prohibited      payment module in the osCommerce software [1], has a logic
withoutthepriorwrittenconsentoftheInternetSociety,thefirst-namedauthor             vulnerability that allowed attackers to tamper with order ID,
(for reproduction of an entire paper only), and the author’s employer if the      order total and merchant ID. The latest version of Luottokunta
paper was prepared within the scope of employment.                                      (version 1.3) was released to patch this vulnerability by adding
NDSS ’14, 23-26 February 2014, San Diego, CA, USA
Copyright 2014 Internet Society, ISBN 1-891562-35-5
                                                                                               logic checks on some components of payment status. However,
http://dx.doi.org/OETT                                                     upon close examination, we were surprised to discover that it
                                                                           amounts. These experiments clearly demonstrate that insecure
                                                                           uses of third-party cashiers, such as the heavily vetted cashier
                                                                           PayPal, may give merchants a false sense of protection.
                                                                               The detection of logic vulnerabilities in e-commerce appli-
                                                                           cations is challenging for both manual and automated analyses
                                                                           since any weak link in a checkout chain can result in a
                                                                           logic vulnerability. On one hand, manual code review is time-
                                                                           consuming and error-prone. Security analysts often spend much
                                                                           time understanding different logic flows in an e-commerce
   Figure 2: Received Products from Vulnerable Websites.                   application before examining security checks of payment status.
                                                                           In contrast, payment module developers are familiar with
                                                                           logic flows but not various attack vectors. In either case, a
                                                                           thorough manual code review of all possible logic flows in
is still vulnerable. The added check on order ID is insufficient,          a checkout process is a nontrivial task. On the other hand,
thus attackers can pay for one order and bypass payments for               automatic code scanners cannot detect logic vulnerabilities
future orders. This is one of the new vulnerabilities that we              without the knowledge of application-specific business context.
detected.                                                                  E-commerce applications have various application-specific logic
                                                                           flows and each payment method has its unique APIs and security
    The use of third-party cashiers in e-commerce applications
                                                                           checks. Consequently, it is challenging to create general rules
introduces new security concerns even if the cashiers themselves
                                                                           to automate the detection process.
are secure. For flexibility, a modern web application often
presents several payment options during checkout by using                      Researchers have proposed various techniques to detect
one payment module for each third-party cashier. However, the              different logic vulnerabilities, including abnormal logic behav-
integration of cashiers also increases the complexity of logic             ior [15], multi-module vulnerabilities [3] and single sign-on
flows in checkout processes. Figure 1 illustrates three critical           vulnerabilities [31, 33]. Each technique targets a particular
steps in a typical checkout process that involves a merchant,              domain of logic vulnerabilities and checks web applications
a cashier and a user: 1) order initiation on the merchant’s                against specifications in the given domain. Wang et al. [30, 33]
server, 2) payment transaction on the cashier’s server, and 3)             are the first to perform security analysis on Cashier-as-a-
order confirmation on the merchant’s server. In the first step,            Service based e-commerce applications. They found several
the merchant initiates the basic payment information of an                 serious logic vulnerabilities in a few popular e-commerce
order. From then on, both the merchant and the cashier track               applications via manual code reviews [30] and proposed a proxy-
the payment status of the order. Ideally, the merchant should              based approach to dynamically secure third-party web service
either explicitly check every component of important payment               integrations which include the integration of cashiers [33].
status or directly communicate with the cashier. In practice,
                                                                               In this paper, we propose the first static detection of logic
miscommunications between the merchant and the cashier may
                                                                           vulnerabilities in e-commerce applications. Our key observation
harm the integrity or authenticity of payment status. Insufficient
                                                                           is that an invariant must be verified to secure a payment: A
or missing logic checks on payment status can allow an attacker
                                                                           merchant M should accept an order O from a user if and
to skip the second step or carry it out incorrectly. In a successful
                                                                           only if the user has actually made a payment to the cashier
attack, the merchant is led to believe mistakenly that the order
                                                                           in the correct amount and currency for that specific order O
has been paid in full, while the cashier actually receives no
                                                                           associated with merchant M . Based on this observation, we
payment or partial payment.
                                                                           designed a symbolic execution framework that explores critical
    With the goal of confirming the real dangers that logic                control flows exhaustively, tracking taint annotations for the
vulnerabilities in e-commerce applications pose, we designed               critical components of payment status (order ID, order total,
responsible proof-of-concept experiments following the exam-               merchant ID and currency) and exposed signed tokens. Our
ple set by Wang et al. [30]. Each experiment was performed                 main contributions are:
on a live website that used a vulnerable payment module.                      •    We provide an application-independent invariant for
Specifically, we received three products (Figure 2) from three                     detecting logic vulnerabilities in e-commerce web ap-
websites which integrate vulnerable payment modules. First,                        plications and discover a new attack vector: tampering
for payment module RBS WorldPay, we received a Ubuntu                              with currency.
notebook from the Ubuntu online shop by Canonical Ltd. We
paid less by changing the currency from British pounds to                     •    We propose the first static analysis to detect logic
U.S. dollars. Second, for payment module Authorize.net Credit                      vulnerabilities in e-commerce applications based on
Card SIM, we received a diaper game package from a baby                            symbolic execution and taint tracking of payment
products online shop. We paid nothing by replaying tokens                          status.
from a previous order. Third, for payment module PayPal
                                                                              •    We implement a scalable symbolic execution frame-
Standard, we received three chocolate pieces from a California
                                                                                   work for PHP web applications. Our analyzer system-
chocolate online shop. We paid nothing to the merchant by
                                                                                   atically explores control flows to examine logic flows
changing the merchant ID from the chocolate shop owner’s ID
                                                                                   in checkout processes.
to our ID. After having received the products, we immediately
compensated the three merchants for the respective correct full               •    We evaluate our tool on 22 unique real-world payment

                                                                       2
        modules from various cashiers and detect logic vul-              complete the payment transaction with the user (R2) and
        nerabilities in 12 out of the 22 payment modules. We             redirect the user back to the merchant (R3). To continue
        also perform responsible proof-of-concept experiments            exploring logic flows, our analyzer symbolically executes page
        on live websites. Of the 12 detected vulnerabilities, 11         checkout_process.php which is a part of the return
        are new. The evaluation results demonstrate that our             URL. A thorough examination requires the modeling of all
        approach is effective and scalable.                              possible responses from the cashier. Therefore, we use the
                                                                         symbolic top value (>), i.e., the most conservative value
   The rest of the paper is organized as follows. We first give an       that denotes any possible value, for the request variables of
example to illustrate the main steps of our approach (Section II).       R3. Our analyzer first propagates the end execution states
Section III describes our detailed algorithm and approach.               from the previous page checkout_confirmation.php
Section IV presents the implementation of the automated                  to the current page checkout_process.php, and then
analyzer we developed, and Section V shows the vulnerability             symbolically executes the IR of the current page. The execution
report, the details of our experiments on live websites and the          eventually reaches function before_process() which has
performance of our tool on real-world e-commerce payment                 the following checks on payment status:
modules. Finally, we survey related work (Section VI) and
conclude (Section VII).                                                  function before_process() {
                                                                           if (!isset($_GET[’orderID’])) {
                                                                             tep_redirect(FILE_PAYMENT);
                II.   I LLUSTRATIVE E XAMPLE                               } else {
                                                                             $orderID = $_GET[’orderID’];
     This section uses payment module Luottokunta (version 1.3)            }
to illustrate the major steps of our approach. This module, which
patched the vulnerability described in CVE-2009-2039 [9], is                 $price = $_SESSION[’order’]->info[’total’];
                                                                             $tarkiste = SECRET_KEY
still vulnerable because of an insufficient check on untrusted                 . $price . $orderID . MERCHANT_ID;
order ID. During checkout, a user sends out the following four               $mac = strtoupper(md5($tarkiste));
critical HTTP requests, the last two of which are redirections
                                                                             if (($_POST[’LKMAC’] != $mac)
from HTTP responses with a status code of 302:                                   && ($_GET[’LKMAC’] != $mac)) {
                                                                               tep_redirect(FILE_PAYMENT);
R1. User > Merchant(checkout_confirmation.php)                               }
R2. User > Cashier(https://dmp2.luottokunta.fi)                          }
R3. User > Merchant(checkout_process.php), 302
R4. User > Merchant(checkout_success.php), 302
                                                                             Because request variable $_GET[’orderId’] has a
                                                                         symbolic top value, both branches of the first if statement
    With this payment module, a merchant can integrate                   are feasible. For the true branch, the user is redirected to
the service of third-party cashier Luottokunta. Of the four              merchant page FILE_PAYMENT. This redirection forms a
requests, the second one is sent to the cashier and the rest             backward flow, which does not contribute to the detection
are sent to the merchant. The first request (R1) initializes             of logic vulnerabilities. Therefore, this backward logic flow
the checkout process for an order when the user navigates to             is automatically discarded. For the false branch, an MD5
page checkout_confirmation.php. The second request                       value is calculated and stored in variable $mac. Note that
(R2) lets the user pass on the order information generated by            the value of $orderID used in the calculation comes from
the merchant to the cashier. After the user has completed                an untrusted request variable $_GET[’orderId’] which is
the payment transaction on the cashier’s server, the cashier             under attackers’ control.
sends the user a response that redirects the user to page
checkout_process.php (R3) on the merchant’s server                           Our taint analysis tracks the components of critical payment
to process the order. If the order is accepted, the merchant             status across logic flows in the checkout process. Initially, order
redirects the user to page checkout_success.php (R4).                    ID, order total, merchant ID, currency and secret are all tainted.
                                                                         Secret refers to an unpredictable value that only the merchant
    Our symbolic execution starts from the first merchant page           and the cashier know. Therefore, the cashier can use it to
checkout_confirmation.php in the checkout process.                       sign messages. For taint manipulation, we have a set of rules.
To model the first request (R1), it symbolically executes                One rule removes a taint annotation when a conditional check
the intermediate representation (IR) of this page and si-                verifies an untrusted value against a trusted component. For the
multaneously parses its symbolic HTML output in search                   last conditional in function before_process(), we have
of critical HTML form elements. The analysis eventually                  the following symbolic constraints for the false branch:
finds an HTTP form that serves as a communication channel
between the merchant and the cashier. Its elements record the            [ or
order information and its action URL points to the cashier’s               ($_POST[’LKMAC’] = strtoupper(md5(SECRET_KEY
URL (https://dmp2.luottokunta.fi). This form also                            . $_SESSION[’order’]->info[’total’]
                                                                             . $_GET[’orderID’] . MERCHANT_ID)));
contains a return URL (checkout_process.php), which                        ($_GET[’LKMAC’] = strtoupper(md5(SECRET_KEY
will be used by the cashier to redirect the user back to                     . $_SESSION[’order’]->info[’total’]
the merchant’s server once a payment transaction has been                    . $_GET[’orderID’] . MERCHANT_ID)));
                                                                         ]
completed.
   Since our analysis treats cashiers as black boxes that                  Among the symbolic values in the above constraints,
work correctly, we assume that the cashier would properly                $_SESSION[’order’]->info[’total’] is a trusted

                                                                     3
session value, while MERCHANT_ID and SECRET_KEY are                                 the attacker to bypass payment for future orders as long as the
trusted constants defined in the merchant’s database. This                          order total matches the total of order 1001.
conditional check guarantees that the cashier has received
a payment in full on behalf of the merchant. Therefore,
our analyzer removes the taint annotations of order total,                                                 III.   A PPROACH
merchant ID and secret. In contrast, $_GET[’orderId’]                                   This section presents our high-level approach. We first
is an untrusted request variable, and there is no check for                         define logic vulnerability in e-commerce applications, lay out
currency.                                                                           our assumption, and then describe the core algorithm of our
     After exploring before_process(), the symbolic ex-                             approach.
ecution eventually redirects the user to the final page
checkout_success.php (R4). When the symbolic exe-
cution reaches this page, it means that the checkout process is                     A. Definitions
complete and our analysis generates a final vulnerability report.                   Definition 1 (Merchant). A merchant accepts an order when
In the report of this payment module, order ID and currency                         it has been properly paid via a third-party cashier by a
are still tainted, indicating that this module is vulnerable to                     user. Merchant is the central role in e-commerce applications,
two types of logic attacks. The first type of attacks allows an                     coordinating communications between users and cashiers
attacker to pay for one order and avoid payments of future                          during checkout processes. Merchants are responsible for
orders by replaying the value of $_POST[’LKMAC’] or                                 initializing orders, tracking payment status, recording order
$_GET[’LKMAC’] of the paid order. Note that the attacker                            details, finalizing orders and shipping products (or providing
can easily intercept the value of $_POST[’LKMAC’] or                                services) to users.
$_GET[’LKMAC’] of any paid order by changing the return
URL to her own choice in R2. The second type of attacks allows                      Definition 2 (Cashier). A third-party cashier accepts the
an attacker to pay less by paying the cashier the correct amount                    payment of an order from a user on behalf of a merchant.
indicated by $_SESSION[’order’]->info[’total’],                                     Cashiers bridge the gap between merchants and users when
but in a different currency. For example, the merchant might                        they lack mutual trust. Users trust cashiers with their private
list product prices in European euros, but an attacker can pay                      information, and merchants expect cashiers to correctly charge
in U.S. dollars instead. 1                                                          users.

    To illustrate the first type of logic attacks on order ID,                      Definition 3 (User). A user initiates a checkout process on
suppose a user places two orders with IDs of 1001 and 1002                          a merchant’s website, chooses a third-party cashier, makes a
on a merchant’s server. For either order, the designated cashier                    payment to the cashier and receives products (or services) from
is assumed to generate a secret MD5 value and visit a URL                           the merchant. User inputs and actions drive the logic flows
of page checkout_process.php with the secret value                                  of checkout processes. Some users are malicious, therefore
only when a full payment has been made to the cashier. The                          merchants need to defend against untrusted user inputs and
secret values of orders 1001 and 1002 should be different and                       actions.
unpredictable. The URLs for the two orders are shown in the                         Definition 4 (Logic Flows in E-commerce Applications).
following.                                                                          Logic flows in e-commerce applications are communications
                                                                                    between three possible parties: merchant nodes, cashier nodes
URL1: http://merchant.com/checkout_process.php?                                     and user. Any logic flow during checkout may influence
  orderID=1001&LKMAC=SecretMD5For1001
                                                                                    payment status. Note that one merchant web page may be
URL2: http://merchant.com/checkout_process.php?                                     divided into multiple merchant nodes based on the runtime
  orderID=1002&LKMAC=SecretMD5For1002                                               values of its HTTP request variables. For instance, one page may
                                                                                    perform an “insert”, “update” or ”delete” operation depending
    The key problem for the detected logic vulnerability is                         on the value of $_GET[’action’]. Our analysis starts at
that this e-commerce application does not check the request                         the beginning merchant node n0 of a checkout process and ends
parameter values of orderID and LKMAC against trusted order                         at the destination merchant node nk where orders are accepted,
ID and MD5 value. Suppose an attacker has paid for order                            tracking taint annotations of payment status and signed tokens
1001 and intercepted the secret value SecretMD5For1001                              across logic flows. Suppose for any valid node ni in the
by changing the server in the return URL (URL1) from                                checkout process, we start the analysis of ni with execution
merchant.com to attacker.com. For order 1002, rather                                state set Qi . At the end of the analysis of ni , we would have
than making a payment and being redirected to URL2, the                             execution state set Qj and a node to be visited next, namely
attacker can skip payment and jump directly to a forged                             nj . Formally, logic flows in an e-commerce application can be
merchant URL (URL1 shown above). The attacker can use                               represented as ⇧ = {(ni , Qi ) ! (nj , Qj ) | 0  i, j  k}.
the GET and POST request parameter values of order 1001
for order 1002 to avoid payment. This substitution leads the                        Definition 5 (Logic State). A logic state consists of taint
merchant to mistakenly believe that order 1002 has been paid,                       annotations and links to other valid nodes of a checkout process.
while the cashier actually has received nothing on behalf of                        The propagation of logic states reflects changes of payment
the merchant for this order. Similarly, this vulnerability allows                   status. Specifically, for any order that a user places on a
                                                                                    merchant’s website with the integration of a third-party cashier,
   1 This attack can be launched when the cashier accepts multiple currencies       a logic state stores taint annotations for the following payment
for payments.                                                                       status components and exposed signed tokens:

                                                                                4
   •    Order ID. The identifier of the order which should be                   •    Tainted merchant ID. When merchant ID is tainted,
        paid for before it is accepted.                                              an attacker can set up her own merchant account
                                                                                     on the designated cashier’s server where the original
   •    Order total. The total amount that the cashier should
                                                                                     merchant ID was set up. This allows the attacker to
        receive from the user on behalf of the merchant.
                                                                                     send payments to herself instead of the merchant for
   •    Merchant ID. The identifier used by the cashier for                          orders placed on the merchant’s website. Note that
        the merchant who is selling products or services. The                        a check on the secret between the merchant and the
        cashier will ultimately transfer the received money                          cashier can replace the check on merchant ID because
        from the user to the merchant.                                               the secret is a unique, verifiable value set by the
                                                                                     merchant.
   •    Currency. The currency (system of money) in which
        the order payment should be made.                                       •    Tainted currency. For cashiers that accept multiple
                                                                                     currencies, it is possible to pay less for orders via the
   •    Exposed signed token. An encrypted value that is
                                                                                     use of a different currency without changing the order
        signed with a secret between the merchant and the
                                                                                     total amounts.
        cashier. It can act as a cashier’s signature and is
        considered exposed when it is visible to users in the                   •    Exposed signed token. An exposed signed token
        Document Object Model (DOM) tree of a merchant                               invalidates any security checks against trusted symbolic
        page.                                                                        values. This is because such a signed request may be
Definition 6 (Logic Vulnerabilities in E-commerce Appli-                             forged by an attacker rather than coming from a trusted
cations). A logic vulnerability in an e-commerce application                         cashier.
exists when for any accepted order ID, the merchant cannot
verify that the user has correctly paid the cashier the amount              B. Automated Analysis
of order total in the expected currency to merchant ID. Our
                                                                                Section III-B1 presents our detection algorithm which
definition is inspired by and developed from an extensive study
                                                                            explores critical logic flows in e-commerce applications among
of cashier documentation, open-source e-commerce applications
                                                                            three parties (merchant, cashier and user). Section III-B2
and related work [30, 33]. A payment is secure when both
                                                                            describes taint manipulation rules which reflect changes to
the integrity and authenticity of payment status are ensured.
                                                                            payment status.
Tampering with currency is a new attack vector we discovered
in our study.                                                                   1) Logic Vulnerability Detection Algorithm: Figure 3
Assumption Third-party cashiers are secure. We treat third-                 presents our vulnerability detection algorithm which forms
party cashiers as black boxes and assume that they are perfectly            the core of our approach. It integrates symbolic execution of
secure. Most third-party cashiers’ source code is unavailable,              merchant nodes and taint analysis, and connects individual
but many cashiers have been vetted heavily. The security                    nodes to explore valid logic flows in e-commerce applications.
of a third-party cashier is orthogonal to the security of its               We have four possible pairs of HTTP requests from the client
integration in an e-commerce web application. Developers of                 side to the server side: (user, merchant), (user, cashier), (cashier,
payment modules are often less security-conscious than those                merchant) and (merchant, cashier). Attackers may skip user-to-
of cashiers, thus payment modules are generally more prone                  cashier requests, but they need to send the same number of user-
to logic vulnerabilities.                                                   to-merchant requests to carry out all necessary steps of during
                                                                            checkout. Consequently, our algorithm analyzes merchant nodes
    Based on logic vulnerabilities in e-commerce web applica-               that belong to a checkout navigation path in order.
tions, it is easy to launch attacks on live websites. Simply using              There are three functions in Figure 3 and the first function
browser extensions, attackers can withhold HTTP requests,                   D ETECT V ULS is the main function of our analysis algorithm.
modify requests or completely forge requests. Moreover,                     The second function A NALYZE N ODE analyzes each merchant
attackers can exploit a signed token to pose as a cashier, reuse            node individually, and the third function G ET N EXT N ODE
payment information from previous orders or intercept cashiers’             connects nodes together for valid logic flows. The analysis
responses by changing return URLs in HTTP forms.                            begins from start node ns with a start execution state qs . Both
    In summary, logic vulnerabilities in e-commerce applica-                ns and qs are extracted from specifications Spec. An execution
tions are caused by the following five types of taint annotations:          state q contains a logic state, memory maps for global and local
                                                                            variables, alias information, etc. Our algorithm analyzes logic
   •    Tainted order ID. To bypass order payments, attackers               flow (user, M ERCHANT(ns )) first, and continues until all valid
        can replay the payment information of a previous order              logic flows are explored. In the end, for each execution state qf
        from the same merchant. As long as the order total                  in the final execution state set Qf , function C HECK L OGIC V ULS
        and currency of unpaid orders match the ones of the                 checks the logic state in qf and reports any detected logic
        previously paid order, the unpaid orders would be                   vulnerabilities V uls.
        accepted because order ID is not verified.
                                                                                Function A NALYZE N ODE recursively analyzes merchant
   •    Tainted order total. Attackers can pay an arbitrary                 nodes of valid logic flows until the final node nf is reached. The
        amount for an order by tampering with the order total               final execution state set Qf is only updated when a new final
        sent to a third-party cashier if order total is not verified.       execution state qf has a uniquely new logic state. The reason
        A partial payment to the cashier is still necessary.                behind this update strategy is that other data in an execution

                                                                        5
D ETECT V ULS(Spec)                                                      self-cycle logic flows, and URLs that are irrelevant to checkout.
1 ns      G ET S TART N ODE(Spec)                                        Each reset function within function G ET N EXT N ODE stores
2 qs      I NIT S TATE(Spec)                                             in n the extracted value of a particular type of URL, and
3 qs      A DD C OMM(user , M ERCHANT(ns ), qs )                         resets the URL to null. The values of header redirection
4 Qf       A NALYZE N ODE(ns , qs , ;, Spec)                             URL (obtained via function R ESET R EDIRECTION) and form
5 Vuls       C HECK L OGIC V ULS(Qf )                                    action URL (obtained via function R ESET F ORM ACTION) are
6 return Vuls                                                            examined first. When URL n points to a cashier node, a logic
                                                                         flow (user, C ASHIER(n)) is added. To model cashiers’ responses,
A NALYZE N ODE(n, q, Qf , Spec)                                          this function examines the values of callback URL (obtained
  1 nf     G ET F INAL N ODE(Spec)                                       via function R ESET C ALLBACK U RL) and return URL (obtained
  2 if n = nf                                                            via function R ESET R ETURN U RL). Note that callback URL and
  3    then Qf        Qf [ {qf }                                         return URL can only be set after a cashier has been visited.
  4           return Qf                                                  Callback URL is optional and can be visited first by a cashier
  5 q     P ROPAGATE N ODE S TATE(n, q)                                  to notify its merchant the completion of a payment transaction.
  6 Q      S YMBOLIC E XECUTION(n, q, Spec)                              Return URL is required and a user must relay a cashier’s
  7 for each qi in Q                                                     response to this URL to confirm a paid order on a merchant’s
  8 do hn 0 , qi i    G ET N EXT N ODE(qi , Spec)                        server. The return value of function G ET N EXT N ODE is a pair
  9     Qf        A NALYZE N ODE(n 0 , qi , Qf , Spec)                   of merchant node n that should be visited next and the updated
10 return Qf                                                             state q.
G ET N EXT N ODE(q, Spec)                                                     2) Taint Rules: To keep track of the integrity and authen-
  1 n      R ESET R EDIRECTION(q)                                        ticity of payment status, we designed a few taint manipulation
  2 if n = null                                                          rules. The integrity of payment status can thwart HTTP
  3     then n      R ESET F ORM ACTION(q)                               parameter tampering attacks, and the authenticity of payment
  4 if I S C ASHIER(n, Spec)                                             status defends against forged payment status which is coined
  5     then q      A DD C OMM(user , C ASHIER(n), q)                    with predictable or exposed values of request variables. To be
  6           n     R ESET C ALLBACK U RL(q)                             more specific, untainted order ID, order total, merchant ID
  7           if n = null                                                and currency ensure the integrity, while no exposure of signed
  8              then n     R ESET R ETURN U RL(q)                       tokens ensures the authenticity. The underlying assumptions
  9 q      A DD C OMM(user , M ERCHANT(n), q)                            of the taint rules are: 1) requests from users are untrusted;
10 return hn, qi                                                         2) unsigned cashier requests sent via insecure channels are
                                                                         untrusted; and 3) cashier responses that are relayed by users
                                                                         to merchants via HTTP redirection (status code 302) are also
        Figure 3: Algorithm for Vulnerability Detection.                 untrusted. Initially, order ID, order total, merchant ID and
                                                                         currency are all tainted.
                                                                             When a merchant correctly verifies a payment status
state have no impact on the final vulnerability results. Function        component, the taint annotation of the checked component
P ROPAGATE N ODE S TATE propagates an execution state q from a           should be removed. Our approach uses taint removal rules for
previous node (np ) to the current merchant node (n), performing         the following three cases:
a few operations on q. Specifically, this function updates runtime
constants such as $_SERVER[’PHP_SELF’], updates array                       •    Conditional checks. When an (in)equality conditional
$_GET based on the query string of node n, updates array                         check verifies an untrusted value against a trusted
$_POST based on the form elements of node np and resets the                      symbolic value of a payment status component, remove
memory map of local variables. By default, request variables                     taint from the checked payment status component.
have the symbolic top value, which represents all possible                  •    Writes to merchant database. When a tainted value
values including null. Next, merchant node n is symbolically                     is written into a merchant’s database with INSERT
executed via function S YMBOLIC E XECUTION, and Q is the end                     or UPDATE queries, conservatively remove taint from
execution state set for n. During symbolic execution, HTML                       the component. Before a merchant employee ships
form action URLs, form elements and parameter values of                          a product or provides a service for an order, she
merchant-to-cashier cURL 2 requests are monitored in search                      needs to review order details retrieved from database
of links to other merchant nodes or cashier nodes.                               tables. If a modified component is written to database,
                                                                                 the merchant employee can easily spot the modified
  To connect nodes of valid logic flows, function G ET N EXT N-
                                                                                 component and thus reject the order with the modified
ODE examines and resets four types of links: redirection URL,
                                                                                 component.
form action URL, callback URL and return URL. A redirection
URL or form action URL can point to either a cashier node                   •    Secure communication channels. For synchronous
or a merchant node, while a callback URL or return URL                           merchant-to-cashier cURL requests, remove taint for
can only point to a merchant node. To navigate only along                        order total, merchant ID or currency when such com-
valid logic flows, we discard URLs that form backward or                         ponent are included in cURL request parameters, and
                                                                                 remove taint for order ID unconditionally. Synchronous
  2 http://curl.haxx.se/                                                         requests are sent via secure communication channels,

                                                                     6
        and thus can guarantee the authenticity of payment
        status changes that pass through such channels.                                      app
                                                                                             code
    Our approach has one taint addition rule: When a
                                                                                                 PHP
conditional check for a cashier-to-merchant request relies on                    spec                        ASTi
                                                                                                Lexer                     IR
an exposed signed token, add taint to the exposed signed                                         and                  Constructor
token. We keep track of all signed token values that are                         ns, qs
                                                                                                Parser
disclosed in DOM trees to users (typically in hidden HTTP
form elements). Although hidden HTTP form elements are                                     nj, Qj                             IRi
invisible in the presentation layer of HTML pages, attackers
can obtain their values by simply viewing the source code
                                                                                                              Qi       Symbolic
of web pages. Note that not all exposed signed tokens are
                                                                                              Navigator                Execution
tainted. The taint addition rule only applies when an exposed
                                                                                                                        Engine
signed token is used as an unpredictable value in a conditional
check for a cashier-to-merchant request. Once a signed token
is exposed, it is no longer unpredictable and therefore should                             nf, Qf
not be used in a conditional check. For example, suppose we
have a signed token in a hidden HTML form with symbolic
value md5($secret.$orderId.$orderTotal). If our                                                 Logic                  Vulnerability
analysis encounters equality check $_GET[’hash’] ==                                            Analzyer                  Report
md5($secret.$_GET[’oId’].$_GET[’oTotal’]),
it adds taint to the exposed signed token. This is because
although $secret is unpredictable, the values of the three
request variables are predictable. To pass the check, an attacker                  Figure 4: Symbolic Execution Framework.
can use the exposed signed token for $_GET[’hash’],
the order ID and order total associated with the exposed
signed token for $_GET[’oId’] and $_GET[’oTotal’]                            To guide our automated analysis, we need developers
respectively.                                                            to specify application-specific variable names of payment
                                                                         status components, critical merchant pages in the checkout
                   IV.   I MPLEMENTATION                                 process, cashier URLs, callback URL, return URL, configurable
                                                                         constants defined in the database and runtime values of a
    We developed a symbolic execution framework that in-
                                                                         few variables that are used for the resolution of dynamic file
tegrates taint analysis for PHP, one of the most prevalent
                                                                         inclusion and class construction. For instance, a payment class
languages for building web applications. We extended the
                                                                         can be dynamically constructed based on a user’s choice of
PHP lexer and parser of a static string analyzer [23, 27, 32]
                                                                         payment methods. If the user chooses PayPal Standard as
written in OCaml. Our tool handles object-oriented features of
                                                                         the payment method, we can specify the value of runtime
PHP, including classes, objects and method calls. We wrote
                                                                         variable $_SESSION[’payment’] to be “paypal standard”
transfer functions for built-in PHP library functions, which
                                                                         to precisely resolve the target of class $payment.
include string functions, database functions, I/O functions, etc.
Our tool consults Satisfiability Modulo Theories (SMT) solver
                                                                         A. Symbolic Execution
Z3 [13] for branch feasibility, supporting arithmetic constraints,
simple string constraints and some other types of constraints.               For each merchant page in the checkout process of an e-
Our implementation contains a total of 25, 113 lines of OCaml            commerce application, our PHP lexer and parser transform its
code. Although our implementation targets the PHP language,              source code into an IR. We followed the PHP language reference
the high-level approach is general and applicable to e-commerce          and carefully wrote parsing rules to resolve reduce/reduce
software written in other languages.                                     conflicts, assigned operator precedence to resolve shift/reduce
                                                                         conflicts and used associativity to resolve other types of
    Figure 4 shows the architecture of our framework. Given
                                                                         conflicts. We observed that a PHP page can either statically or
the source code of an e-commerce web application and a
                                                                         dynamically include other pages via PHP include or iframe,
specification for it, our analysis starts with a single execution
                                                                         and the pages that are included can in turn include other pages.
state qs at merchant node ns , the first node in the checkout
                                                                         To fully expand a PHP page, our analyzer infers static targets
process. For each merchant node ni , our PHP lexer and parser
                                                                         of included pages when possible, and resorts to specification
transform the corresponding merchant page into an Abstract
                                                                         when targets can only be decided at run time. For example,
Syntax Tree ASTi , which is then transformed into an Internal
                                                                         static include require(DIRS_CLASSES.‘cart.php’)
Representation IRi by our IR constructor. After the symbolic
                                                                         depends on the value of constant DIRS_CLASSES, while
execution engine explores all possible control flow paths of IRi ,
                                                                         dynamic include require($language.‘.php’) depends
we have a set of end execution states Qi . Next, the navigator
                                                                         on the runtime variable $language.
searches for valid logic flows, and continues symbolic execution
for new merchant nodes until the final merchant node nf is                   For heap modeling, our tool uses five variable maps:
reached. Finally, the logic analyzer checks all the unique logic         a variable-to-symbolic-value memory map, an instance-to-
states of final execution state set Qf , and then reports any            class-name map, an alias-to-variable map, an array-parent-to-
detected logic vulnerabilities.                                          array-elements map and an object-parent-to-object-properties

                                                                     7
map. First, the variable-to-symbolic-value map allows us to             other hand, to explore all possible inter-procedural edges, our
model a heap symbolically. A symbolic value is a recursive              approach adopts a global call stack which stores snapshots of
data structure composed of the following types: literal, basic          previous function environment before function calls. A function
symbolic PHP variable, library function call, concatenation             environment snapshot includes a parameter-argument map for
of two symbolic values, arithmetic expression, comparison               the inter-procedural function call which is going to be explored,
expression and symbolic PHP resource. For instance, symbolic            the work list and end execution states of the current function,
value md5("hello".$_GET[’orderID’]) represents a                        etc.
call to library function md5 with a symbolic argument of a
                                                                            Our tool consults the SMT solver Z3 for constraint solving.
concatenation of two symbolic values: a string literal “hello”
                                                                        When a conditional is encountered during symbolic execution,
and a basic symbolic variable $orderID of type integer.
                                                                        our analyzer transforms the conditional into a formula of the
Second, given a class instance and a method name, the
                                                                        smtlib2 format, conjuncts the new formula with the current
instance-to-class-name map enables us to quickly retrieve
                                                                        path condition, and feeds the merged path condition to Z3 to
the corresponding class method definition. Third, the alias-
                                                                        get an answer. When both branches are feasible, we select one
to-variable map allows us to correctly update a symbolic heap.
                                                                        branch to explore first, and add the other branch to the current
Aliases are created when: a method is called from within
                                                                        work list. We support the following types in our constraints:
an object context ($this becomes available); a variable is
                                                                        boolean, integer, real, string, array, object, resource, null and
assigned by reference; and a function/method has pass-by-
                                                                        >. We try to infer the satisfiability of simple string constraints,
reference arguments or returns a reference. Last, the two maps
                                                                        which can contain literals, string variables, and operators
for array and object variables enable us to track the children of
                                                                        such as =, 6=, <, , > and . To symbolically represent PHP
arrays and objects respectively. Our tool uses one memory map
                                                                        library function calls, we use define-fun in Z3 for function
for global variables and one memory map for local variables.
                                                                        declarations.
    To model arrays and objects in PHP, we adopt the McCarthy
                                                                        $error = false;
rule for list manipulations [13]. Given an array a, an array            if ($_POST[’x_response_code’] == ’1’) {
element e and array index i, let a[i] represent an array select           if (tep_not_null(AUTHORIZENET_MD5_HASH) &&
and a{i       e} represent an array store with the element at               ($_POST[’x_MD5_Hash’] != strtoupper(
                                                                              md5(AUTHORIZENET_MD5_HASH .
index i set to e. By the McCarthy rule, we have the following:                AUTHORIZENET_LOGIN_ID .
                                                                              $_POST[’x_trans_id’] .
         (8 array a)(8 element e)(8 index i, j)                               $this->format_raw($order->info[’total’])
               i = j ! a{i    e}[j] = e                                     )))) {
                                                                            $error = ’verification’;
             ^ i 6= j ! a{i   e}[j] = a[j]                                } elseif ($_POST[’x_amount’] !=
                                                                              $this->format_raw($order->info[’total’])) {
                                                                            $error = ’verification’;
    Our implementation precisely retrieves and updates array              }
elements (or object properties) whenever possible. Otherwise,           } elseif ($_POST[’x_response_code’] == ’2’) {
when an index of an array variable (or the field of an object             $error = ’declined’;
                                                                        } else {
property) is >, all possible values of the array elements (or             $error = ’general’;
object properties) are merged. For example, suppose we have a           }
simple array $arr=array(1=>"x",2=>"y"). If the value
                                                                        if ($error != false) {
of array index $i is >, the value of $arr[$i] is either “x” or            tep_redirect(tep_href_link(
“y”. We also use the McCarthy rule to symbolically represent                FILENAME_CHECKOUT_PAYMENT,
arrays and objects. As an example, the symbolic representation              ’payment_error=’ . $this->code .
                                                                            ’&error=’ . $error, ’SSL’, true, false));
of $arr is:                                                             }
   array update(array update(array(), 1, “x”), 2, “y”)
                                                                                   Figure 5: Example for Path Exploration.
B. Path Exploration
     Given a start execution state, our goal is to explore all              Consider the example in Figure 5 for path exploration.
possible intra-procedural and inter-procedural edges in the             Since the default values of request variables are >,
control-flow graph (CFG) of a merchant node. We use a work-             all possible control-flow edges are explored. Only one
list-based algorithm and explore CFG edges with a depth-first           exploration path in the example leads to a valid logic
strategy. On one hand, to explore all possible control flows            flow, while the other paths redirect users to a payment
within a function/method body, a work list stores execution             node with an error message in $error. For the second
states for feasible branches that have not been explored yet.           if conditional on the valid path, there is a method call
Each execution state includes a program counter (consists of a          $this->format_raw($order->info[’total’]).
basic block number and a statement number within the basic              To follow this inter-procedural edge, our analyzer first looks
block), a logic state, path condition, memory maps of global            up the class name of object $this and then the definition
and local variables, etc. We set a configurable quota for the           of method format_raw in the corresponding class. Next,
maximum number of similar execution states in a work list               the analyzer updates aliases for pass-by-reference parameters
to avoid state explosion. When the quota for a work list is             which include $this, initializes parameter values based on
exhausted, we only add an execution state to the work list if it        the arguments of the method call, passes on the memory
has either a new program counter or a new logic state. On the           map of global variables and pushes a snapshot of the current

                                                                    8
function environment into the global call stack. At the end of                     TABLE I: Payment Modules for Cashiers.
the symbolic execution for format_raw, we have a set of
execution states Q. After the method call returns, our analyzer              Cashier                Modules      Unique     Callback
pops the function environment from the global call stack                     2Checkout                      1          1        N
and maps Q to Q0 to update method arguments that have                        Authorize.net                  2          2        N
pass-by-reference parameters. To continue path exploration                   ChronoPay                      1          1        Y
after the call, Q0 is added to the current work list. When all               inpay                          1          1        Y
possible paths are explored, merchant ID and order total are                 iPayment                       3          1        Y
untainted in the execution state of the valid flow which keeps               Luottokunta                    2          2        N
the value of $error unchanged.                                               Moneybookers                  23          1        Y
                                                                             NOCHEX                         1          1        N
C. Logic Flows                                                               PayPal                         5          5        Y
                                                                             PayPoint.net                   1          1        N
     The focus of our analysis is critical logic flows of a                  PSiGate                        1          1        N
successful checkout process. We discard backward flows, error                RBS WorldPay                   1          1        Y
flows or aborted flows since they are irrelevant to our security             Sage Pay                       3          3        Y
analysis. First, a backward flow happens when an error has                   Sofortüberweisung             1          1        Y
occurred in a merchant node n, and the user is redirected to a
previous merchant node or the same merchant node n. Second,                  Sum                           46         22        8
an error flow refers to a redirection to a special error page or a
visited page with an error message in a request variable. In the
first case, the special error page does not belong to the critical       total. If these two request parameters are written to a merchant’s
checkout process and the flow to this page is discarded. In the          database, they will be read from the database and displayed
second case, flows to pages with a symbolic error message                clearly to a merchant employee. Since she needs to review order
variable are backward flows, which are automatically discarded.          details before accepting an order, she may reject any order with
Last, an aborted flow happens when a serious error occurs and            abnormal payment status. Consequently, the taint annotations
the rendering of a merchant page is stopped with an exit                 of order ID and order total should be removed based on the
statement.                                                               specifications for $_GET[’v1’] and $_GET[’v2’].
    In search of links to other nodes, our analyzer parses
symbolic values of HTTP forms and cURL parameters. Since                                 V.   E MPIRICAL E VALUATION
string literal is not the only type that a symbolic value can
represent, we cannot simply use regular expressions such                     To evaluate the effectiveness and performance of our
as <form \s*action\s*=\s*[ˆ>]*> to extract links.                        tool, we performed experiments on osCommerce [1], one
Consequently, our parser recursively examines each component             of the most popular open-source e-commerce applications. It
of a symbolic value to correctly handle non-literals. In most            has a long history of 13 years, powering more than 14,000
cases, merchants embed URLs in HTTP requests to cashiers                 registered sites [1]. The latest stable release (version 2.3) of
and our parser can find such URLs. However, a merchant may               osCommerce contains 987 files with 38,991 lines of PHP code.
also store the configurations of callback URL and return URL             It supports various third-party cashiers and multiple currencies
on a cashier’s server. For this case, we need to specify the pre-        with different payment modules, which are integrated in the
configured merchant URLs to continue exploring logic flows               main framework as add-ons. Each payment module provides a
after a user-to-cashier request.                                         payment method that a user can choose during checkout.
    Requests from cashiers often store critical payment status               In total, We evaluated 46 payment modules, 22 of which
in their parameters. Although the names of request parameters            have distinct CFGs. There are 928 payment modules for
vary for different cashiers, it is not necessary to associate            osCommerce, and new payment modules have been actively
their names with payment status components unless their                  added since 2003. In addition, payment modules evolve over
values are written to a database. On one hand, when an                   time. For example, module Luottokunta (version 1.2) was
untrusted request parameter is compared against a trusted                reported to be vulnerable [9], and Luottokunta (version 1.3) was
payment status component, our tool can infer which pay-                  released to patch the reported vulnerability. 46 payment modules
ment status component a request parameter is associated                  are included in osCommerce by default, and 44 of them are
with, and apply taint rules for the involved payment sta-                developed to integrate third-party cashiers. The two remaining
tus component. For instance, for $_POST[’x_amount’]                      payment modules are irrelevant to our security analysis: One
==$order->info[’total’], our analyzer removes taint                      allows merchants to accept cash on delivery, and the other
from order total based on the trusted payment status compo-              enables merchants to accept mailed money orders. The 44
nent $order->info[’total’] rather than the untrusted                     payment modules that accept online payment have 20 unique
$_POST[’x_amount’]. On the other hand, when untrusted                    CFGs. Modules that differ slightly from one another in terms
request variables from cashiers are written to a database                of variable names and cashier URLs may have identical CFGs.
via INSERT or UPDATE queries, we need specifications of                  Therefore, we evaluated 20 default payment modules that have
which payment status components the request variables are                unique CFGs as well as the two Luottokunta payment modules.
associated with. For example, suppose a specification associates         All the experiments are run on a desktop PC with a quad-core
$_GET[’v1’] with order ID and $_GET[’v2’] with order                     CPU (2.40 GHz) and 4GB of RAM.

                                                                     9
                                         TABLE II: Logic Vulnerability Analysis Results.

                                                                               Tainted / Exposed
  Payment Module                                                                                                                  Safe
                                                 OrderId     OrderTotal          MerchantId       Currency     SignedToken
  2Checkout                                          7               7                 7              7                            8
  Authorize.net Credit Card AIM                                                                                                    3
  Authorize.net Credit Card SIM                      7                                                7                            8
  ChronoPay                                          7               7                 7              7               7            8
  inpay                                                                                                                            3
  iPayment (Credit Card)                             7                                                                             8
  Luottokunta (v1.2)                                 7               7                 7              7                            8
  Luottokunta (v1.3)                                 7                                                7                            8
  Moneybookers                                                                                                                     3
  NOCHEX                                             7               7                 7              7                            8
  PayPal Express                                                                                                                   3
  PayPal Pro - Direct Payments                                                                                                     3
  PayPal Pro (Payflow) - Direct Payments                                                                                           3
  PayPal Pro (Payflow) - Express Checkout                                                                                          3
  PayPal Standard                                                                      7                                           8
  PayPoint.net SECPay                                7               7                                7                            8
  PSiGate                                            7               7                 7              7                            8
  RBS WorldPay Hosted                                                                                 7               7            8
  Sage Pay Direct                                                                                                                  3
  Sage Pay Form                                                      7                                7                            8
  Sage Pay Server                                                                                                                  3
  Sofortüberweisung Direkt                                                                           7                            3⇤
  Total                                              9               7                 6              11              2          9 + 1⇤


    Table I shows payment modules from 14 different cashiers.            payment for future orders. Second, 7 modules fail to verify
Column “Modules” shows the number of payment modules                     order total, allowing attackers to pay arbitrary amounts. Third,
that a cashier has, and column “Unique” lists the number of              6 modules fail to verify merchant ID, allowing attackers to
payment modules that have unique CFGs. All the payment                   pay themselves instead. Note that the verification of secret can
modules are in their latest versions except Luottokunta, for             replace the verification of merchant ID. Fourth, 11 modules fail
which we included two versions with different CFGs. Cashier              to verify currency, making it the most neglected component of
Moneybookers provides 23 payment modules for various                     payment status. When a cashier is configured to accept only
countries and currencies, but we observed that all of them               one currency for a merchant, not verifying currency is safe
share the same CFG. Therefore, it is sufficient to pick just one         and acceptable. However, we believe that the best practice is
Moneybookers module for our security analysis. In contrast,              to always verify currency so that additional currencies can be
PayPal has 5 payment modules and each of them has a unique               easily added in the future. Last, 2 signed tokens are accidentally
CFG.                                                                     exposed in plain text, allowing attackers to pose as cashiers.
                                                                         We also tracked exposed secrets in our evaluation. When a
A. Analysis Results                                                      secret is exposed, an attacker can arbitrarily forge values for
                                                                         order ID, order total, merchant ID and currency. Fortunately,
    Table II shows the analysis results for the 22 unique payment        none of the modules makes such a mistake.
modules. Columns under “Tainted/Exposed” show the existence
of tainted components of payment status and exposed signed
tokens for each module. For these columns, a table cell marked               In summary, as shown in the last column of Table II, 9 out
with “7” means that a payment status component is tainted or             of 22 modules are safe; module Sofortüberweisung Direkt is
a signed token is exposed. The last column “Safe” summarizes             safe when only one currency is accepted; the remaining 12
the safety of a payment module. When a payment module                    modules are vulnerable. We expected the patched version of
verifies all the components of payment status and exposes no             Luottokunta (v1.3) to be safe at first but were surprised to see
signed tokens, it is considered safe and marked with “3”;                that it is still vulnerable. This shows the difficulty of writing a
otherwise, it is marked with “8”.                                        perfectly secure payment module. We manually confirmed the
                                                                         detected vulnerabilities on a local deployment of osCommerce,
    Table II shows that when a payment module is unsafe, it is           successfully performed responsible experiments on live web
often vulnerable to several types of logic attacks on different          stores powered by osCommerce and communicated with the
components of payment status. First, 9 modules fail to correctly         developers of osCommerce about the detected vulnerabilities.
verify order ID. This allows attackers to pay once for an order,         We classified the detected logic vulnerabilities into the following
and reuse the payment status values of the paid order to bypass          categories.

                                                                    10
    1) Untrusted Request Variables: Payment module develop-              are two methods to fix the problem. The first one is to use
ers sometimes make the mistake of checking payment status                just one secret but two ways of calculation to make the signed
based on untrusted request variables. Verifying untrusted request        tokens different. For example, by simply changing the orders
variables guarantees neither the integrity nor the authenticity          of the components of payment status in a calculation, we can
of payment status, but may give developers a false sense of              generate different signed tokens with the same secret. A better
security. Four modules, namely, Authorize.net Credit Card AIM,           method is to use two secrets to avoid exposing important signed
iPayment (Credit Card), Luottokunta (v1.3) and PayPoint.net              tokens. We can use one secret to authenticate a merchant and
SECPay fall into this category. The values of untrusted request          the other to authenticate a cashier using the same calculation,
variables that pass such insufficient checks may be inconsistent         without worrying about the security of signed tokens.
with actual payment status components. For example, module
                                                                             3) Incomplete Payment Verification: Payment modules
iPayment (Credit Card) performs a check on order ID based on
                                                                         sometimes only partially verify the components of payment
untrusted request variable $_GET[’ret_booknr’] in the
                                                                         status. In other words, checks of some components of payment
following code.
                                                                         status are missing rather than insufficient. Three modules,
$_GET[’ret_param_checksum’] !=                                           namely, Sage Pay Form, Sofortüberweisung Direkt and PayPal
md5(MODULE_PAYMENT_IPAYMENT_CC_USER_ID                                   Standard belong to this category. Module Sage Pay Form
  . ($this->format_raw($order->info[’total’])                            writes partial payment status into the database, but misses
  * 100) . $currency                                                     checks on order total and currency. Module Sofortüberweisung
  . $_GET[’ret_authcode’] . $_GET[’ret_booknr’]
  . IPAYMENT_CC_SECRET_HASH_PASSWORD)                                    Direkt does not verify currency and therefore is vulnerable to
                                                                         currency tampering attacks if cashiers are configured to support
    An attacker could pay once for an order and intercept the            multiple currencies. Module PayPal Standard misses the check
cashier-to-merchant request of the paid order by modifying the           on merchant ID, allowing an attacker to pay herself instead.
return URL of the preceding merchant-to-cashier request. For
                                                                             4) Missing Payment Verification: Some payment modules
the above example, the attacker needs to record the values of
                                                                         are not designed to defend against logic attacks and have
$_GET[’ret_param_checksum’], $_GET[’ret_authcode’]
                                                                         no security checks of payment status at all. They could
and $_GET[’ret_booknr’]. For future orders, the attacker
                                                                         easily become the playground for attackers. The following
can purchase different products and bypass payments as long
                                                                         five payment modules unfortunately fall into this category:
as the order total and currency are the same as the paid
                                                                         ChronoPay, Luottokunta (v1.2), NOCHEX, 2Checkout and
order. Note that $_GET[’ret_param_checksum’] is supposed
                                                                         PSiGate. Such payment modules should be patched as soon as
to be an unpredictable and unique value signed with secret
                                                                         possible.
IPAYMENT_CC_SECRET_HASH_PASSWORD. However, simply re-
playing the intercepted values of the three GET variables
would allow the attacker to pass the above payment status                B. Experiments on Live Websites
check. The check in the example is insufficient because the                  To show the feasibility and ease of attacks based on the
value of order ID in the conditional comes from untrusted                detected logic vulnerabilities listed in Table II, we conducted
$_GET[’ret_booknr’].                                                     experiments on three live websites in a responsible manner. We
    2) Exposed Signed Tokens: An exposed signed token                    consulted lawyers at our university and followed the example of
nullifies the verification of payment status. Two modules                Wang et al. in setting up attacker anonymity, purchasing a VISA
ChronoPay and RBS WorldPay Hosted expose their signed                    gift card at a supermarket with cash, and registering accounts
tokens. Verification based on exposed signed tokens fails to             on third-party cashiers [30]. The Google Chrome browser with
ensure the authenticity of payment status. An attacker could             no browser extensions suffices as our attack tool. Although
record the values of signed tokens hidden in HTML forms and              we initially paid nothing or less to the merchants for the three
forge a request to fake a completed payment. The following               orders we placed, we paid in full amounts to the merchants
exposed signed token from the form element M_hash, for                   after we received the products shown in Figure 2. We reported
example, nullifies the verification on order ID, order total and         the results of our experiments to osCommerce developers. The
merchant ID (secret RBSWORLDPAY_HOSTED_MD5_PASSWORD                      details of the experiments are elaborated in the following.
can also uniquely identify a merchant).                                      The Ubuntu online shop by Canonical Ltd. (RBS World-
                                                                         Pay Hosted). RBS WorldPay is a cashier mainly used in
tep_draw_hidden_field(’M_hash’,
  md5(tep_session_id() . $customer_id                                    the U.K. and supports multiple currencies. The Ubuntu online
    . $order_id . $language                                              shop is a featured osCommerce shop, and it uses the vulnerable
    . number_format($order->info[’total’], 2)                            module RBS WorldPay Hosted. As Table II shows, this payment
    . RBSWORLDPAY_HOSTED_MD5_PASSWORD));
                                                                         module is vulnerable to currency attacks. We placed an order
                                                                         in U.K. pounds but paid cashier WorldPay in U.S. dollars of
    Fundamentally, exposed signed tokens are caused by using
                                                                         the same amount. About one week later, we received a Ubuntu
the same secret for both merchant signature and cashier
                                                                         notebook (shown in Figure 2) even though we did not pay the
signature. We observed that a signed token is often exposed
                                                                         full amount at first.
when a merchant wishes to use it to authenticate herself to a
cashier. A signed token can work both as a merchant signature                A baby products online shop (Authorize.net Credit Card
and a cashier signature for non-cURL HTTP requests. When a               SIM). Module Authorize.net Credit Card SIM is vulnerable
signed token is used for both purposes, it is considered exposed         to order ID attacks. In our experiments on the baby products
if attackers can intercept cashier-to-merchant requests. There           online shop, we placed two orders of the same order total but

                                                                    11
                                                 TABLE III: Performance Results.

 Payment Module                              Files       Nodes (%)             Edges (%)         Stmts (%)     States   Flows    Time (s)
 2Checkout                                     105   5,194 (19.09%)        6,176 (19.15%)    8,385 (25.01%)       40         4      16.04
 Authorize.net Credit Card AIM                 105   5,274 (19.95%)        6,284 (19.96%)    8,545 (25.97%)       43         4      17.65
 Authorize.net Credit Card SIM                 105   5,221 (19.66%)        6,221 (19.72%)    8,435 (25.52%)       46         4      16.89
 ChronoPay                                      99   5,013 (15.67%)        5,969 (15.61%)    8,084 (20.75%)       69         5      31.51
 inpay                                         100   5,118 (18.31%)        6,109 (18.42%)    8,408 (23.68%)      335         6     125.29
 iPayment (Credit Card)                         99   4,999 (16.09%)        5,932 (16.14%)    7,918 (21.62%)       38         5      21.86
 Luottokunta (v1.2)                            105   5,158 (18.94%)        6,127 (18.96%)    8,291 (24.72%)       34         4      15.33
 Luottokunta (v1.3)                            105   5,164 (18.99%)        6,135 (19.03%)    8,308 (24.80%)       35         4      15.33
 Moneybookers                                   99   5,082 (15.90%)        6,059 (15.85%)    8,215 (21.08%)       66         4      80.85
 NOCHEX                                        105   5,145 (18.90%)        6,111 (18.89%)    8,237 (24.67%)       33         4      15.03
 PayPal Express                                104   5,351 (12.63%)        6,379 (12.64%)    8,596 (17.95%)       62        11      42.15
 PayPal Pro - Direct Payments                  105   5,302 (19.85%)        6,339 (19.77%)    8,700 (25.61%)       65         4      20.76
 PayPal Pro (Payflow) - Direct Payments        105   5,302 (19.92%)        6,339 (19.85%)    8,714 (25.71%)       63         4      20.85
 PayPal Pro (Payflow) - Express Checkout        99   5,128 (14.41%)        6,107 (14.35%)    8,197 (20.08%)       31        10      31.95
 PayPal Standard                                99   5,040 (16.03%)        6,006 (16.01%)    8,170 (21.04%)       68         6      33.01
 PayPoint.net SECPay                           105   5,174 (19.09%)        6,152 (19.10%)    8,332 (24.97%)       40         4      15.80
 PSiGate                                       106   5,231 (19.07%)        6,228 (19.04%)    8,436 (24.95%)       44         4      16.82
 RBS WorldPay Hosted                            99   5,019 (15.84%)        5,977 (15.92%)    8,121 (21.09%)       79         5      36.12
 Sage Pay Direct                               106   5,447 (20.71%)        6,515 (20.55%)    8,984 (25.97%)       95         4      26.20
 Sage Pay Form                                 106   5,315 (19.52%)        6,329 (19.54%)    8,762 (24.55%)       55         4      19.96
 Sage Pay Server                               101   5,100 (14.72%)        6,067 (14.62%)    8,268 (19.78%)       42         6      28.26
 Sofortüberweisung Direkt                      98   5,038 (16.01%)        6,003 (15.96%)    8,160 (21.20%)       97         5      43.86
 Average                                    102.73   5,173 (17.70%)        6,162 (17.69%)    8,376 (23.21%)     67.27     5.05      31.43


only paid for the first order. We set up a simple web page               checkout; and column “Time (s)” shows the total analysis time
on our server to record the values of HTTP request variables.            in seconds for each payment module.
For the first order, we changed the value of return URL from
the merchant URL to that of our web page. This change lets                   Merchant nodes are nontrivial to analyze. The number of
cashier Authorize.net send the payment notification request to           files that each merchant node includes ranges from 98 to 106,
us instead of the merchant. We replayed the recorded values              with an average of 102.73. An IR has 5,173 basic blocks (nodes),
of the request variables from the first order for the cashier-to-        6,162 control flow edges and 8,376 statements on average.
merchant request of the second order. We paid nothing for the            The coverage of nodes, edges and statements is calculated
second order at first but received a dirty diaper game package           for the main function, function bodies and method bodies.
shipped from California.                                                 Some defined functions, defined class methods and even some
                                                                         branches of the main function may not be executed at all in
    A chocolate online shop (PayPal Standard). Module                    the checkout process. On average, the symbolic execution of
PayPal Standard is vulnerable to merchant ID attacks. PayPal             each merchant node has a CFG node coverage of 17.70%, an
is one of the most popular cashiers in the U.S., yet it is not           edge coverage of 17.69% and a statement coverage of 23.21%.
used securely in this payment module. In our experiment on
the chocolate online shop, we simply changed the merchant                    To estimate the efforts of manual code review, we have also
ID from the chocolate merchant’s PayPal account to our own               counted the lines of code that are related to the checkout process
PayPal account for the user-to-cashier payment request. In               for payment modules. In general, the number of lines of code is
this way, we received three pieces of chocolate although the             slightly higher than the number of statements listed in Table III
payment was not made to the chocolate merchant at first.                 for each payment module. For example, for module PayPal
                                                                         Express, there are 8,727 lines of code in total to review while its
C. Performance Evaluation                                                IR has 8,596 statements. In addition to code, manual reviewers
                                                                         need to examine database tables and cashiers’ documentation.
    Table III shows some data that we collected during symbolic
execution to demonstrate the performance of our tool. Column                 On average, it takes 31.43 seconds to explore 67.72
“Files” to column “States” show average numbers for all                  execution states in 5.05 logic flows for each payment module.
merchant nodes, while columns “Flows” and “Time (s)” show                In simple cases, it takes only 4 logic flows to initiate the
total numbers of merchant nodes. For the IR of each merchant             checkout process, make a payment on a cashier’s server, notify
node, we report the number of parsed files (column “Files”),             the merchant of the payment and complete the order. Module
the number of nodes and node coverage (column “Nodes (%)”),              PayPal Express has the most complex logic flows. It uses 11
the number of edges and edge coverage (column “Edges (%)”)               logic flows to obtain a ppe_token for each payment transaction,
and the number of statements and statement coverage (column              start an express checkout with function setExpressCheckout,
“Stmts (%)”). Additionally, column “States” shows the total              make a payment on a PayPal server, get payer details with
number of end execution states; column “Flows” shows the total           function getExpressCheckoutDetails and complete the sale
number of logic flows among user, cashier and merchant during            with function doExpressCheckoutPayment. Module inpay has

                                                                    12
                                                   TABLE IV: Coverage Results.

                                                                     Main
 Payment Module                                                                                      Func Stmts (%)      Class Stmts (%)
                                                Nodes (%)       Edges (%)              Stmts (%)
 2Checkout                                   498 (39.60%)     693 (28.86%)        1,246 (58.89%)       2,249 (17.65%)      4,891 (19.76%)
 Authorize.net Credit Card AIM               498 (40.20%)     693 (29.37%)        1,246 (59.94%)       2,249 (19.65%)      5,051 (20.40%)
 Authorize.net Credit Card SIM               498 (39.60%)     693 (28.86%)        1,246 (58.89%)       2,249 (18.45%)      4,941 (20.32%)
 ChronoPay                                   463 (36.04%)     647 (26.24%)        1,130 (54.34%)       2,249 (14.64%)      4,705 (15.61%)
 inpay                                       510 (39.70%)     709 (30.22%)        1,218 (56.17%)       2,276 (17.27%)      4,915 (18.60%)
 iPayment (Credit Card)                      454 (38.25%)     632 (27.90%)        1,116 (59.10%)       2,249 (16.10%)      4,554 (15.15%)
 Luottokunta (v1.2)                          498 (39.60%)     693 (28.86%)        1,246 (58.89%)       2,249 (17.30%)      4,797 (19.32%)
 Luottokunta (v1.3)                          498 (39.60%)     693 (28.86%)        1,246 (58.89%)       2,249 (17.34%)      4,814 (19.46%)
 Moneybookers                                471 (36.12%)     656 (26.63%)        1,139 (54.32%)       2,249 (14.52%)      4,828 (16.29%)
 NOCHEX                                      498 (39.60%)     693 (28.86%)        1,246 (58.89%)       2,249 (17.30%)      4,743 (19.19%)
 PayPal Express                              575 (28.91%)     797 (21.32%)        1,324 (44.76%)       2,249 (11.75%)      5,024 (13.66%)
 PayPal Pro - Direct Payments                498 (40.20%)     693 (29.37%)        1,246 (59.94%)       2,249 (19.88%)      5,206 (19.87%)
 PayPal Pro (Payflow) - Direct Payments      498 (40.20%)     693 (29.37%)        1,246 (59.94%)       2,249 (19.81%)      5,220 (20.09%)
 PayPal Pro (Payflow) - Express Checkout     508 (34.70%)     706 (25.71%)        1,201 (52.96%)       2,249 (13.12%)      4,747 (15.07%)
 PayPal Standard                             477 (36.76%)     665 (27.08%)        1,151 (54.88%)       2,249 (15.09%)      4,770 (15.69%)
 PayPoint.net SECPay                         498 (39.60%)     693 (28.86%)        1,246 (58.89%)       2,249 (17.67%)      4,838 (19.64%)
 PSiGate                                     498 (40.20%)     693 (29.37%)        1,246 (59.98%)       2,249 (17.74%)      4,942 (19.39%)
 RBS WorldPay Hosted                         461 (36.63%)     643 (27.02%)        1,132 (55.35%)       2,249 (14.97%)      4,740 (15.81%)
 Sage Pay Direct                             498 (40.20%)     693 (29.37%)        1,246 (59.94%)       2,249 (20.08%)      5,490 (20.67%)
 Sage Pay Form                               498 (39.70%)     693 (29.00%)        1,246 (58.97%)       2,251 (17.55%)      5,266 (19.41%)
 Sage Pay Server                             463 (36.07%)     645 (26.28%)        1,151 (55.42%)       2,249 (13.45%)      4,868 (14.27%)
 Sofortüberweisung Direkt                   470 (36.69%)     653 (26.94%)        1,136 (55.28%)       2,249 (15.41%)      4,776 (15.82%)
 Average                                     492 (38.10%)     685 (27.92%)        1,211 (57.03%)       2,250 (16.67%)      4,915 (17.89%)


the longest analysis time (125.29 seconds) and also the largest                Table IV shows detailed coverage results. All the numbers in
number of execution states (335 states). The performance                  this table are average numbers of all merchant nodes. Columns
results show that our automated detection is more efficient               under “Main” show the average numbers and coverage results
and comprehensive than manual analysis. When we manually                  (listed in parentheses) for the nodes, edges, and statements
confirmed the detected logic vulnerabilities, we need around              of the main functions in analyzed merchant nodes. Columns
30 minutes for each payment module. We spent about 15                     “Func Stmts (%)” and “Class Stmts (%)” show the average
minutes to read control flows of merchant pages and cashier               numbers and coverage results (listed in parentheses) for defined
documentation, and another 15 minutes to find valid inputs that           functions and classes of analyzed merchant nodes respectively.
lead to logic attacks.
                                                                              On average, our symbolic execution covers 38.10% of 492
                                                                          main-function nodes, 27.92% of 685 main-function edges and
    We have adopted a few optimizations to speed up our                   57.03% of 1,211 main-function statements. Additionally, it
analysis and two of them significantly reduced the analysis               covers 16.67% of 2,250 statements in defined function bodies
time. The first optimization sets the maximum number of similar           and 17.89% of 4,915 statements in defined classes. Main
execution states in a work list to one. This means that whenever          function is the entry of each merchant node, and the average
the analysis stores a new execution state in a work list, it first        coverage for the statements of main functions is much higher
checks if there already exists an execution state with the same           than the coverage for defined functions and classes. It is obvious
program counter and logic state. If yes, the new execution                in Table IV that the deviation of class statement coverage is
state is discarded. Since such two execution states often differ          the highest. This is because different payment modules are
only slightly, discarding the second state has no impact on               integrated into the checkout process as plug-ins with dynamic
the vulnerability analysis result. The analysis time for each             class construction, and they have little influence on the statement
payment module is limited to 10 minutes. When we increased                numbers of the main functions and defined functions.
the length of a work list to two, timeout events occurred before
the analyses were completed. The second optimization sets                     Our symbolic execution is developed for security analysis
some symbolic session variables to be not null, just like what            rather than achieving high coverage. The average coverage of
they should be in a normal checkout process. For example,                 all three types of statements (23.21% as shown in Table III) is
$_SESSION[’customer_id’] and $_SESSION[’cartId’] are                      lower than the coverage of main-function statements (57.03%),
specified as not null. The first few basic blocks in the IR of a          but higher than the coverage of defined function statements
merchant node often check whether some session variables are              (16.67%) and the coverage of class statements (17.89%).
null. The second optimization rules out irrelevant branches at            There are three reasons for the low coverage. First, not all
an early state of a symbolic execution process. This accelerates          statements in defined functions and class methods are used
our analysis considering that the number of states usually grows          in each merchant node. One merchant node may only need
at an exponential rate.                                                   a few functionalities provided by defined functions and class

                                                                     13
methods. Second, our tool explores control flows of CFGs                    (928 for osCommerce) and the two vulnerable Luottokunta
based on branch feasibility. Note that one merchant page is                 modules illustrate the difficulty of detecting missing/insufficient
often divided into multiple merchant nodes based on different               checks. However, for basic e-commerce software with only a
request parameter values. Our exploration is based on merchant              few payment modules, manual code review may be a viable
nodes, but the coverage is calculated using merchant pages. This            alternative.
explains why some modules have low coverage. The callback
page of PayPal Express for example, has a switch statement                      It is possible that there exist multiple execution states with
based on the value of request variable $_GET[’osC_Action’]                  unique logic states when we reach the final merchant node
near the beginning of the page. It has different branches to                during checkout. There is no universal criterion as to which
handle “cancel”, “callbackSet”, “retrieve” and default actions.             logic state should be picked over another for valid logic flows,
For a merchant node of this page, only one switch branch is                 and we leave the selection of logic states to developers who have
taken. Third, our specifications of some user inputs help us                the best judgment. Our current tool includes all taint operations
avoid the exploration of a few irrelevant control flows. Not all            and flows in logic states as a reference, and uses heuristics based
possible combinations of user inputs need to be examined for                on our observations to rank logic states. The logic state that
vulnerability detection, therefore our analysis focuses on user             should be picked is often the one that has the least number of
inputs that are related to the checkout process.                            taint annotations, excluding exposed signed tokens. The reason
                                                                            is that our symbolic execution may conservatively explore a
                                                                            branch that will not be taken in practice, and only the opposite
D. Discussions                                                              branch contains checks on payment status.
    The implementation of our detection tool is neither sound
nor complete. For all the logic vulnerabilities detected by our                                  VI.   R ELATED W ORK
tool, we carefully examined and tested each one to confirm that
they are true positives. There is no observed false positives to the            Logic vulnerabilities in e-commerce applications. The
best of our knowledge. We cannot guarantee the absence of logic             uniqueness of logic vulnerabilities, together with their great
vulnerabilities because of the difficulty of exploring all possible         impact, has attracted the attention of researchers in recent years.
logic flows in large real-world e-commerce applications. We                 Wang et al. [30] are the first to analyze logic vulnerabilities in
hope our tool can help developers write secure payment modules              Cashier-as-a-Service based web stores. Through manual security
and raise their security awareness.                                         analysis, they found serious logic flaws that can lead to inconsis-
                                                                            tent payment status between a merchant’s server and a cashier’s
    Our static analysis still faces nontrivial challenges which             server. Their follow-up work, InteGuard [33], offers dynamic
include dynamic features of PHP, constraint solving and regular             protection of third-party web service integrations, including the
expressions. Typically, static analyses are limited in handling             integration of cashier service in merchants’ websites. In contrast
dynamic language features (e.g. dynamic includes, dynamic                   to their work, we seek to comprehensively examine various
class, array and object construction), and the dynamic features             attack vectors on payment status and automatically detect
of PHP also most significantly influence the scalability and                logic vulnerabilities before the deployments of e-commerce
precision of our analysis. For a precise resolution of dynamic              applications. We discovered a new attack vector on currency
features, specifications are incorporated for some critical code.           which allows an attacker to modify the currency of a payment to
                                                                            her advantage, and designed a symbolic execution framework to
    Our current implementation does not support JavaScript                  systematically explore critical logic flows of checkout processes.
analysis yet. It is possible that some links to merchant nodes
or cashier nodes are generated by JavaScript code on the                        Parameter pollution vulnerabilities in web applications.
client side. We did not encounter any JavaScript links in our               Another active line of research is HTTP Parameter Pollution
experiments but our test subject may not be representative of               (HPP) in web applications. It is a common attack vector
other e-commerce applications. Detecting links in JavaScript                for various vulnerabilities which include logic vulnerabilities.
code is a difficult task because of the various dynamic features            WAPTEC [5] takes a white-box approach that combines
of the JavaScript language. For example, its eval function,                 symbolic execution and dynamic analysis to detect parameter
which executes statements provided as strings at run time,                  tampering vulnerabilities in PHP applications, while NoTam-
can be invoked in many different ways. For e-commerce                       per [4] and PAPAS [2] adopt black-box based approaches.
applications that heavily use JavaScript, we may need to                    NoTamper [4] detects insufficient server-side validations where
incorporate JavaScript analysis to detect critical URLs that                a server fails to replicate the validations on the client side.
are dynamically generated.                                                  PAPAS [2] aims at automated discovery of parameter pollution
                                                                            based on a black-box scanning technique for vulnerable
    Automated analysis incurs significant engineering efforts               parameters. Our approach also makes the assumption that user
and the amortized development cost can be kept low for e-                   inputs are untrusted. However, in contrast to parameter pollution
commerce software with a large number of payment modules.                   detection which examines parameters in isolation, our approach
Symbolic execution allows systematic exploration and is                     detects logic vulnerabilities in e-commerce applications by
particularly useful to model HTTP requests/responses from                   linking and analyzing the logic flows of a checkout process.
cashiers and users as symbolic values can be used (rather
than concrete values). In contrast, manual code review is error-                Other logic vulnerabilities in web applications. Besides
prone, and it is difficult to cover all possible attack vectors and         attacks on e-commerce applications, logic vulnerabilities also
important control-flows (which may explain why many serious                 open doors to other attacks which include access control
vulnerabilities still exist). The number of payment modules                 attacks, single sign-on attacks and workflow violations in

                                                                       14
web applications. First, access control vulnerability exposes                one known vulnerability. For future work, we plan to support
privileged functionality or resources to unauthenticated users.              additional path exploration strategies for our symbolic execution,
Nemesis [12] performs dynamic information flow tracking                      add function summaries to improve performance and apply
based on specified access control lists, while static approaches             our analysis to a larger number of popular e-commerce web
analyze source code to detect unprotected accesses [14, 26, 27].             applications.
Second, Wang et al. discovered new single sign-on attacks [31],
and InteGuard moves a step forward [33] by using a proxy-                                        ACKNOWLEDGEMENTS
based approach which checks a set of inferred invariants to
let merchants safely integrate third-party web services. Third,                  We thank the anonymous reviewers and our shepherd,
to detect deviations of normal workflows, it is important to                 Davide Balzarotti, for useful feedback on earlier versions
first establish a good guideline of correct workflows. Such a                of this paper. We also gratefully acknowledge Ellen Auriti,
guideline can be specified by developers [19], inferred from                 Michael Sweeney, and Lynette Temple with the University
client-side validations which should be replicated on the server             of California for advice on our proof-of-concept experiments.
side [4, 17], or obtained from dynamic analyses [3, 11, 15, 22].             This research was supported in part by NSF Grants 0917392,
An alternative way of thwarting logic attacks is secure-by-                  1117603, 1319187, and 1349528. The information presented
construction. Both Swift [8] and Ripley [29] aim to offload some             here does not necessarily reflect the position or the policy of
computations to the client side while ensuring the consistency               the Government and no official endorsement should be inferred.
of logic states between servers and clients for modern web
applications. Logic vulnerabilities in e-commerce applications                                        R EFERENCES
are one important subtype of general logic vulnerabilities in
web applications. Focusing on this particular domain, we are                  [1] osCommerce Online Merchant. http://www.oscommerce.
able to design an invariant of secure payments to detect logic                    com/.
vulnerabilities which are application-specific.
                                                                              [2] M. Balduzzi, C. T. Gimenez, D. Balzarotti, and E. Kirda.
    Symbolic execution and taint analysis. Symbolic ex-                           Automated discovery of parameter pollution vulnerabilities
ecution and taint analysis are two widely used techniques                         in web applications. In Proceedings of Network and
in security research. Schwartz et al. [25] provide a high-level                   Distributed System Security, 2011.
view of dynamic taint analysis and forward symbolic execution.                [3] D. Balzarotti, M. Cova, V. V. Felmetsger, and G. Vigna.
Symbolic execution is a powerful technique that can be adopted                    Multi-module vulnerability analysis of web-based applica-
for a diverse set of languages and problem settings ever since                    tions. In Proceedings of Computer and Communications
the seminal work by King [21]. For traditional programs,                          Security, 2007.
KLEE [6] is capable of automatically generating tests that
achieve high coverage on even complex programs. For server-                   [4] P. Bisht, T. Hinrichs, N. Skrupsky, R. Bobrowicz, and
side languages, Halfond et al. [18] apply symbolic execution to                   V. N. Venkatakrishnan. NoTamper: Automatic blackbox
precisely identify interfaces in the Java Enterprise Edition (JEE)                detection of parameter tampering opportunities in web
framework, while Rubyx [7] detects security vulnerabilities                       applications. In Proceedings of Computer and Communi-
based on specifications by symbolically executing Ruby-on-                        cations Security, 2010.
Rails web applications. For JavaScript, a client-side language
                                                                              [5] Bisht, Prithvi and Hinrichs, Timothy and Skrupsky,
widely used in web applications, Saxena et al. [24] designed
                                                                                  Nazari and Venkatakrishnan, V. N. WAPTEC: Whitebox
and implemented a symbolic execution framework which can
                                                                                  analysis of web applications for parameter tampering
handle string constraints. Pixy [20] is a static taint analyzer built
                                                                                  exploit construction. In Proceedings of Computer and
for PHP applications, and it detects injection vulnerabilities
                                                                                  Communications Security, 2011.
with taint analysis based on specifications of taint sources and
sinks. Our approach combines symbolic execution with taint                    [6] C. Cadar, D. Dunbar, and D. Engler. KLEE: Unassisted
analysis in a novel way to detect potential logic attacks on                      and automatic generation of high-coverage tests for
payment status.                                                                   complex systems programs. In Proceedings of Operating
                                                                                  Systems Design and Implementation, 2008.
                      VII.    C ONCLUSION                                     [7] A. Chaudhuri and J. S. Foster. Symbolic security analysis
                                                                                  of ruby-on-rails web applications. In Proceedings of
    Merchants should carefully verify each critical component                     Computer and Communications Security, 2010.
of payment status to ensure the consistency of payment status
between merchants’ severs and cashiers’ servers. This paper                   [8] S. Chong, J. Liu, A. C. Myers, X. Qi, K. Vikram, L. Zheng,
proposes the first static approach to automatically detect                        and X. Zheng. Secure web applications via automatic
logic vulnerabilities in e-commerce web applications. Our key                     partitioning. In Proceedings of Symposium on Operating
observation is that secure checks on payment status must verify                   Systems Principles, 2007.
the integrity and authenticity of order ID, order total, merchant
                                                                              [9] Common Vulnerabilities and Exposures. CVE-2009-
ID and currency. Our framework integrates symbolic execution
                                                                                  2039. http://cve.mitre.org/cgi-bin/cvename.cgi?name=
with taint analysis to track critical logic states, which include
                                                                                  CVE-2009-2039, 2009.
payment status, across checkout nodes. Our tool explored
important logic flows, scaled to 22 unique real-world payment                [10] Common Weakness Enumeration. CWE-840 business
modules and detected 11 unknown vulnerabilities along with                        logic errors. http://cwe.mitre.org/data/definitions/840.html.

                                                                        15
[11] M. Cova, D. Balzarotti, V. Felmetsger, and G. Vigna.               [23] Y. Minamide. Static approximation of dynamically
     Swaddler: An approach for the anomaly-based detection                   generated web pages. In Proceedings of World Wide
     of state violations in web applications. In Proceedings of              Web, 2005.
     Recent Advances in Intrusion Detection, 2007.
                                                                        [24] P. Saxena, D. Akhawe, S. Hanna, F. Mao, S. McCamant,
[12] M. Dalton, C. Kozyrakis, and N. Zeldovich. Nemesis:                     and D. Song. A symbolic execution framework for
     Preventing authentication and access control vulnerabili-               JavaScript. In Proceedings of Symposium on Security
     ties in web applications. In Proceedings of the USENIX                  and Privacy, 2010.
     Security Symposium, 2009.
                                                                        [25] E. J. Schwartz, T. Avgerinos, and D. Brumley. All you
[13] L. De Moura and N. Bjørner. Z3: An efficient SMT                        ever wanted to know about dynamic taint analysis and
     solver. In Proceedings of Tools and Algorithms for the                  forward symbolic execution (but might have been afraid
     Construction and Analysis of Systems, 2008.                             to ask). In Proceedings of Symposium on Security and
                                                                             Privacy, 2010.
[14] A. Doupé, B. Boe, C. Kruegel, and G. Vigna. Fear
     the EAR: Discovering and mitigating execution after                [26] S. Son, K. S. McKinley, and V. Shmatikov. Fix Me Up:
     redirect vulnerabilities. In Proceedings of Computer and                Repairing access-control bugs in web applications. In
     Communications Security, 2011.                                          Proceedings of Network and Distributed System Security,
                                                                             2013.
[15] V. Felmetsger, L. Cavedon, C. Kruegel, and G. Vigna.
     Toward automated detection of logic vulnerabilities in             [27] F. Sun, L. Xu, and Z. Su. Static detection of access control
     web applications. In Proceedings of the USENIX Security                 vulnerabilities in web applications. In Proceedings of the
     Symposium, 2010.                                                        USENIX Security Symposium, 2011.
[16] J. Grossman. Seven business logic flaws that put your              [28] U.S. Census Bureau. Quarterly retail e-commerce
     website at risk. http://www.whitehatsec.com/home/assets/                sales. http://www.census.gov/retail/mrts/www/data/pdf/
     WP bizlogic092407.pdf, 2007.                                            ec current.pdf, 2013.
[17] A. Guha, S. Krishnamurthi, and T. Jim. Using static                [29] K. Vikram, A. Prateek, and B. Livshits. Ripley: Automat-
     analysis for Ajax intrusion detection. In Proceedings of                ically securing Web 2.0 applications through replicated
     World Wide Web, 2009.                                                   execution. In Proceedings of Computer and Communica-
                                                                             tions Security, 2009.
[18] W. G. Halfond, S. Anand, and A. Orso. Precise interface
     identification to improve testing and analysis of web              [30] R. Wang, S. Chen, X. Wang, and S. Qadeer. How to
     applications. In Proceedings of International Symposium                 shop for free online – security analysis of Cashier-as-a-
     on Software Testing and Analysis, 2009.                                 Service based web stores. In Proceedings of Symposium
                                                                             on Security and Privacy, 2011.
[19] S. Hallé, T. Ettema, C. Bunch, and T. Bultan. Eliminating
     navigation errors in web applications via model checking           [31] R. Wang, S. Chen, and X. Wang. Signing me onto your
     and runtime enforcement of navigation state machines. In                accounts through Facebook and Google: A traffic-guided
     Proceedings of Automated Software Engineering, 2010.                    security study of commercially deployed Single-Sign-On
                                                                             web services. In Proceedings of Symposium on Security
[20] N. Jovanovic, C. Kruegel, and E. Kirda. Pixy: A static                  and Privacy, 2012.
     analysis tool for detecting web application vulnerabilities
     (short paper). In Proceedings of Symposium on Security             [32] G. Wassermann and Z. Su. Sound and precise analysis
     and Privacy, 2006.                                                      of web applications for injection vulnerabilities. In
                                                                             Proceedings of Programming Language Design and
[21] J. C. King. Symbolic execution and program testing. In                  Implementation, 2007.
     Communications of ACM, 1976.
                                                                        [33] L. Xing, Y. Chen, X. Wang, and S. Chen. InteGuard:
[22] X. Li and Y. Xue. BLOCK: A black-box approach                           Toward automatic protection of third-party web service
     for detection of state violation attacks towards web                    integrations. In Proceedings of Network and Distributed
     applications. In Proceedings of Annual Computer Security                System Security, 2013.
     Applications Conference, 2011.




                                                                   16
