text
stringlengths
0
1.99k
electronic purses with up to $50 and the vending machine supplier installed
and serviced vending machines retrofitted with smart card modules all over
campus. Somehow, they periodically settled accounts.
As with most projects like this, it probably never made or even saved
anybody any money and the chip card based MCard is now a faded memory. But
at the time, smart card reader-equipped vending machines were all over
campus, even in off-campus offices like CITI, where we had a snack machine
and a pop machine in our lunchroom.
This was an obvious target and a temptation. It didn't take us long to
begin tracing the communication between the MCard and the vending machine.
Guess what we found. >:)
--[ 4 - The MCard electronic purse protocol
A smart card spends most of its life in a lonely powered-down state,
crushed in a wallet or buried in a purse, but when inserted into a reader,
the card springs to life, resets itself into a predetermined state, and
awaits commands.
Smart card communication obeys a suite of standards, known as ISO 7816,
that govern physical aspects of the card, such as shape and size, location
of the contacts, the serial data interface, and describe an RPC-like
protocol that allows the exchange of structured command/response pairs and
challenge/response authenticators. The card stores long-term keys and other
data in a hierarchical file system with idiosyncratic access controls.
We can imagine a bare-bones electronic purse protocol in which
1 the vending machine checks that the purse has sufficient funds, then
2 the cardholder makes and receives a selection, then
3 the vending machine updates the purse.
This protocol is vulnerable to a simple attack, called tearing, in which
the cardholder forcibly removes the card after step 2 (deliver the
selection) but before step 3 (update the purse), and indeed, this protocol
is not what we found when we traced the messages exchanged between a
vending machine and an MCard. Instead, we found a two-phase protocol that
resists tearing by reserving funds prior to product selection and debiting
the funds and committing the transaction after product selection.
Message to MCard MCard response
Wake up! I'm awake
How much $$$ in the purse? $18.23
Show me the last entry in the log $18.23
Give me a nonce Here is a nonce
Send nonce encrypted with shared key Vending machine is authentic
Reserve $1.25 in the log OK
Table: Pre-selection phase of the MCard electronic purse transaction.
The vending machine has reserved $1.25 on the MCard and awaits consumer
product selection. Already, a flaw in the electronic purse protocol is
evident. The card does not trust the vending machine and requires it to
authenticate before writing to the log, but the vending machine never
authenticates the card. This suggests an obvious replay attack.
To be clear, if we can program a computer to utter the MCard responses
shown above, we can use an inverse card reader or a JavaCard to inject
those messages into a vending machine. The unsuspecting (literally!)
vending machine believes it is talking to an MCard with $18.23 in its
purse. A bottomless purse, forever. (This feature is what got the attention
of the Secret Service.)
Back to the transaction in progress. So far, the first phase of the
protocol has reserved funds in a log. Following product selection, the
second phase debits the purse and updates the log, authenticating itself in
both updates. It's up to the next vending machine that reads the card to
confirm that the log and the purse agree and to reconcile them if they
don't.
Message to MCard MCard response
Give me a nonce Here is a nonce
Debit $1.10 from the purse, \
authenticated with encrypted nonce OK
Another nonce-based authentication OK
Log the $1.10 transaction OK
Table: Post-selection phase of the MCard electronic purse transaction
To belabor the point about the replay attack, during a purchase, the MCard
authenticates the vending machine three times: twice prior to writing to
the log and once during the debit operation. But at no time does the MCard
authenticate to the vending machine.
It would certainly be possible to engineer a challenge/response that runs
in the opposite direction, indeed, the smart card has a specific API for
this Arguably, authenticating the card is the very first thing the vending
machine should do when a card is presented. So why didn't the smart card
developer include this in their protocol? Or even simpler, reverse steps 2
and 3 in the bare-bones protocol described earlier.
We can only speculate. The system we observe protects against attacks on
the card and leaves the vending machine wide open. This makes a certain
amount of sense: to attack a card, you need only a PC and a card reader,
but attacking a vending machine requires tools like CITI's bespoke card
extender and inverse card reader.