Web Application Attacks: Types, Examples, and Runtime Protection

By ByteHide12 min read
Web application attacks explained: types, examples, and how runtime protection stops them

Web application attacks are attempts to exploit weaknesses in the code, logic, or configuration of an application through its normal web interfaces, such as forms, URLs, headers, and APIs. They remain one of the most common ways attackers breach organizations: the Verizon Data Breach Investigations Report lists web applications among the top vectors in confirmed breaches year after year, and the OWASP Top 10 exists specifically to catalog the risks behind them.

This guide is written for developers and security engineers who want a clear, practical map of the landscape. We will cover the main types of web application attacks, how the three most-confused ones (XSS vs CSRF vs SQL injection) actually differ, what they look like in real code, and why defending against them at runtime closes gaps that perimeter tools leave open.

Table of Contents

  • What Are Web Application Attacks?
  • Types of Web Application Attacks
  • XSS vs CSRF vs SQL Injection: Key Differences
  • Real-World Examples (with Code)
  • Why Perimeter Defenses Miss These Attacks
  • How Runtime Protection Defends Against Every Attack Type
  • Web Application Attack Prevention Checklist
  • Frequently Asked Questions

What Are Web Application Attacks?

A web application attack is any malicious attempt to exploit a vulnerability in an application’s code, logic, or configuration through the interfaces it exposes over HTTP(S). Instead of breaking through the network perimeter, the attacker speaks the application’s own language: HTTP requests, form fields, query parameters, cookies, and API calls.

What makes the application layer such a rich target is trust. Every input a user sends is, by default, untrusted, yet the application has to read it, store it, render it, and act on it. Web application security attacks abuse exactly that boundary. A single field that gets concatenated into a database query, reflected into a page, orc used to build a file path can become the entry point for a full compromise.

Because these attacks ride on legitimate traffic, they often look like normal requests until the moment they execute. That is why understanding the categories, and where each one strikes, matters more than memorizing individual payloads.

Types of Wecb Application Attacks

The most common types of web application attacks fall into four families, grouped by the part of the system they abuse: injection, client-side, broken access and server-side, and automated attacks.

Injection attacks

Injection happens when untrusted input is interpreted as a command or query. SQL injection manipulates database queries to read, modify, or delete data the user should never reach. NoSQL inection does the same against document databases like MongoDB, abusing query operators instead of SQL syntax. Command injection smuggles operating-system commands through input that is passed to a shell. Injection has topped the OWASP risk lists for years because the impact, from data theft to remote code execution, is so high.

Client-side attacks

These target the user’s browser rather than the server. Cross-site scripting (XSS) injects malicious JavaScript that runs in another user’s session, letting an attacker steal cookies, tokens, or keystrokes. Cross-site request forgery (CSRF) tricks an authenticated user’s browser into sending an unwanted state-changing request, such as a password change or a money transfer. Clickjacking layers an invisible frame over a legitimate page to hijack clicks.

Broken access and server-side attacks

Here the attacker abuses the application’s logic and trust relationships. Broken access control / IDOR lets a user reach data or actions that belong to someone else by tampering with identifiers. Server-side request forgery (SSRF) coerces the server into making requests to internal systems it should never touch. Path traversal uses sequences like ../ to read files outside the intended directory.

Automated and volumetric attacks

Some attacks rely on scale rather than a single flaw. Credential stuffing replays leaked username-password pairs in bulk. Brute-force attacks guess credentials or tokens. Layer 7 (application-layer) DDoS floods expensive endpoints to exhaust resources.

For the canonical reference on which of these carry the most risk, see the OWASP Top 10.

XSS vs CSRF vs SQL Injection: Key Differences

XSS, CSRF, and SQL injection are the three attacks developers confuse most often, because all three involve “malicious input.” The real difference is what the attacker controls and who the victim is.

