<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by shirish on Medium]]></title>
        <description><![CDATA[Stories by shirish on Medium]]></description>
        <link>https://medium.com/@thisislazaruss?source=rss-d41bd127d601------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*suUt7Oj5fZ3LdPMcxxviRA.jpeg</url>
            <title>Stories by shirish on Medium</title>
            <link>https://medium.com/@thisislazaruss?source=rss-d41bd127d601------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:55:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thisislazaruss/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[c{api}tal Analysis Report]]></title>
            <link>https://medium.com/@thisislazaruss/c-api-tal-analysis-report-2c7e2cad8654?source=rss-d41bd127d601------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c7e2cad8654</guid>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[begineers]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[shirish]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 15:29:17 GMT</pubDate>
            <atom:updated>2023-08-02T15:29:17.271Z</atom:updated>
            <content:encoded><![CDATA[<p>With this blog I present you the analysis report of <a href="https://github.com/Checkmarx/capital">capital API</a>.</p><p>First view of the application frontend:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*kvW1Xj8cemFQE9YGmmxn0Q.png" /><figcaption>Fig 1: First view of the application</figcaption></figure><p>As the application is made up of js, I tried to send the request to burp and filter out the js requests only which as a result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*XW3POTkR0czcpVgL8on6NA.png" /><figcaption>Fig 2: Analyzing HTTP history</figcaption></figure><p>So viewing the request on browser gave me :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*_QpjDnnu6MfGFXzPWoi0Qw.png" /><figcaption>Fig 3: Viewing the application in json format</figcaption></figure><p><strong>Vulnerabilities explanations:</strong></p><p><strong>API1: Broken Object Level Authorization</strong></p><p><strong>Description:</strong></p><p>The application is vulnerable to broken object level authorization since the application allows any user to delete the comments within post by other user. Object-level authorization is the process of granting or denying access to specific objects, such as files, database records, or other resources, based on the user’s privileges and permissions. Broken object level authorization occurs when when an application or system fails to properly enforce access controls on individual objects or resources.</p><p><strong>Impact:</strong></p><ul><li>Once attackers gain access to resources, they may modify or delete critical data, leading to data loss, data manipulation, or disruption of services.</li></ul><p><strong>Remedies:</strong></p><ul><li>Ensure access controls consider the user’s role, context, and session data to make more accurate access decisions.</li><li>Monitor access attempts and log activities to detect suspicious behavior and potential unauthorized access.</li></ul><p><strong>Steps of Reproduction:</strong></p><ul><li>Navigate to the swagger documentation and authorize yourself.</li><li>Navigate to the comments documentation section and try creating comment either by using swagger itself or burp. I have shown evidences using burp.</li><li>Try deleting the comment and check for the response.</li></ul><p><strong>Evidences:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*bvjoaPQ30Akm98YQfIyJsQ.png" /><figcaption>Fig 4: Navigating to the comment endpoint</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*2Wlmxx8wICGL5TQl_yiy9g.png" /><figcaption>Fig 5: Viewing the slug of the posts</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*f1mPxXGclnvzCKF4uuFVMw.png" /><figcaption>Fig 6: Adding the necessary values for deleting the comments</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*tbkYqHftGbfDBmNPKKGYLw.png" /><figcaption>Fig 7: As there were no comment on the post, I tried creating one using the POST Method</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*KeRfa2RvgM9uVKUTeree5Q.png" /><figcaption>Fig 8: Deleting the recently created comment</figcaption></figure><p>Let’s try deleting the post itself now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*nLNfVtZT-BiY6OQsp_yCfQ.png" /><figcaption>Fig 9: Trying deleting other user’s post without any auth0rization</figcaption></figure><p><strong>API2: Broken Authentication</strong></p><p><strong>Description:</strong></p><p>The application is vulnerable to broken authentication as knowing just the email address and brute forcing the password, we are able to login as the user which is already registered. Authentication is the process of verifying the identity of users attempting to access a system or application. Broken authentication is a security vulnerability that occurs when an application or system’s authentication mechanisms are flawed or improperly implemented, leading to potential unauthorized access to user accounts or sensitive data.</p><p><strong>Impact:</strong></p><ul><li>Attackers can impersonate legitimate users by bypassing the authentication process, potentially gaining access to personal information, financial data, or sensitive resources associated with the compromised accounts.</li></ul><p><strong>Remedies:</strong></p><ul><li>Enforce strong password requirements, such as minimum length, complexity (combining uppercase, lowercase, numbers, and special characters), and password expiration. Discourage the use of easily guessable passwords and common words.</li></ul><p><strong>Steps of Reproduction:</strong></p><ul><li>Look for the recent post and check for sensitive data.</li><li>Now send the request to burp.</li><li>Here in this case I have found an email of a user but there is no password and we need to guess it.</li><li>Send the request to intruder and highlight the password section and add $</li><li>Also load the list of common password for payload and start attack.</li><li>Wait for 200 response and try the passwords that matches the login.</li></ul><p><strong>Evidences:</strong></p><p>Viewing the post, a post called I am Pikachu contains a email <a href="/service/mailto:Pikachu@checkmarx.com">Pikachu@checkmarx.com</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*U5UdZIcZEoSem_lsoPQIVQ.png" /><figcaption>Fig 10: Navigating to targeted post</figcaption></figure><p>Sending the following request :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*b8oLTlHhnqRndXJBWkk8QA.png" /><figcaption>Fig 11: User authentication documentation</figcaption></figure><p>Passing the request to intruder for brute force attack:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*L3jv04DBJx2kcdfL78Ch3w.png" /><figcaption>Fig 12: Giving the list of common password for the payload to brute force the password</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*6f-GVC7pq9wu9xOxqCmBpw.png" /><figcaption>Fig 13: Viewing the response of 200 status and figuring out password</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*t5V6PvSgtmjyam32nQaRnQ.png" /><figcaption>Fig 14: Viewing the response in the documentation</figcaption></figure><p><strong>API3: Broken Object Level Property Authorization</strong></p><p><strong>Description:</strong></p><p>This application is vulnerable to object level property authorization since it allows the user to modify the request and provide any method in the request and view the login credentials (in this case it’s just flag). In the context of an application, an object typically refers to logging entity, that the application manages.Properties or attributes are individual data elements or fields that describe an object. Authorization refers to the process of determining whether a user or application has the necessary permissions to perform specific actions on an object. Here a normal user was able to edit the method and provide the logging endpoint and view the descriptions.</p><p><strong>Impact:</strong></p><ul><li>Attackers can manipulate object identifiers or properties to access sensitive data they are not authorized to view. This could include personal information, financial data, intellectual property, or other confidential data.</li><li>This can result in the exposure of private and sensitive user information, violating user privacy and potentially leading to legal and reputational issues for the application owner.</li></ul><p><strong>Remedies:</strong></p><ul><li>Avoid using direct object references (e.g., sequential IDs, predictable filenames) in URLs or parameters. Instead, use indirect references, such as UUIDs or randomly generated tokens, that are not easily guessable.</li><li>Validate and sanitize user input, especially data related to object references, to prevent URL tampering or injection attacks.</li></ul><p><strong>Steps of Reproduction:</strong></p><ul><li>Navigate to the update user endpoint and send the request to the burp.</li><li>Try manipulating the request to GET and also provide the endpoint randomly.</li><li>Here in my case logging endpoint was able to give me the flag.</li></ul><p><strong>Evidences:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*5eEcVY2cCCwDVgIsUe67Rg.png" /><figcaption>Fig 15: User update endpoint</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/713/1*VI8oK0HXO2PbheKYehdfnA.png" /><figcaption>Fig 16: Viewing response of the api after providing the image link</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*Dw79U8dn5kTm4aGXlgEQgQ.png" /><figcaption>Fig 17: Navigating to the logging endpoint and viewing the response</figcaption></figure><p><strong>API4: Unrestricted Resource Consumption</strong></p><p><strong>Description:</strong></p><p>This application is vulnerable to unrestricted resource consumption since it doesn’t limits the use of it’s resources. Attackers exploit this weakness by intentionally consuming excessive resources, leading to a denial of service (DoS) condition. In a DoS attack, legitimate users are denied access or face significantly degraded performance because the system becomes overwhelmed and unable to handle legitimate requests.</p><p><strong>Impact:</strong></p><ul><li>As the system becomes overwhelmed with the excessive consumption of resources, it may become slow, unresponsive, or completely unavailable. This denies legitimate users access to the service, leading to downtime and loss of productivity.</li><li>Resource exhaustion attacks may serve as a diversion tactic for other, more damaging attacks.</li></ul><p><strong>Remedies:</strong></p><ul><li>Implement rate limiting and request throttling mechanisms to control the number of requests from individual clients.</li></ul><p><strong>Steps of Reproduction:</strong></p><ul><li>Navigate to the endpoint which retrieves the list of authors and send the request to Burp suite.</li><li>Send the request to intruder and set the author’s name in the payload.</li><li>Now try to check the response for each author.</li></ul><p><strong>Evidences:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*aP0y4hrvSqNRdsQL3br_9w.png" /><figcaption>Fig 18: Providing the different author names as an payload to brute force the author with sensitive data in their endpoint</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*vopSJVlN3QTRYb4G0mxxZA.png" /><figcaption>Fig 19: Analyzing the 200 response and finally getting the one with card details of the author</figcaption></figure><p><strong>API5: Broken Function Level Authorization</strong></p><p><strong>Description:</strong></p><p>This application fails to properly enforce access controls at the function or API level. It allows an attacker to bypass intended authorization restrictions and perform actions or access resources they are not supposed to. This condition is known as broken function level authorization. Properly implemented function level authorization would ensure that only authorized users with appropriate privileges can access these URLs. For instance, regular users might only be allowed to view profiles, while administrators can edit and delete profiles.</p><p><strong>Impact:</strong></p><ul><li>Attackers could modify data or settings that are meant to be controlled by authorized users only. This can lead to unauthorized changes in user profiles, configurations, or application behavior.</li><li>In cases where the function level authorization is not correctly enforced, attackers might elevate their privileges to perform administrative actions or access restricted parts of the application.</li></ul><p><strong>Remedies:</strong></p><ul><li>Ensure that access controls are implemented at the function level, both on the server-side and client-side. Verify the user’s identity and permissions before allowing them to access sensitive functions or resources.</li><li>Adopt RBAC principles to define roles and associated permissions. Assign users to appropriate roles based on their responsibilities and grant access to functions accordingly.</li></ul><p><strong>Steps of Reproduction:</strong></p><ul><li>Navigate to the website and try adding js/budle.js to the path.</li><li>Search for admin and view the json.</li><li>Navigate to the authentication api and send the request to the burp.</li><li>Try editing the header to /admin and view the response.</li></ul><p><strong>Evidences:</strong></p><p>For this I have tried to find a hidden path, just searching for the admin, gave me the path of admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*ORLxA_PpO7AJxQRcdFY7TA.png" /><figcaption>Fig 20: Navigating to the website and viewing the static js</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*yc3zEwUCVV1fqTXCI7EYUw.png" /><figcaption>Fig 21: Registration of new user</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*f1-ZC2t1SWGLlvTsaN6eLA.png" /><figcaption>Fig 22: User login</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*IQQVUKlQcEUox326x1mE6g.png" /><figcaption>Fig 23: Response of the logging action</figcaption></figure><p>Sending GET /api/admin to burp and adding authorization token:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*n367EWAdd3jL9I9GjPyaNA.png" /><figcaption>Fig 24: Trying various endpoint for the admin and finally getting the actual admin responses</figcaption></figure><p>Without any admin credentials just changing the request header gave me the flag. In real world scenario this would be the vulnerability where the attacker would be able to access the admin information without any credentials. So this application is vulnerable to broken function level authorization.</p><p><strong>API6: Unrestricted Access to sensitive business flow</strong></p><p><strong>Description:</strong></p><p>Here an unauthorized user or an attacker is able to gain unrestricted access to critical or sensitive parts of a business application or system. In this context, the term “business flow” refers to the series of interconnected steps and operations that represent essential business processes or transactions within an organization.</p><p><strong>Impact:</strong></p><ul><li>Unauthorized access to sensitive business flows may lead to data breaches, exposing confidential information such as customer data, financial records, trade secrets, and intellectual property. Data breaches can result in legal liabilities and damage the organization’s reputation.</li></ul><p><strong>Remedies:</strong></p><ul><li>Follow the principle of least privilege, granting users only the minimum access necessary to perform their specific tasks or responsibilities. Avoid providing excessive permissions.</li></ul><p><strong>Steps of Reproduction:</strong></p><ul><li>Navigate to the authentication endpoint and send the request to burp.</li><li>Try editing the endpoint to /admin and view the response.</li></ul><p><strong>Evidences:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*JjaIrKugmSfslCz6hmgNJg.png" /><figcaption>Fig 25: Viewing the response of the articles where the limit is 10</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*DDru1blELeptgsLzj0vWHg.png" /><figcaption>Fig 26: Viewing the response providing the limit to be 100000</figcaption></figure><p>When attackers exploit this vulnerability, they typically need to understand the business model supported by the API. They then identify sensitive business flows and automate access to them, causing harm to the business. The lack of a holistic view of the API’s business requirements contributes to the prevalence of this vulnerability, as developers may not fully understand the implications of the exposed sensitive flows.</p><p>As for business-specific impacts, exploitation of this vulnerability can hurt the organization in various ways. For example:</p><ul><li>Preventing legitimate users from purchasing a product: Attackers could manipulate the sensitive business flow related to purchases, leading to disruptions in the purchasing process for genuine customers, resulting in potential revenue loss for the business.</li></ul><p><strong>API7: Server Side Request Forgery</strong></p><p>I tried different endpoint that could be vulnerable of SSRF but none was vulnerable to SSRF.</p><p>It involves an attacker manipulating the server to make unintended requests to internal or external resources. SSRF attacks target the server to perform actions it was not designed to do, often leading to unauthorized access to sensitive data, abuse of internal resources, or even complete compromise of the server.</p><p>Here’s how SSRF works in the context of APIs:</p><ul><li>Vulnerable API Endpoint: An API endpoint accepts a user-supplied URL as input parameter. This URL is intended to fetch external resources like images, data, or perform legitimate actions.</li><li>Attacker Manipulation: The attacker exploits this input parameter to supply a malicious URL pointing to an internal or external server.</li><li>Server Misuse: The API server, unaware of the malicious intent, sends a request to the attacker-controlled URL, and the response is processed by the server.</li><li>Unauthorized Actions: Depending on the server’s permissions and network access, the attacker may perform unauthorized actions, such as accessing internal files, querying internal databases, or interacting with restricted services.</li></ul><p><strong>API8: Security Misconfiguration</strong></p><p><strong>Description:</strong></p><p>This application allows to view the key and values of database without any authentication. This type of vulnerability is considered one of the most common and critical security vulnerabilities, as misconfigurations can lead to unauthorized access, data breaches, and various other security incidents.</p><p><strong>Impacts:</strong></p><ul><li>Misconfigurations may enable attackers to modify or delete data, leading to incorrect or unreliable information, which can disrupt business operations and decision-making processes.</li></ul><p><strong>Remedies:</strong></p><ul><li>Implement Role-Based Access Control (RBAC) or Attribute-Based Access Control (ABAC) to enforce proper authorization and limit access to sensitive API endpoints based on user roles and permissions.</li></ul><p><strong>Steps of reproduction:</strong></p><ul><li>During composing the docker, you could have seen the redis database somewhere in the log.</li><li>Try to install redis cli and view the keys within the database.</li><li>We can view the key and value easily without any authentication.</li></ul><p><strong>Evidences:</strong></p><p>For the purpose of demonstration of this vulnerability, I have used redis-cli database remote and viewing the value of the available keys gave me the flag. Here I was not asked for any password for the access of keys so this represents the security misconfiguration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*8YkGirKD1c-qlGhNMvZdbg.png" /><figcaption>Fig 28: Connecting to the redis database of the application</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*yZtPGWJSXbzZrHssCorhaw.png" /><figcaption>Fig 29: Checking the key and value pairs of the database</figcaption></figure><p><strong>API9: Improper Inventory Management</strong></p><p><strong>Description:</strong></p><p>In most of the application, we find older version of APIs still in use. This kind of vulnerability allows the attacker to receive the credentials and information the old API was providing. This may lead to unauthorized access as well as unauthenticated access to business flows.This application is vulnerable to Improper Inventory Management I was able to navigate to older API just editing the request to older version.</p><p><strong>Impact:</strong></p><ul><li>Weak access controls or improperly configured permissions might allow unauthorized users to access sensitive inventory data. This could lead to data breaches or unauthorized changes to inventory records.</li></ul><p><strong>Remedies:</strong></p><ul><li>Deactivating unused APIs reduces the attack surface, minimizing the risk of security vulnerabilities. Unused APIs might have undiscovered or unresolved security flaws, and keeping them active could expose the system to potential exploitation.</li><li>If an unused API has sensitive or outdated data, deactivating it prevents unauthorized access to that data.</li></ul><p><strong>Steps of Reproduction:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*qDgfdGcP48Y4cIz-Qmv0mA.png" /><figcaption>Fig 30: Login request and response of the application</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*gsryB1BF5ZKLlbPTeOP0-Q.png" /><figcaption>Fig 31: Trying editing the request to previous version</figcaption></figure><p><strong>API10: Unsafe Consumption of APIs</strong></p><p>This refers to the unsafe integration and usage of APIs, particularly when interacting with third-party APIs. To effectively test and demonstrate this vulnerability, it would be ideal to have access to a third-party API that is known to have some security weaknesses or misconfigurations.</p><p>This vulnerability cannot be exploited in the lab environment since it doesn’t use any third party API. So, I will just try to explain this in simple words.</p><p>The security weakness in the target API lies in the fact that developers often trust and do not thoroughly verify the endpoints that interact with external or third-party APIs. This trust is based on assumptions that the external APIs have adequate security measures in place, such as transport security (encryption), authentication/authorization mechanisms, and input validation and sanitization. However, this trust might lead to overlooking potential vulnerabilities in these integrated APIs or services.The impacts of this vulnerability can be severe and varied. If an attacker successfully exploits this weakness, they might gain unauthorized access to sensitive information that the target API pulls from the compromised external APIs or services. This can result in data breaches and the exposure of confidential data.</p><p>Additionally, the attacker might conduct various forms of injection attacks against the target API through the compromised external APIs. Injection attacks could include SQL injection, command injection, or other forms of code execution vulnerabilities, which can lead to unauthorized control of the target API or even the underlying server. Furthermore, attackers might attempt denial-of-service (DoS) attacks against the target API by manipulating or disrupting the data flow from the compromised external APIs, impacting the availability and reliability of the target API’s services.</p><p><strong>Other vulnerabilities in the Application</strong></p><p><strong>Injection</strong></p><p><strong>Description:</strong></p><p>Injection attacks in APIs are a type of security vulnerability where an attacker exploits input validation or lack of proper sanitization in API parameters to inject malicious code or unauthorized data into the API, potentially gaining unauthorized access, manipulating data, or executing unintended actions. This application is vulnerable to injection attack as it doesn’t sanitize the user input and allows user to input any command on the body of the requests.</p><p><strong>Impacts:</strong></p><ul><li>Successful injection attacks can lead to unauthorized access to sensitive data, resulting in a data breach. Attackers can steal sensitive information such as user credentials, personal identifiable information (PII), financial data, or proprietary business data.</li></ul><p><strong>Remedies:</strong></p><ul><li>Validate and sanitize all input received from users or external sources before processing it in the application or passing it to the backend systems.</li><li>Use parameterized queries and prepared statements to prevent SQL injection attacks.</li><li>Avoid using user-supplied data directly in code execution or dynamic queries without proper escaping and encoding.</li></ul><p><strong>Steps of Reproduction:</strong></p><ul><li>Navigate to the debug endpoint and send it to burp.</li><li>Try giving the different command in the body section and see the responses.</li></ul><p><strong>Evidences:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*CmAYisG-Yv_1h_0UBXbRUg.png" /><figcaption>Fig 32: Providing the ifconfig in the command and viewing the response</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*sHhOTlr_CFkBPTV1GQjXFg.png" /><figcaption>Fig 33: Providing uptime in the command and viewing the result</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*SnceT2Ilywm0R5mDMpCiig.png" /><figcaption>Fig 34: Providing the uptime&amp;&amp;dir and finally getting the flag</figcaption></figure><p>Thank you for staying through the end !</p><p>Would love to hear your feedbacks and suggestions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c7e2cad8654" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[vAPI Walkthrough : API Security Top 10 2023]]></title>
            <link>https://medium.com/@thisislazaruss/vapi-walkthrough-api-security-top-10-2023-9cab20c9377?source=rss-d41bd127d601------2</link>
            <guid isPermaLink="false">https://medium.com/p/9cab20c9377</guid>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[shirish]]></dc:creator>
            <pubDate>Thu, 20 Jul 2023 10:03:09 GMT</pubDate>
            <atom:updated>2023-07-20T16:26:49.128Z</atom:updated>
            <content:encoded><![CDATA[<h3>vAPI Walkthrough : API Security Top 10 2023</h3><p>This is my first blog!</p><p>It’s been a week, I have been exploring API security. I came across <a href="https://github.com/roottusk/vapi">vAPI</a>, Vulnerable Adversely Programmed Interface which is Self-Hostable API that mimics OWASP API Top 10 scenarios in the means of Exercises.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*R4maUIsmi-0Mz0KanyPDuQ.png" /></figure><p>Here I am trying to explain the example of vulnerability as described by latest <a href="https://owasp.org/www-project-api-security/"><strong>API Security Top 10 2023</strong></a><strong>.</strong></p><p><strong>Setting up lab:</strong></p><ol><li>Download the vAPI Postman collection and vAPI_ENV environment from the <a href="https://www.postman.com/roottusk/workspace/vapi/overview">vAPI Public Workspace</a> .</li><li>Navigate to Postman and import the collections.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/354/1*VlKPPeP7C3ZhpkBwB-OPww.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/363/1*6i3dJvTscC-YXjRvzFeI2Q.png" /></figure><p>3. Setup variables for the collection</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lxi2qsOrWbBPaLSepKwEjQ.png" /></figure><p><strong>API1:2023 Broken Object Level Authorization</strong></p><blockquote>API1:2023 states that “ APIs tend to expose endpoints that handle object identifiers, creating a wide attack surface of Object Level Access Control issues. Object level authorization checks should be considered in every function that accesses a data source using an ID from the user.”</blockquote><p>For the demonstration of this we will try accessing the user details of other users just changing the ID value in the burpsuite.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_8YqYOUTUsn5LMhaWyJ1xA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-6EzWysTIjLp9W86bFBDIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WSpo46SNhkywK2bqbevRTg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0r-5hfKodiGczspnzjepTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qwCHWXTiYSghMHFkfhoyGA.png" /></figure><p>Also now we try to navigate to the user having ID 1, where the user would probably represent admin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-lAN3Qby2xb2kcfp5EbzqA.png" /></figure><p>This screenshots shows that we are able to view the other user details that are not authorized to us just by changing the ID value. This proves that vAPI is vulnerable to Broken Object Level Authorization.</p><p><strong>API2:2023 Broken Authentication</strong></p><blockquote>API2:2023 states that “Authentication mechanisms are often implemented incorrectly, allowing attackers to compromise authentication tokens or to exploit implementation flaws to assume other user’s identities temporarily or permanently. Compromising a system’s ability to identify the client/user, compromises API security overall.”</blockquote><p>For the demonstration of this vulnerability, we don’t have any initial email or password set during the creation of user. So we randomly type the email and password and send a request to burp and we send the request again to the intruder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LCfB-XUCka6TFBJ7l1Iojw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ms4JuiIIrkTIYIuMSz-cxg.png" /></figure><p>We see that the payload position is already set for email and password.</p><p>Also, vAPI contains a list of comma separated emails and corresponding passwords. In my case the list is in ~/lab/vapi/Resources/API2_CredentialStuffing/creds.csv location. So, I moved this to vAPI directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*3Mk1Ba385KeHPYXEw78HmA.png" /></figure><p>We also select pitch fork type of attack in this case. Pitch fork attack iterates through a different payload set for each defined position. Payloads are placed into each position simultaneously. The total number of requests generated in the attack is the number of payloads in the smallest payload set. The Pitchfork attack is useful where an attack requires different but related input to be inserted in multiple places within the request.</p><p>Next for the payload we load the creds.csv .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7QBxBCvv5Zd82onUkShqEA.png" /></figure><p>For the payload processing section, choose Match/replace option and add, <strong>,([^\s,]+)</strong> to the match regex and leave replace with blank. For payload set 2 add<strong> ([\w\.-]+@[a-zA-Z\d\.-]+\.[a-zA-Z]{2,}),</strong> to the match, leave replace blank and start attack. Also remember to Uncheck the <strong>URL-encode these characters</strong> box for both positions, then start the attack.</p><p>I have created this regex using the <a href="https://regex101.com/">https://regex101.com/</a> . You can also make yours regex in other use cases using the same site.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*yx9Ww9YqLaJzhTx-kbw4hg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/1*JXS8vnBFK0mctA2RDPoyLQ.png" /></figure><p>Sort the result according to status and view the email and password where the email and password matches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*mmlEopI9PkVcBN8zG0vU4g.png" /></figure><p>Using the credentials we can get the token as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*I24Vvk8jXP9k20aIWrhejQ.png" /></figure><p>Also,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EXLtN_ebUQTBCjr9GjmIng.png" /></figure><p>These screenshots show us that we are able to authenticated without knowing the password of the user by just bruteforcing it.</p><p><strong>API3:2023 Broken Object Property Level Authorization</strong></p><p>Broken object property level authorization refers to a security weakness or vulnerability in an API where the access control for individual properties of an object is not properly enforced or validated<strong>.</strong> In other words, it means that the API allows unauthorized access to certain sensitive or private properties of an object, which should only be accessible to specific users or roles.</p><p>This category combines <a href="https://owasp.org/API-Security/editions/2019/en/0xa3-excessive-data-exposure/">API3:2019 Excessive Data Exposure</a> and <a href="https://owasp.org/API-Security/editions/2019/en/0xa6-mass-assignment/">API6:2019 — Mass Assignment</a>, focusing on the root cause: the lack of or improper authorization validation at the object property level. This leads to information exposure or manipulation by unauthorized parties.</p><p>Let’s create a user first and try to get the details of created user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g3fezcthRlKJm_tefYOy3A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yQ7NIH9wxAOR6cG95uU8hw.png" /></figure><p>Now, let us try to give the credit during the user creation process. I was unable to implement the PUT method for this endpoint so I tried giving the credit property with a value during creation of new user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*E8KMHPKAZ3pI8CayCaTDEg.png" /></figure><p>During fetching the new user, we could see that the credit of the user is set to the given value during the creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8h36AjaBD8OOlkdQiIhhCw.png" /></figure><p>In the context of APIs, an object is a data structure that contains various properties or attributes. In this case credit is a property of user which should not have been able to be edited by user but here a user can define the property and give a value to it during creating user. The level of authorization should have ensured that users only have access to the properties they are allowed to use but in this case a user was successful to view the credit while retrieving user details and edit it. As a combination of which a user was successfully able to edit the property and increase their credit.</p><p><strong>API4:2023 Unrestricted Resource Consumption</strong></p><blockquote>API4 sates that “Satisfying API requests requires resources such as network bandwidth, CPU, memory, and storage. Other resources such as emails/SMS/phone calls or bio metrics validation are made available by service providers via API integrations, and paid for per request. Successful attacks can lead to Denial of Service or an increase of operational costs.”</blockquote><p>For the demonstration of this vulnerability, navigate to the API4 of the collection and we try requesting to send the OPT code to a mobile phone. This logs us into the user account whose cell phone number we provided. In the response body, we see that a 4 digit code has been sent to that user’s device. Since we don’t have the user’s device, we don’t have the OTP code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZTTRZ09OoDseRD2R3Dz7Lg.png" /></figure><p>But we can work around with Burp to get the OTP code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ax_i69Ta1APYYB8vzjjlqA.png" /></figure><p>But viewing the response of the request, we could see that the OTP is invalid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WYrqmDuz7ZOtAe_71iWeuQ.png" /></figure><p>Now we should try to fuzz around with the help of intruder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*saTLjiKwxvLunNRgua4shQ.png" /></figure><p>Now we select the snipper attack and edit the payload section where the details are added as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VVZyuoUYU3pPeXM98cSc_w.png" /></figure><p>Now we start attack and wait for the response where the OTP gives the 200 status.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*tRmBGyjr9ODWqDkeRj_Ebw.png" /></figure><p>Now we go back to Postman and select the Get Details query from the list. Paste the key value we found above into the Authorization Token field and send the query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ML_02CwsePk6Xv5ZVJzhIA.png" /></figure><p>The app should have some form of limiting that would’ve stopped us for sending thousands of request to find the OTP code that matches. This proves that the vAPI is vulnerable to unrestricted resource consumption.</p><p>This kind of vulnerability exploitation can lead to DoS due to resource starvation, but it can also lead to operational costs increase such as those related to the infrastructure due to higher CPU demand, increasing cloud storage needs, etc.</p><p><strong>API5:2023 Broken Function Level Authorization</strong></p><blockquote>API5 states that “Complex access control policies with different hierarchies, groups, and roles, and an unclear separation between administrative and regular functions, tend to lead to authorization flaws. By exploiting these issues, attackers can gain access to other users’ resources and/or administrative functions.”</blockquote><p>At first we create a user and try getting it’s details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gEDm_aCf-hIYvSPC-XxRXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WezHL69nXe-cyE0xCYID3Q.png" /></figure><p>For the demonstration of this vulnerability, we try to retrieve admin details using multiple endpoints guessing. Here are some of the endpoints I have tried guessing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eIiYpHxENLc3VLOlIPWAPw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3lAd8I3RScEtWMniZvAoXw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*whbY2XVCu5jT9hRk43RxfQ.png" /></figure><p>After multiples trying, when the user/something_something didn’t work, I tried to dump all the users data. In this case the admin details were able to view easily. This proves that the API is vulnerable to Broken Function Level Authorization.</p><p><strong>API6: Unrestricted Access to Sensitive Business Flows</strong></p><blockquote>API6 states that “APIs vulnerable to this risk expose a business flow — such as buying a ticket, or posting a comment — without compensating for how the functionality could harm the business if used excessively in an automated manner. This doesn’t necessarily come from implementation bugs.”</blockquote><p>This vulnerability cannot be exploited in the lab environment. So, I will just try to explain this in simple words.</p><p>The impacts of this vulnerability can be significant and varied. Since attackers can gain access to sensitive business flows, they can exploit them in ways that harm the business. The prevalence of this issue is considered “Widespread,” which means it is a common problem faced by many APIs. The detectability of this vulnerability is “Average,” indicating that it may not be immediately apparent or easy to identify.</p><p>When attackers exploit this vulnerability, they typically need to understand the business model supported by the API. They then identify sensitive business flows and automate access to them, causing harm to the business. The lack of a holistic view of the API’s business requirements contributes to the prevalence of this vulnerability, as developers may not fully understand the implications of the exposed sensitive flows.</p><p>As for business-specific impacts, exploitation of this vulnerability can hurt the organization in various ways. For example:</p><ul><li>Preventing legitimate users from purchasing a product: Attackers could manipulate the sensitive business flow related to purchases, leading to disruptions in the purchasing process for genuine customers, resulting in potential revenue loss for the business.</li><li>Inflation in the internal economy of a game: If the API relates to a gaming platform, attackers may exploit sensitive flows to create artificial resources or in-game currency, causing an imbalance in the game’s economy and negatively affecting the gameplay experience for other users.</li></ul><p><strong>API7: Server Side Request Forgery</strong></p><blockquote>API7 states that “Server-Side Request Forgery (SSRF) flaws can occur when an API is fetching a remote resource without validating the user-supplied URI. This enables an attacker to coerce the application to send a crafted request to an unexpected destination, even when protected by a firewall or a VPN.”</blockquote><p>For this we navigate to the Arena folder and ServerSurfer sub folder and send the GET request.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*a9C5-ha1W5MNxSsITBUNOw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*-uC8HFQriuD86ybz2OxnAw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*TNwEJpeIXQWj301QX3jr2g.png" /></figure><p>Here, I have tried switching to <a href="https://webhook.site/">https://webhook.site</a>. Here we will set a text to be sent back whenever a query is made to a specific web address. vAPI application displays the data returned by whatever URL we set as the value of the GET parameter in this request. In this case, it was just a string. In a different scenario it could have been a malicious payload. This is a SSRF vulnerability.</p><p><strong>API8: Security Misconfiguration</strong></p><blockquote>API8 states that “APIs and the systems supporting them typically contain complex configurations, meant to make the APIs more customizable. Software and DevOps engineers can miss these configurations, or don’t follow security best practices when it comes to configuration, opening the door for different types of attacks.”</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwR2lHbgOG3igUQb0j7low.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hmjO_xioLitzg5CWqsaMKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hLlVEtFOkIE5aQCrH0hZqg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3qy6EdH9D6XjUfrcnsV12A.png" /></figure><p>We will notice the following response headers:<br> Access-Control-Allow-Origin: *<br> Access-Control-Allow-Credentials: true</p><p>This reveals the CORS policy for this request is improperly set, meaning that it could be sent from a third party web app to access this resource and retrieve the user’s id, username, password and authkey.</p><p>To demonstrate it, we send the request to Repeater and add a custom Origin: request header.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hP1cOLVOnVk1-aICohA2hA.png" /></figure><p>Here the Origin : * made the exploitation easy as we can any site address and send the request. This represents security misconfigurations.</p><p><strong>API9: Improper Inventory Management</strong></p><blockquote>API9 sates that “APIs tend to expose more endpoints than traditional web applications, making proper and updated documentation highly important. A proper inventory of hosts and deployed API versions also are important to mitigate issues such as deprecated API versions and exposed debug endpoints”</blockquote><p>For the demonstration of this vulnerability, we navigate to the API9 of the collection and post login and send the request to burp. Sending it to repeater and viewing the response we could see that the api has rate limitation of 5 and remaining limit 4 which means we can only try for the pin for 4 times now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jvOxn_8g3mLX6_g2b-B1Yw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hn0C5b4tdqG4CVmRE5niuA.png" /></figure><p>Trying to viewing the v1 api by just editing the request gave me the details of older version of the v2 api . Also we couldn’t see any of the rate limitation in this case . So, we can give as much as request we would like to for the api. I have used <a href="https://github.com/ffuf/ffuf">ffuf </a>for this case for easy brute force of the pin. I have used this <a href="https://gist.github.com/kleo/79a5d946e5ea18c5ba5a84a23a4d88fc">wordlist</a> to predict the pin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SXQwlnOy9yNiH6FwIGWcug.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ShENY-YlTdkDWasitrhMEA.png" /></figure><p>The ffuf result gave me ‘1655’ as the pin result with status 200 of the request. Later, I have tried to give the pin in the request as a result of which I was able to access the details of the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/657/1*ZhW2giC5NIbRUfNKkq2InA.png" /></figure><p>vAPI is vulnerable to improper inventory assessment as the API developer have not managed the previous version of API and we user are able to access it and view the details.</p><p><strong>API10: Unsafe Consumption of APIs</strong></p><blockquote>API10 states that “Developers tend to trust data received from third-party APIs more than user input, and so tend to adopt weaker security standards. In order to compromise APIs, attackers go after integrated third-party services instead of trying to compromise the target API directly.”</blockquote><p>This refers to the unsafe integration and usage of APIs, particularly when interacting with third-party APIs. To effectively test and demonstrate this vulnerability, it would be ideal to have access to a third-party API that is known to have some security weaknesses or misconfigurations.</p><p>This vulnerability cannot be exploited in the lab environment since it doesn’t use any third party API. So, I will just try to explain this in simple words.</p><p>The security weakness in the target API lies in the fact that developers often trust and do not thoroughly verify the endpoints that interact with external or third-party APIs. This trust is based on assumptions that the external APIs have adequate security measures in place, such as transport security (encryption), authentication/authorization mechanisms, and input validation and sanitization. However, this trust might lead to overlooking potential vulnerabilities in these integrated APIs or services.The impacts of this vulnerability can be severe and varied. If an attacker successfully exploits this weakness, they might gain unauthorized access to sensitive information that the target API pulls from the compromised external APIs or services. This can result in data breaches and the exposure of confidential data.</p><p>Additionally, the attacker might conduct various forms of injection attacks against the target API through the compromised external APIs. Injection attacks could include SQL injection, command injection, or other forms of code execution vulnerabilities, which can lead to unauthorized control of the target API or even the underlying server. Furthermore, attackers might attempt denial-of-service (DoS) attacks against the target API by manipulating or disrupting the data flow from the compromised external APIs, impacting the availability and reliability of the target API’s services.</p><p>Thank you for staying through the end !</p><p>Would love to hear your feedback.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9cab20c9377" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>