As with the other labs, this lab is about both attacks and protection. The focus is on exploiting races conditions and on protection against them.
The lab consists of two parts.
In part one, the scenario is a race attack on a simple password
database. The attack is mounted by two principals Malin
and Kalle
(running as separate threads) that collaborate
to exploit a race condition in order to overwrite the password of an
honest principal
Bob
(which is yet another thread). You need to implement
the vulnerable database operations, an
attack, and fix the database operations.
Concretely, you need to write a Java program that includes
classes Password
, Principal
, and PasswordApp
.
These classes can be described as follows:
Password
handles a password
database. It should implement interface IPassword, which
contains the following methods:
check()
- this method accepts a user
name and a password and returns a boolean that
indicates whether the provided password matches the
one from the database.
updatePwd()
- this method accepts a
user name, old password, and new password. It should
check whether the old password matches the one in the
database, and if so, then update the password with the
new password. The method returns a boolean that
indicates whether the update has succeeded.
deleteUser()
- this method accepts a
user name and a password. It checks whether the
password is correct, and if so, erases the
user/password pair from the database. The method
returns a boolean that indicates whether the deletion
has succeeded.maxReqTime()
- returns the maximum
time (in milliseconds) taken by check()
,
updatePwd()
, or deleteUser()
requests so far. Clearly, the latter methods need to
keep track of time they take to serve requests from principals.
Principal
describes the behavior of a
principal, whether it is Malin
, Kalle
, or Bob
.PasswordApp
, which contains method
main()
. This class should start all necessary
threads.Password
class should not have other
vulnerabilities than race conditions. It should not contain
unjustified code.
Password
should not have
basic race conditions (such conditions are due to unprotected fields). In order to
verify this, you need to make sure that the CheckSync
tool (which implements Eraser for Java) gives no warnings on your
program.
Password
to
help you expose interleavings for which the attack works.
remote12.chalmers.se
) should be as follows:
> java PasswordApp ... Kalle logged in as Bob Maximum request time: 3007Where
Kalle logged in as Bobis printed by thread for
Kalle
on a successful login with username
Bob
. The last output
Maximum request time: 3007is printed at the end for statistics by some thread other than
Malin
, Kalle
, or Bob
.
PasswordApp
is a public class.
The output sync.log
from CheckSync
should contain no
warnings:
> setup_course tda600 > java -cp /chalmers/groups/tda600/CheckSync/checkSync.jar:. edu.umd.cs.pugh.CheckSync PasswordApp ... Kalle logged in as Bob Maximum request time: 3007 > cat sync.log >
PasswordFixed
, which is free
of races.
Password
does not have other
vulnerabilities than race conditions,
In part two, the scenario is a console password prompt in Java. As passwords are typed in the console they need to be hidden (by, for example, "*" characters). You need to evaluate multi-thread solutions offered by the Sun Developer Network.
Please stick to the simple database structure provided in Password.java. No complex database representations are needed to illustrate race attacks and protection.