Exercice
Exercice
Access control
R. Absil P. Hauweele
This document quickly reviews a few access control techniques and principles to implement
on a basic client / server application, in Java.
Introduction
Access control is a core concept in sensitive computer systems. In general, a secure system must
at least implement the following features:
• non repudiation: when a transaction t is performed between actors x and y, making sure
that x and y are who they claim to be, and that none of them can deny taking part in t;
For the purpose of this lab, we will use a minimal1 client/server application implemented in
Java. The main components of this application are:
• BasicServer.java: classes modeling the server’s side of the application, namely, a simple
class for the server, a utility class (BasicServerThread) to model a session, and the
interface BasicMessageHandler as the handler for messages of specific types (this interface
will have to be implemented for each message recognisable by the server);
• UserDB: a simple interface to store (resp. retrieve) users into (resp. from) a file;
1
For the sake of simplicity, and to solely focus on security, we will shamelessly and with impunity violate nearly
every single software engineering principle regarding the design of client/server applications.
Access control 2021 – 2022
Note that the files ClientMain.java and ServerMain.java can be used as tutorials showing
how to use this small framework.
• telling "You killed my father" to the server, that answers "No, I am your father";
• telling "Hello there" to the server, that answers "General Kenobi!";
• closing the session.
In the next section, the objective will be to implement several security principles. More
precisely, we will take the following steps:
Note that while this lab provides exercices to illustrate these concepts and implement security
features, they do not concretely detail how to implement them. It is a soft skill you are expected
to develop. You are encouraged to think outside the box.
Clients will generate their own pair of keys when needed, and these keys will also be trusted by
the server. For that purpose, the classes MessageDigest, Cipher, KeyPair, KeyGenerator and
SealedObject from the Java standard will most likely be useful.
This scheme is clearly flawed, mainly in terms of certification and associated security features.
For that reason, it is possible that some of the exercices that are given are artificial. These
problems will be addressed in the next lab, as this one focuses on access control and protection
against replay attacks.
2
For modularity, it is considered that the client accepts commands, made out of an initial string followed by
potential data. There are three predefined commands: HELLO, FATHER and EXIT. It is then expected that FATHER is
followed by You killed my father and HELLO by Hello there. Depending on the type of command, the client
then builds up a particular message type, later written down to the stream linking the client to the server.
2
Access control 2021 – 2022
Submission
Projects can be implemented in pairs (groups of 2 students), and must be submitted with the
help of a git repository3 . For that purpose, send an email to your teacher on 10 April at 23h59 at
the latest with the URL to your repository, and the name and matricule of your group members.
You have to submit your work on 24 April at 23h59 at the latest. The minimal requirements
for submitted projects are as follows:
Projects failing to meet these requirements will not be graded (that is, they will get 0/20).
Furthermore, note that we shall in no way build or run your projects in an IDE.
Exercises
For the following exercices, we will ask that you add several features associated with security in
the basic client/server framework that we provided. For that purpose, we advise that you create
new message types, message handlers, etc. While you are free to modify the code we provided in
any way you want, it should be enough to add enumerators in the MsgType enumeration, and
then only work from within the ClientMain and ServerMain classes.
Exercice 1. Implement a basic password-based user registration scheme, that is, create a message
type allowing non authenticated users to ask for the creation of their user account.
When a user asks for an account to be created, he provides a login and a password matching
the policy5 . The login has to be unique.
Note that it is expected here that users’ passwords are transmitted and stored securely, that
is
• passwords are ciphered with RSA (2048 bits) when transmitted from the client to the
server,
3
Create the repository yourself, add your teacher as maintainer.
4
Projects that do not compile will not be graded.
5
Passwords are assumed to be between 6 and 8 alphanumeric ASCII characters.
3
Access control 2021 – 2022
• passwords are salted and stored hashed using 100 passes through the PBKDF2 hash
function6 .
In order to persistently store users, we demand that you use the UserDB class. This class is
able to associate any login to an arbitrary amount of data, with the help of the parameter
byte[]... fields. This information is transparently (un)serialised for you, so no modification
of this class should be required.
Exercice 2. Implement a simple authentication scheme so that registered users can authenticate
providing their login and password.
Exercice 3. Make sure that messages of type FATHER are only processed for authenticated users.
Exercice 4. Implement the following challenge-answer scheme so that no message can be replayed
2. when actor y answers, he provides n1 ` 1 (to be checked by x), and includes an encrypted
random integer n2 ;
3. When actor x answers, he provides n2 ` 1 (to be checked by y), and includes an encrypted
random integer n3 , etc.
For the purpose of this exercice, it is probably useful to create a class NonReplayableMessage
packing up an integer (to be checked according to the above scheme) along with a BasicMessage.
6
It’s probably useful to have a look at the Java classes javax.crypto.spec.PBEKeySpec and
javax.crypto.SecretKeyFactory