Top 10 OWASP API Vulnerabilities Every QA Must Know for Effective API Security Testing with crAPI

Top 10 OWASP API Vulnerabilities Every QA Must Know for Effective API Security Testing with crAPI

  • APIs power much of our digital experience today, connecting services and users worldwide. But this growth has come with increasing security risks. To combat these, the OWASP API Top 10 provides a roadmap for addressing the most critical API vulnerabilities. However, recognizing these vulnerabilities requires more than theoretical knowledge. Using crAPI (Completely Ridiculous API), a sandbox API developed by OWASP, we can practically explore these vulnerabilities and understand how they manifest in real-world scenarios.
  • crAPI : https://github.com/OWASP/crAPI

1. Broken Object Level Authorization

Example:

A common BOLA vulnerability occurs when users can access or manipulate data that they shouldn’t be authorized to access. With crAPI, let's attempt to access another user's service request details by simply changing the report_id in the "Get Mechanic Report" API.

Suppose you initially request your own service report using the following endpoint:

GET https://127.0.0.1:8888/workshop/api/mechanic/mechanic_report?report_id=5        

By changing the report_id to a different number, such as 5, you can access another report that should belong to a different user. This demonstrates that the endpoint fails to properly authorize based on the specific user’s access rights.

Prevention:

Implement object-level authorization checks by validating that the user_id in the request matches the logged-in user. Avoid relying on user-provided IDs alone for authorization.

2. Broken User Authentication

Example:

An API without secure session management allows attackers to impersonate other users. In crAPI, you might find that token validation is weak, allowing a JWT token to be reused indefinitely. Using an intercepted token, an attacker could potentially log in as another user:

POST https://127.0.0.1:8888/workshop/api/auth/reuse_token
Authorization: Bearer [stolen_jwt_token]        

Prevention:

Implement strong token handling by setting short token expiration times, using refresh tokens, and rotating tokens frequently.

3. Excessive Data Exposure

Example:

APIs should never reveal more data than necessary. In crAPI, the response for an account retrieval request might expose unnecessary data fields, such as:

GET https://127.0.0.1:8888/workshop/api/user/account        

Response:

{
  "username": "user1",
  "email": "[email protected]",
  "password_hash": "abc123hash",
  "phone": "1234567890"
}        

In this example, the API reveals the password_hash and phone number, which are not needed by the frontend.

Prevention:

Limit response data to only essential fields. Apply filtering or serialization at the API level, and avoid returning sensitive or internal data fields.

4. Lack of Resources & Rate Limiting

Example:

APIs without rate limits are vulnerable to brute-force and Denial of Service (DoS) attacks. The crAPI endpoint for sending messages to a mechanic has no rate limit:

POST https://127.0.0.1:8888/workshop/api/merchant/contact_mechanic
{
  "message": "Please contact me about my vehicle."
}        

An attacker could automate requests to spam this endpoint, overwhelming the service.

Prevention:

Implement rate limiting with IP throttling or API key-based rate limits to prevent abuse and ensure API stability.

5. Broken Function Level Authorization

Example:

This vulnerability occurs when users can access functions they’re not authorized to perform. In crAPI, a regular user might try to access administrative functions:

POST https://127.0.0.1:8888/workshop/api/admin/delete_user
{
  "user_id": "123"
}        

If there’s no role-based access control (RBAC) in place, unauthorized users might successfully delete accounts.

Prevention:

Ensure all functions are restricted by role-based access controls, where only authorized roles can access administrative or sensitive functions.

6. Mass Assignment

Example:

Mass assignment flaws occur when an API automatically maps input fields to model attributes without restrictions. With crAPI, a user might try adding an isAdmin field to their profile update:

PUT https://127.0.0.1:8888/workshop/api/user/update_profile
{
  "username": "user1",
  "isAdmin": true
}        

This example could potentially escalate a user's privileges if the API fails to filter input fields.

Prevention:

Define an allowlist of updatable properties for each endpoint and discard any fields that are not explicitly allowed.

7. Security Misconfiguration

Example:

In crAPI, certain endpoints may lack essential security headers, making them vulnerable to attacks like clickjacking or MIME-type sniffing. For instance:

GET https://127.0.0.1:8888/workshop/api/user/account        

Without headers like X-Frame-Options or Content-Security-Policy, this endpoint could be embedded in a malicious site.

Prevention:

Set up security headers (like X-Content-Type-Options, X-Frame-Options, and Content-Security-Policy) and apply secure default configurations across the API.

8. Injection

Example:

Injection vulnerabilities arise when APIs accept unsanitized inputs. In crAPI, certain fields may not sanitize user input, exposing the database to SQL injection:

GET https://127.0.0.1:8888/workshop/api/search?query=SELECT * FROM users        

An attacker could manipulate the query parameter to execute malicious SQL commands.

Prevention:

Use parameterized queries or ORM libraries and sanitize all input fields to prevent SQL injection.

9. Improper Assets Management

Example:

Exposing non-production assets can inadvertently expose vulnerabilities. In crAPI, if both the staging and production environments are accessible, attackers can test the staging environment for weaknesses and then exploit them in production.

GET https://staging.127.0.0.1:8888/workshop/api/user/details        

Prevention:

Ensure proper management of API assets. Disable public access to staging environments, and apply access controls for each environment.

10. Insufficient Logging & Monitoring

Example:

Without adequate logging, attacks may go unnoticed. In crAPI, sensitive requests like password resets may lack logging, making it hard to trace unauthorized password change attempts.

POST https://127.0.0.1:8888/workshop/api/user/reset_password        

If failed attempts or IP addresses aren’t logged, suspicious activity might remain undetected.

Prevention:

Log all sensitive actions and monitor logs for anomalies, such as repeated failed attempts or suspicious access patterns. Set up alerts for high-risk actions.

.

.

.

.

.

Securing APIs is no longer optional—it’s essential. Understanding and addressing the OWASP API Top 10 vulnerabilities in your APIs will protect your systems, your users, and your data. Tools like crAPI offer a unique opportunity to learn, test, and refine your skills in API security in a safe, controlled environment. Start with these core practices, and remember that building secure APIs is an ongoing commitment to excellence and protection.

#APISecurity #OWASP #CyberSecurity #crAPI #DataProtection #InfoSec #APIDevelopment #OWASPTop10 #APIBestPractices #SoftwareSecurity #APIIntegration #TechTips #SecDevOps #SecureAPIs #APIThreats


Pushkaaar Deshpande

10 YOE - [UI | API | PWA | Component | Performance Automation - Cypress.io | Playwright | WebdriverIO | Nightwatch | Appium | Postman | Newman | K6] [ChatGPT | Gemini | Bing] [CI-CD | AWS | Docker | K8s | SAAS | OTT]

3 周

Very informative

要查看或添加评论,请登录

社区洞察

其他会员也浏览了