All exams← All Certified Ethical Hacker (CEH) notes

Hacking Web Applications: Certified Ethical Hacker (CEH) revision notes

Revision notes

## Hacking Web Applications: CEH Revision

Web applications are a primary target for attackers due to their accessibility and potential for sensitive data. Ethical hackers must understand common vulnerabilities and testing methodologies to secure these systems.

## Common Web Application Vulnerabilities

The OWASP Top 10 provides a standard awareness document for developers and web application security. Understanding these categories is crucial.

Injection

Injection flaws occur when untrusted data is sent to an interpreter as part of a command or query.

  • SQL Injection (SQLi): Malicious SQL queries are inserted into input fields to manipulate database queries, potentially leading to data theft, modification, or even remote code execution. Common types include Union-based, Error-based, Blind (Boolean-based, Time-based).
  • Command Injection: Injecting OS commands through an application to execute them on the server.

Cross-Site Scripting (XSS)

XSS allows attackers to inject client-side scripts into web pages viewed by other users.

  • Reflected XSS: Malicious script is reflected off the web server, typically in an error message or search result, and executed in the victim's browser.
  • Stored XSS: Malicious script is permanently stored on the target server (e.g., in a database, comment field) and delivered to victims when they request the affected page.
  • DOM-based XSS: The vulnerability lies in client-side code rather than server-side, manipulating the Document Object Model (DOM) environment.

Broken Authentication and Session Management

Vulnerabilities in authentication or session management can allow attackers to compromise user accounts.

  • Weak Credentials: Easily guessable passwords.
  • Session Hijacking: Stealing or predicting session IDs to impersonate a legitimate user.
  • Improper Session Management: Predictable session tokens, lack of session expiration, or not invalidating sessions after logout.

Broken Access Control

Attackers can exploit flaws in access control to bypass authorization checks and access unauthorized functionality or data.

  • Insecure Direct Object References (IDOR): Directly accessing internal implementation objects (e.g., file paths, database keys) without proper authorization checks.

Security Misconfiguration

This category covers a broad range of issues, including default credentials, unpatched flaws, unnecessary features, and misconfigured HTTP headers.

  • Default Credentials: Using factory-set usernames and passwords.
  • Unnecessary Services: Running services or features that are not required.

Cross-Site Request Forgery (CSRF) & Server-Side Request Forgery (SSRF)

  • CSRF: Tricking a victim's browser into sending an authenticated request to a vulnerable web application.
  • SSRF: An attacker can induce the server-side application to make HTTP requests to an arbitrary domain chosen by the attacker, potentially targeting internal systems.

File Upload Vulnerabilities

Improper validation of uploaded files can lead to remote code execution if an attacker uploads a malicious script (e.g., a PHP shell) that the server then executes.

## Key Tools for Web App Hacking

  • Burp Suite: An integrated platform for performing security testing of web applications (proxy, scanner, intruder, repeater).
  • OWASP ZAP (Zed Attack Proxy): A free, open-source integrated penetration testing tool for finding vulnerabilities in web applications.
  • SQLMap: An open-source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws.
  • Nikto: A web server scanner that performs comprehensive tests against web servers for multiple items, including over 6700 potentially dangerous files/programs, outdated server versions, and version-specific problems.

## Mitigation Strategies

Implementing secure coding practices, regular security audits, input validation, output encoding, strong authentication mechanisms, and proper access controls are essential for mitigating these risks.

Key facts

Flashcards

What is SQL Injection (SQLi)?
A web security vulnerability that allows attackers to interfere with the queries an application makes to its database, potentially leading to data theft or modification.
tap to reveal
Name the three main types of Cross-Site Scripting (XSS).
Reflected XSS, Stored XSS, and DOM-based XSS.
tap to reveal
What is the primary purpose of Burp Suite in web application hacking?
An integrated platform for performing security testing of web applications, including proxying, scanning, and exploiting vulnerabilities.
tap to reveal
What vulnerability allows an attacker to bypass authorization checks and access unauthorized data by directly referencing internal objects?
Insecure Direct Object References (IDOR), a form of Broken Access Control.
tap to reveal
How does Cross-Site Request Forgery (CSRF) typically work?
It tricks a victim's browser, while authenticated to a vulnerable site, into sending an unintended request to that site.
tap to reveal
What does SSRF stand for, and what does it enable?
Server-Side Request Forgery. It enables an attacker to induce the server-side application to make HTTP requests to an arbitrary domain chosen by the attacker.
tap to reveal
What is a common risk associated with unrestricted file uploads?
Remote Code Execution (RCE) if an attacker uploads and executes a malicious script (e.g., a web shell) on the server.
tap to reveal
Which organization publishes a widely recognized list of the top web application security risks?
OWASP (Open Web Application Security Project).
tap to reveal
Practice questions

Hacking Web Applications: 5 practice questions

Q1. An attacker injects a malicious script into a web page's comment section. When other users view the page, the script executes in their browser, potentially stealing their session cookies. What type of attack is this?
  • A.  Directory Traversal
  • B.  Cross-Site Request Forgery (CSRF)
  • C.  Stored Cross-Site Scripting (XSS)
  • D.  SQL Injection
Show answer & explanation
✓ Answer: C. Stored Cross-Site Scripting (XSS)
This is Stored (or Persistent) XSS because the malicious script is permanently stored on the target server and is served to all users who visit the affected page.
Q2. A penetration tester wants to automate the process of detecting and exploiting SQL injection flaws in a web application's database. Which of the following open-source tools is specifically designed for this purpose?
  • A.  Wireshark
  • B.  sqlmap
  • C.  Metasploit
  • D.  Nmap
Show answer & explanation
✓ Answer: B. sqlmap
sqlmap is a powerful, dedicated tool that automates the entire process of finding and exploiting SQL injection vulnerabilities and taking over database servers.
Q3. An attacker tricks a logged-in user into clicking a specially crafted link that performs an unwanted action on a trusted website, such as changing their password. This attack leverages the user's existing authenticated session. What is this attack called?
  • A.  Clickjacking
  • B.  Session Fixation
  • C.  Reflected Cross-Site Scripting (XSS)
  • D.  Cross-Site Request Forgery (CSRF)
Show answer & explanation
✓ Answer: D. Cross-Site Request Forgery (CSRF)
CSRF, also known as 'Session Riding', tricks a victim's authenticated browser into sending a forged HTTP request to a site, thereby performing an action as the user.
Q4. A web application parses XML input from a user without proper validation. An attacker submits a malicious XML file containing a reference to an external entity, causing the application to read and return the contents of a sensitive local file like '/etc/passwd'. What is this vulnerability?
  • A.  LDAP Injection
  • B.  Server-Side Request Forgery (SSRF)
  • C.  Insecure Deserialization
  • D.  XML External Entity (XXE) Injection
Show answer & explanation
✓ Answer: D. XML External Entity (XXE) Injection
XXE attacks abuse features of XML parsers to access local or remote resources by referencing external entities in the XML document, leading to information disclosure.
Q5. What is considered the most effective and fundamental programming practice to prevent SQL injection attacks in a web application?
  • A.  Using a Web Application Firewall (WAF)
  • B.  Using parameterized queries or prepared statements
  • C.  Implementing client-side input validation with JavaScript
  • D.  Hashing all user-supplied data before database insertion
Show answer & explanation
✓ Answer: B. Using parameterized queries or prepared statements
Parameterized queries ensure that user input is treated strictly as data, not as executable SQL code, which is the root cause of SQL injection vulnerabilities.
Test yourself
See the Certified Ethical Hacker (CEH) page

More Certified Ethical Hacker (CEH) topics