Common Backend Vulnerabilities
Authentication & Authorization
Spring Security JWT authentication
Content
Add authentication system to your week 7 project:
Type: coding (Java)
You've been handed a leaked password hash. The company had a weak password policy, so every password follows the format HackYourFuture followed by a 4-digit number (HackYourFuture0000 to HackYourFuture9999). The stolen hash:
$2b$10$qeQy/F75FZ06fWPnREh.pelDL.QwCQIbVPRP4qq9aqJouzMYNfK.2
Write a small Java program that loops through all 10,000 candidates and uses BCryptPasswordEncoder.matches(candidate, hash) to find the original password. Print the password once you find it, and print how long the search took.
Reflect (as comments in your code):
matches() call take, and why is it so slow compared to a normal hash?Hint: it will take a few minutes to run — that slowness is the whole point of bcrypt.
Type: hands-on
Here is a token issued by an API:
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c2VyLTQyIiwidXNlcm5hbWUiOiJzYW0iLCJyb2xlIjoiVVNFUiIsImV4cCI6NDEwMjQ0NDgwMH0.6inBRrghilltJq-MGw5uCbG5YBSfSZp7rAAZgPs4Xh4
Part A — read it: Paste the token into jwt.io (or Base64Url-decode the first two parts yourself). What is the user's role? What does this prove about storing sensitive data in a payload?
Part B — tamper (and fail): Change the role claim from USER to ADMIN, keep the original signature, and try to verify the token against the secret hyf-super-secret-key-2024. It should be rejected — explain in one sentence why.
Part C — forge (with the secret): Now that you have the secret, generate a brand-new valid token where role is ADMIN. Verify it passes. Write one sentence on why knowing the secret changes everything, and where that secret must never end up.
Use any JWT library (jjwt or java-jwt), or jwt.io's editor for a quick version.
Type: coding (Java)
Start with this deliberately vulnerable login lookup:
String sql = "SELECT * FROM users WHERE username = '" + username + "'";
users table with one or two rows.' OR '1'='1' -- as the username.JdbcClient with a named parameter, and confirm the same input now fails safely.Deliverable: the vulnerable version, the exploit input, and the fixed version — plus one sentence on why the parameterized version is immune.
Type: coding (Java)
This endpoint returns any order to any logged-in user:
@GetMapping("/api/orders/{id}")
public Order getOrder(@PathVariable Long id) {
return orderRepository.findById(id)
.orElseThrow(() -> new NotFoundException("Order not found"));
}
GET /api/orders/2 and confirm you can read Bob's order — that's the IDOR.403 Forbidden otherwise.Reflect: why is "being logged in" not the same as "being allowed"? Why are UUIDs a helpful second layer but not a real fix?
Type: written
Pick one feature from an app you've built (e.g. "user uploads a profile picture" or "reset password by email"). Put on your attacker hat and write down:
Deliverable: a half-page threat model. There is no single right answer — the goal is to practise thinking about what can go wrong before writing code.
The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0 *https://hackyourfuture.net/*

Built with ❤️ by the HackYourFuture community · Thank you, contributors
Found a mistake or have a suggestion? Let us know in the feedback form.