My review on “Exploiting and Securing Vulnerabilities in Java Applications” in Coursera

Hugo
3 min readApr 6, 2022

My job recently has to build a solution for user management and protecting OWASP risks is important. Then, I want to know more about how my application can be attacked to have deeper insight.

I decdie to take the course from Coursera: Exploiting and Securing Vulnerabilities in Java Applications

https://www.coursera.org/learn/exploiting-securing-vulnerabilities-java-applications.

This course ease my reading of OWASP cheetsheets. Before they are superficial to me and now I see how the attack can happen.

The followings are my detail review:

The topics cover

  • XSS — Client
  • Injection — Server
  • Authentication

based on WebGoat, the project that OWASP develops for exercising attack and defense.

For me the XSS Client is useful to know Frontend attack. The injection part is simple and by using the proper library nothing can go wrong in my experience. The useful tool I learn in the injection part is how to setup Burp

https://portswigger.net/burp

which is a free tool to hack your application. You can intercept the call, change the params easily and send the request to the server.

The most useful part is Authentication. It covers authentication bypass and JWT. The exercise can bring your understanding to another level.

The attack is also provided with 1 or 2 examples that happened in the real world in the past, to give you deeper impression.

XSS Client:

  • Stored XSS

BeEF - The Browser Exploitation Framework Project

Case

and the solution is to use the encoder.

GitHub — OWASP/owasp-java-encoder: The OWASP Java Encoder is a Java 1.5+ simple-to-use drop-in high-performance encoder class with no dependencies and little baggage. This project will help Java web developers defend against Cross Site Scripting!

Authentication

Authentication bypass

JWT

Refresh token

  • Regardless of the chosen solution you should store enough information on the server side to validate whether the user is still trusted. You can think of many things, like store the ip address, keep track of how many times the refresh token is used (using the refresh token multiple times in the valid time window of the access token might indicate strange behavior, you can revoke all the tokens an let the user authenticate again).
  • Also keep track of which access token belonged to which refresh token otherwise an attacker might be able to get a new access token for a different user with the refresh token of the attacker (see JWT Refresh Token Manipulation for a nice write up about how this attack works).
  • Also a good thing to check for is the ip address or geolocation of the user. If you need to give out a new token check whether the location is still the same if not revoke all the tokens and let the user authenticate again.
  • In the case the refresh tokens are stored for validation it is important to protect these tokens as well (at least use a hash function to store them in your database).

JWT a good idea?

Here I also provide some solutions when you get stuck to solve the exercises from WebGoat

--

--