Exploiting Exposed Tokens and API Keys: Edition 2023

Kongsec
3 min readJun 24, 2023

--

Introduction: Welcome to my 14th article on exploiting exposed tokens and API keys. In this edition, I will discuss how to approach and exploit exposed API keys or tokens, helping you enhance your exploitation mindset. Before proceeding, I recommend reading the first part of this series, as this article builds upon the concepts discussed previously. Let’s dive in!

Finding Exposed Information: To begin, you can use various techniques to discover exposed information, such as using the Nuclei tool with specific templates, conducting GitHub recon, performing source code reviews, and exploring multiple extensions. These methods will assist you in uncovering potential vulnerabilities.

Scenario: Exposed API Key in a JS file or GitHub Recon Once you have identified an exposed API key in a JavaScript (JS) file or through GitHub recon, follow these steps to proceed with the exploitation process:

Step 1: Identify the Key Name or Service Name Manually inspect the code or relevant resources to find the name of the exposed API key. For example, let’s assume the key name is “filepicker_key.”

Step 2: Conduct a Google Search Perform a Google search using the key name followed by the terms “api docs curl.” In our case, the search query would be “filepicker_key api docs curl.” This will help you find the official API documentation and examples that involve using cURL commands.

Step 3: Read the API Documentation and Identify cURL Commands Thoroughly review the API documentation you found in the previous step. Look for sections or examples that demonstrate the usage of cURL commands for interacting with the API using the specific key. Understanding the API’s functionalities and available endpoints is crucial for successful exploitation.

Step 4: Exchange Key with cURL Command and Observe the Response Replace the placeholder values in the cURL command from the API documentation with the exposed API key you discovered. Execute the modified cURL command and analyze the response you receive. This step allows you to verify whether the key is valid and if you can perform actions or retrieve sensitive information.

Understanding the Impact: Depending on the privileges associated with the exposed API key, you need to assess the potential impact of its exploitation. Consider factors such as the scope of actions you can perform, the sensitivity of the data accessible through the API, and the potential harm it could cause to the target domain or service.

Note: Reporting and Impact Assessment When reporting a vulnerability, it is essential to provide a detailed explanation of the exploit and its impact. Remember, a vulnerability report without a demonstrated exploit or proof of concept may not be accepted. Additionally, if the API documentation is not available, making it difficult to demonstrate the exploit, it might not be considered a valid bug. Be prepared to answer questions from third parties regarding how the vulnerability could harm the domain or service.

Conclusion: In this article, we explored the process of exploiting exposed tokens and API keys. By following the steps outlined above, you can effectively leverage the discovered keys to interact with the API and assess the potential impact of their exploitation. Remember to prioritize reporting vulnerabilities that come with a demonstrated exploit and to provide clear explanations of the potential harm caused by the vulnerability.

Thank you for reading, and I hope you found this article beneficial for the bug bounty community.

--

--

Kongsec
Kongsec

Written by Kongsec

#kongsec | Solo Bounty Hunter | Function Exploits and Report Crafting | Bikes | Not a XSS guy | Own views | Bugcrowd Top 100 l Top 10 P1 warriors | Biker

Responses (1)