This code uses reflective access, make sure your version of Java supports/allows this! We used JAVA_VERSION="15.0.2"
To run the server, run the following:
( make sure to replace and <path-to-sbp_impl-root-dir> )
<path-to-Java-Home>\Java\bin\java.exe
--illegal-access=permit
-classpath <path-to-sbp_impl-root-dir>\sbp_impl\out\production\sbp_impl
sbp.HTTPS_Server
Make sure to import certs\myCA.pem as a Certificate Authority into your browser / System Certificates
Using a browser, visit https://localhost:9000/login
Click the button to simulate the login / client autheication process.
You will be given an application session token in the form of a cookie,
and you will be taken to the account landing page.
This page includes malicious code that will forge and send a state-changing request to the server.
You can check the server output in the terminal to see if the server will honor or ignore this malicious request.
General information about this implementation:
- There are 3 endpoints for this server:
- The
/loginendpoint takes the user to theLoginpage - The
/accountendpoint is the user'sAccountlanding page - The
/changeendpoint accepts state-changing requests for the account
- The
- When the user clicks on the button in the
Loginpage,
they are direct to the/accountendpoint and the server does the following:- The server uses Java's illegal reflective access to extract the master secret used with each client
(this will generate a warning in the terminal, you can ignore that warning) - The server uses the master secret and a constant secret key
KPSto generate aclientKeyfor each client - The server generates and stores a new token for each client
- The server generates a fresh IV and encrypts the token using the
clientKey - The server attaches the encrypted token as a cookie to the response
- The server attaches the html for the
Accountpage as the body of the response and send the response.
- The server uses Java's illegal reflective access to extract the master secret used with each client
- The
Accountpage includes injected malicious JavaScript code.
When the page loads inside the client's browser, the code runs and sends a request to the/changeendpoint.
The browser will auto-attach the cookie received from the server to this change request - When the server receives a request on the
/changeendpoint, it does the following:- The server searches for a cookie, if not found, request is ignored, otherwise:
- The server regenerates the
clientKeyfor client and uses it to decrypt the value stored in the cookie - If the decrypted value is found in the stored list of issued tokens,
the server printsValid change request received, request will be honored!
otherwise, it printsInvalid change request received, request will be ignored