Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following protocol for adding money to a debit card. User inserts d

ID: 3766346 • Letter: C

Question

Consider the following protocol for adding money to a debit card. User inserts debit card into debit card machine. Debit card machine determines current value of card (in dollars), which is stored in variable x. User inserts dollars into debit card machine and the value of the inserted dollars is stored in variable y. User presses enter button on debit card machine. Debit card machine writes value of x + y dollars to debit card and ejects card. Recall the discussion of race conditions in the text. This particular protocol has a race condition. What is the race condition in this protocol? Describe a possible attack that exploits the race condition. How could you change the protocol to eliminate the race condition, or at least make it more difficult to exploit?

Explanation / Answer

a) what is the race condition in this protocol?
race condition exists when multithreading code runs parallely, that would shared a same resource
So that it will give unexpected results. In our example when user gives some cheque to some person.
That person tries to debit the money from bank using this cheque and same time and account holder
tries to debit the money from atm machine...then race condition will occur.

b) Describe possible attack that exploits the race condition?
Because of this race condition, the attacker will wait for user giving password to access atm,
then immediately attacker will hack the account and steal the money.

c) How to eliminate the race condition?
Race conditions will be avoided by using locking mechanism. So as per ordering of activites
multiple locks will be placed. So if one process starts (in our example , debiting money using cheque)
, then other user has to be wait (debit money from atm card) until first transaction completes.