Common Backend Vulnerabilities
Authentication & Authorization
<aside> 🚧
This page is currently under construction. Please check back later.
</aside>
Our methodology for this section is "Exploit First, Then Fix." For each vulnerability, we will first put on our "attacker hat" to understand how it can be exploited. And will focus on the concepts and the attacker's strategy. Then we will look into how can this be translated in code.
Imagine you ask a librarian for a book by "John Smith." Now imagine you ask for "John Smith's book, and also, give me the keys to the rare books room." SQL Injection is like that second request. It's when an attacker tricks the application into running unintended database commands by hiding them inside what looks like normal user input (like a username or a search query).
The Attacker's Goal: bypass the application's logic and talk directly to the database to:
A Practical Example:
Think of a login page with a username and password field. The application expects a username like ‘testuser’.
An attacker might enter something like this in the username field:
' OR '1'='1' --.
When the application builds its database query to check the user, this malicious input breaks the original logic. The '1'='1' part is always true, and the -- tells the database to ignore the rest of the command (like the part that checks the password). The result? The database thinks the login is valid, and the attacker is let in.
Leverage Object-Relational Mapping (ORM): Modern frameworks like Spring Data JPA use prepared statements behind the scenes. By using an ORM correctly, you inherit these security benefits without having to write SQL queries manually.
XSS happens when an application takes untrusted data (like an attackers crafted javascript code in a comment section) and sends it to a web browser without cleaning it first, causing a malicious script to run in the victim's browser. Example
<p>Hi, my name is Bob.</p><script>steal_user_cookie();</script>
The Attacker's Goal:
CSRF tricks a logged-in user into unknowingly performing an action they did not intend, by forcing their browser to submit a malicious request to an application where they are already authenticated
The Attacker's Goal:
Use Anti-CSRF Tokens (Synchronizer Token Pattern): This is the classic defense. The server embeds a unique, secret, and unpredictable token in every web form. When the user submits the form, the token is sent back. The server validates that the received token is the one it expected. An attacker cannot guess this token, so any forged request they create will be rejected.
This is when an application reveals sensitive internal details (like stack traces or database error messages) to the end-user when it encounters an error.
The Attacker's Goal: Gather intelligence for a future attack by learning about the technologies used (database, framework), internal file paths, and application logic.
This vulnerability exists when an application doesn't limit how many times a user or IP address can attempt an action in a given period of time.
The Attacker's Goal:
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.