AttackWhat the attacker controlsPrimary targetTypical impactPrimary defense
SQL injectionInput that reaches a database queryThe server’s databaseData theft, data tampering, RCEParameterized queries
XSSInput reflected or stored into a pageOther users’ browsersSession/cookie theft, account takeoverOutput encoding + CSP
CSRFA link or form the victim triggersAn authenticated user’s sessionUnwanted state changesAnti-CSRF tokens + SameSite cookies

XSS vs CSRF

The core difference between XSS and CSRF is the direction of trust. XSS abuses the trust a user has in a site by running attacker-controlled code in the victim’s browser. CSRF abuses the trust a site has in the user’s browser by riding on credentials the browser already holds. In short, XSS executes code while CSRF forges requests. An XSS flaw can even be used to defeat CSRF defenses, which is why the two are often discussed together.

XSS vs SQL Injection

XSS and SQL injection differ in where the payload executes. In SQL injection the payload runs on the server, inside the database engine, to expose or alter data. In XSS the payload runs on the client, inside another user’s browser. SQL injection attacks the application’s data; XSS attacks the application’s users. Both share the same root cause: mixing untrusted input with trusted code or queries.

Real-World Examples (with Code)

The fastest way to understand these attacks is to put the vulnerable code next to its fix. The examples below use JavaScript/Node.js, but the principles apply to every language.

SQL injection

// Vulnerable: user input is concatenated directly into the query.// Input  ' OR '1'='1  turns the WHERE clause into "always true".const query = `SELECT * FROM users WHERE email = '${req.body.email}'`;db.query(query);// Secure: a parameterized query sends data and code separately,// so input can never change the structure of the statement.db.query('SELECT * FROM users WHERE email = $1', [req.body.email]);

Cross-site scripting (XSS)

// Vulnerable: untrusted input is written into the page as HTML.// A comment like <img src=x onerror="fetch('/steal?c='+document.cookie)">// will execute in every visitor's browser.element.innerHTML = userComment;// Secure: treat input as text, never as markup, and encode on output.element.textContent = userComment;// Add a Content-Security-Policy header to block inline script as defense in depth.

Cross-site request forgery (CSRF)

// Vulnerable: a state-changing endpoint with no proof the request was intentional.app.post('/account/transfer', (req, res) => {  transfer(req.body.to, req.body.amount); // any external site can trigger this});// Secure: require and verify a per-session CSRF token before acting.app.post('/account/transfer', verifyCsrfToken, (req, res) => {  transfer(req.body.to, req.body.amount);});// Also set authentication cookies with SameSite=Strict to block cross-site sends.

Notice the pattern. Every fix works by separating untrusted data from trusted execution, or by proving intent. That is exactly what a runtime defense enforces when code-level fixes are missing or incomplete. For a deeper, language-by-language look at catching these flaws in production, see detecting SQL injection at runtime.

Why Perimeter Defenses Miss These Attacks

A traditional web application firewall (WAF) sits at the network edge and inspects HTTP traffic against a set of signatures and rules. It is useful, but it works from the outside, and that creates three structural blind spots.

First, it matches patterns, not behavior. Attackers bypass signatures with encoding, case changes, comment injection, and obfuscation that look harmless on the wire. Second, it has no application context. A perimeter WAF cannot know whether a suspicious string actually reaches a database query, a DOM sink, or a file path, so it must either over-block legitimate traffic or let ambiguous payloads through. Third, modern apps span server, mobile, and API surfaces, while an edge filter only sees what crosses that one edge.

The result is a gap between “a request looked malicious” and “an attack actually executed.” For a full breakdown of where edge filtering helps and where it falls short, see our In-App WAF vs perimeter WAF comparison. In my experience, teams that rely only on edge rules hit the same wall: the WAF flags plenty of noise but still misses the one encoded payload that reaches a query.

How Runtime Protection Defends Against Every Attack Type

Runtime protection closes that gap by moving defense inside the application. Technologies known as runtime application self-protection (RASP) and, more broadly, Application Detection and Response (ADR) instrument the running app so they can see the actual SQL query before it executes, the real DOM sink before it renders, and the exact system call before it runs.

How runtime protection (RASP and ADR) detects web application attacks from inside the application

