Loopus

Pro Content

This lesson requires Loopus Pro access. Upgrade to unlock all courses, labs, and challenges.

Web Application HackingAPI Security

REST API Fundamentals

15 min
theory
+25 XP

Learning Objectives

  • Understand modern API architectures
  • Test REST and GraphQL APIs for vulnerabilities
  • Identify common API security flaws

API Security Testing Fundamentals

Modern web applications increasingly rely on APIs to separate frontend interfaces from backend logic. Single-page applications, mobile apps, and third-party integrations all communicate through API endpoints, creating new attack surfaces that require different testing approaches than traditional web pages.

The API Attack Surface

APIs fundamentally change how applications communicate. Instead of rendering complete HTML pages server-side, many applications expose data through API endpoints that clients consume and display. This architecture offers flexibility and performance benefits but introduces security challenges.

REST APIs organize resources under meaningful URLs and use HTTP methods semantically. GET retrieves resources, POST creates them, PUT updates them, and DELETE removes them. This predictable structure makes APIs easier to understand and document but also easier to enumerate and attack.

GraphQL provides a single endpoint that accepts queries defining exactly what data clients want. While this flexibility benefits developers, it also means attackers can potentially request any data the schema exposes without needing to discover individual endpoints.

Common API Vulnerabilities

Broken Object-Level Authorization tops the list of API security issues. Many APIs expose direct references to objects through identifiers like /api/users/123. If the application doesn't verify that the authenticated user should access that specific object, attackers can enumerate and retrieve other users' data by simply changing the ID.

Mass assignment occurs when APIs accept more parameters than they should. An update endpoint expecting {name: "value"} might also process {role: "admin"} if the server binds all incoming parameters to database objects without filtering. Attackers discover these hidden parameters through documentation, code analysis, or experimentation.

Rate limiting failures allow automated attacks that would trigger protections in traditional interfaces. APIs designed for programmatic access often accept requests much faster than human users would generate, enabling credential stuffing, data scraping, and denial of service attacks.

Testing Methodology

Effective API testing starts with understanding the API's structure. Documentation, if available, maps out endpoints, parameters, and expected responses. Intercepting real API traffic reveals how the application actually uses its API, sometimes exposing undocumented functionality.

Authentication and authorization deserve thorough testing. What happens without a token? With an invalid token? With a token belonging to a different user or role? Each endpoint needs verification that it properly enforces access controls.

Input validation testing follows familiar patterns adapted for API contexts. SQL injection in JSON parameters, command injection in search queries, and path traversal in file references all remain possible. The testing techniques transfer even when the delivery mechanism changes.

GraphQL-Specific Concerns

GraphQL's introspection features can reveal the entire schema including all types, fields, and operations. While useful for developers, this self-documenting nature helps attackers understand exactly what data exists and how to request it.

Query complexity attacks target GraphQL's flexibility. Deeply nested queries or queries requesting large amounts of data can overwhelm servers that don't implement proper complexity limits. Attackers craft expensive queries to consume server resources.

Authorization in GraphQL requires careful attention because a single request might access multiple related resources. Each field access needs individual authorization checks, not just the top-level query.

Answer the Questions0 / 4 completed

📚 KnowledgeQuestion 1

What interface allows software to communicate?

Format: ***(3 chars)
Exact match required
⌨️ Hands-OnQuestion 2

What HTTP method updates a resource?

Format: ***(3 chars)
Exact match required
📚 KnowledgeQuestion 3

What data format do REST APIs use?

Format: ****(4 chars)
Exact match required
⌨️ Hands-OnQuestion 4

What HTTP header sends a token?

Format: *************(13 chars)
Exact match required
Answer all questions correctly to unlock the next lesson

Interactive Sandbox

Loading sandbox...
Previous
Answer all questions to continue