That inside view changes the question from “does this request look malicious?” to “is this input about to be used in a dangerous way?” Because the engine observes execution instead of guessing from patterns, it confirms attacks rather than approximating them, which means far fewer false positives and far fewer bypasses through encoding tricks.

The strategic advantage is coverage. The same instrumentation that catches SQL injection at the query layer also catches XSS at the rendering layer, command injection at the system-call layer, and path traversal at the file-access layer. One runtime layer defends against the whole taxonomy above, across server, mobile, and API workloads, instead of one appliance per surface. This is the approach behind ByteHide App Runtime, which adds an In-App WAF and ADR directly inside the application without changing its architecture.

Web Application Attack Prevention Checklist

A resilient web application pairs secure coding with a runtime safety net:

  • Validate and normalize all input on the server; never trust client-side checks alone.
  • Use parameterized queries or an ORM for every database call (stops SQL and NoSQL injection).
  • Encode output for its context and enforce a strict Content-Security-Policy (stops XSS).
  • Require anti-CSRF tokens and set cookies to SameSite=Strict (stops CSRF).
  • Enforce object-level authorization on every request (stops IDOR and broken access control).
  • Allowlist outbound destinations and block internal IP ranges (limits SSRF).
  • Canonicalize and sandbox file paths (stops path traversal).
  • Add rate limiting and bot detection (limits credential stuffing, brute force, and Layer 7 DDoS).
  • Track the OWASP Top 10 and patch known-vulnerable dependencies.
  • Deploy runtime protection (RASP / In-App WAF / ADR) to detect and block whatever slips past the code.

Frequently Asked Questions

What are the most common web application attacks?

The most common web application attacks are SQL injection, cross-site scripting (XSS), cross-site request forgery (CSRF), broken access control, and server-side request forgery (SSRF). Injection and broken access control consistently rank at the top of the OWASP Top 10.

What is the difference between XSS and CSRF?

XSS runs attacker-controlled code in a victim’s browser, while CSRF forces a victim’s browser to send an unwanted authenticated request. XSS executes scripts; CSRF forges actions. XSS can be used to bypass CSRF protections, but they are distinct vulnerabilities with distinct defenses.

Is SQL injection still a threat in 2026?

Yes. Despite being decades old, SQL injection is still common because any query built by concatenating untrusted input is vulnerable. Parameterized queries prevent it, and runtime detection catches attempts that reach the database layer in production.

What is a WAF attack?

“WAF attack” usually refers to a web application attack that a web application firewall is expected to block, or to a technique that bypasses a WAF. Because perimeter WAFs match patterns, attackers use encoding and obfuscation to evade them, which is why in-app and runtime defenses are increasingly paired with edge filtering.

Can a WAF stop all web application attacks?

No. A perimeter WAF reduces exposure but cannot see whether a payload actually reaches a dangerous sink inside the app, so it misses obfuscated and logic-based attacks. Combining a WAF with runtime protection covers both the edge and the execution path.

How does runtime protection differ from a WAF?

A WAF inspects traffic from outside the application using signatures, while runtime protection (RASP/ADR) runs inside the application and observes actual execution. That inside view lets it confirm exploitation with higher accuracy and defend against many attack types with a single layer.

Conclusion

Web application attacks share one root cause: untrusted input meeting trusted execution. Sorting them into families (injection, client-side, broken access, and automated) makes the landscape manageable, and a handful of habits such as parameterized queries, output encoding, CSRF tokens, and strict authorization neutralize most of them at the source.

Key takeaways:

  • The biggest risks (injection, XSS, CSRF, broken access) come from how the app handles input and trust.
  • XSS, CSRF, and SQL injection differ by what the attacker controls and where the payload runs.
  • Secure coding prevents attacks; runtime protection catches what slips through.
  • A single runtime layer can defend against the entire attack taxonomy across server, mobile, and API.

If you want to detect and block these attacks the moment they execute, without re-architecting your app, ByteHide App Runtime brings In-App WAF and ADR inside your application across every surface.

Related posts