A Study On API Security Pentesting
A Study On API Security Pentesting
A Thesis
presented to
In Partial Fulllment
by
Hadi Asemi
June 2023
© 2023
Hadi Asemi
ALL RIGHTS RESERVED
ii
COMMITTEE MEMBERSHIP
iii
ABSTRACT
Hadi Asemi
Application Programming Interfaces (APIs) are essential in the digital realm as the
tems, allowing them to work together eortlessly and share data. APIs are used in
the security of APIs is critical to ensure data security, privacy, and more. There-
fore, the security of APIs is not only urgent but mandatory for pentesting APIs at
every stage of development and to catch vulnerabilities early. The primary purpose
of this research is to provide guidelines to help apply existing tools for reconnais-
sance and authentication pentesting. To achieve this goal, we rst introduce the
basics of API and OWASP’s Top 10 API security vulnerabilities. Secondly, we pro-
pose deployable scripts developed for Ubuntu Debian Systems to install pentesting
tools automatically. These scripts allow future students to participate in API secu-
rity courses and conduct API security pentesting. API security pentesting, regarding
reconnaissance, passive and active approaches are introduced with dierent tools
iv
ACKNOWLEDGMENTS
have been the bedrock of my journey. Their encouragement and sacrices have fueled
my aspirations, and I am profoundly thankful for the sacrices they’ve made to ensure
my education. Their constant belief in my potential has been a guiding light, and I
growth.
Dongfeng Fang, whose guidance and mentorship have been invaluable throughout this
time and eort she invested in imparting knowledge, challenging my perspectives, and
mark on my academic journey, and I am indebted to her for her unwavering support.
In addition, I want to thank my committee Dr. Brue DeBruhl, and Dr. Devkishen
Sisodia for their support, expertise, and constructive feedback. Their dedication has
Finally, I would like to thank friends and classmates whose steadfast support, en-
ney. Your kindness and faith in my abilities have been a driving force, propelling me
v
TABLE OF CONTENTS
Page
LIST OF TABLES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x
LIST OF FIGURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
CHAPTER
1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1.1.1 REST . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1.1.2 SOAP . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.1.3 GraphQL . . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.2.1 E-commerce . . . . . . . . . . . . . . . . . . . . . . . 4
1.1.2.4 Stripe . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.1 Condentiality . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2.2 Integrity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.2.3 Availability . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
1.3 Breaches . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.3.1 Coinbase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
vi
1.3.4 Venmo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.3.5 Instagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.3.6 Bumble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.3.7 T-Mobile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.3.8 OPTUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.4 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.5 Contribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.1 Tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.1.1 Burpsuite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.1.2 Ffuf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
vii
3.1.3 Wfuzz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.1.5 Zaproxy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.1.7 Postman . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
3.1.8 Amass . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.2.1 Ansible . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.2.2 Jinja . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.1.1 Passive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.1.1.4 Shodan: . . . . . . . . . . . . . . . . . . . . . . . . . 64
4.1.1.5 Amass: . . . . . . . . . . . . . . . . . . . . . . . . . 65
4.1.2 Active . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
viii
4.1.2.2 Burp Suite . . . . . . . . . . . . . . . . . . . . . . . 72
4.1.3 Gobuster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
4.2 Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
4.2.1.1 Wfuzz . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.2.1.2 Ffuf . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
5.1 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
BIBLIOGRAPHY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
ix
LIST OF TABLES
Table Page
3.1.11.1Rustscan vs Nmap . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
x
LIST OF FIGURES
Figure Page
1.1.0.1 Communication between devices and backend with the help of API 2
xi
4.1.2.3 Burp Suite intercept creating account . . . . . . . . . . . . . . . . . 73
4.2.3.2 Authentication with website and get token with Burp Suite . . . . 84
xii
Chapter 1
INTRODUCTION
and tools for building software applications that allow dierent software systems to
It is a way that software applications talk to each other and exchange data. These are
three dierent types of API communication: a web API (which uses the HTTP/HTTPS
protocol to send and receive data), a database API (which allows the software to ac-
cess and manipulate data in a database), or a hardware API (which enables software
to communicate with hardware devices). APIs are widely used for many applications,
such as the weather app or your stock app on your phone, which communicates with
When working with APIs, it’s essential to consider both the client and server as-
pects [6]. The client is the application that runs on each device and sends the request,
while the backend responds to that request. As you can see in the diagram in 1.1.0.1.
The device sends a request, and the backend server gets the information from the
1
Figure 1.1.0.1: Communication between devices and backend with the help
of API
protocols while initiating API requests [5]. In this section, I will be discussing the
1.1.1.1 REST
that facilitates communication between a client and server. This design can be im-
appropriate header, users can obtain the information they require [14]. The infor-
mation obtained through HTTP can be in dierent formats, such as JSON, HTML,
XML, or plain text. The REST API adheres to the CRUD functions: create, read,
update, and delete. By utilizing a stateless REST API, you can signicantly enhance
the performance and scalability of your system. The beauty of this approach is that
it eliminates the need for the server to keep track of the client’s state or previous
seamless scalability that can be eortlessly managed, updated, and reused without
2
adversely impacting the system’s overall functionality. With a stateless architecture,
you can build a rock-solid and highly adaptable system that can easily accommodate
1.1.1.2 SOAP
Simple Object Access Protocol (SOAP) is a technology widely used for communication
between operating systems using HTTP and XML [15]. It stands for Simple Object
Access Protocol and is known for its extensibility, neutrality, and independence. With
SOAP, developers can easily maintain accounts and searches using any programming
language they prefer. In table 1.1.1.1 you can see dierence between SOAP and REST
API.
Has specic
Standards Does not have ocial standards due to its architectural style.
standards and protocols.
Functionality Limited to HTTP and XML. Utilizes uniform resource locator (URL) and HTTP.
Relies on service
Business Logic Utilizes URL interfaces (/WeatherService).
interfaces like @WebService.
Requires more
Bandwidth Usage Uses less bandwidth.
bandwidth due to XML payload.
Description Language Uses Web Services Description Language. Uses Web Application Description Language.
Implementation Ease Requires adherence to specic standards. Easier to implement using specic programming languages.
Rules and Standardization Must follow particular rules for standardization. Doesn’t require as many
3
1.1.1.3 GraphQL
Facebook created GraphQL, a query language that enables the creation of client
applications using an intuitive and exible syntax [16]. GraphQL is a data query
language that allows users to request specic data sets tailored to their needs. This
contrasts REST APIs, which typically return a xed data set. GraphQL’s exibility
makes it a good choice for mobile apps, as it can reduce the amount of data that
can scale to handle more requests and data. GraphQL uses a single URL for fetching
and mutating data, making it easier to maintain than REST APIs, which require
multiple endpoints. GraphQL is a powerful and exible data query language that can
1.1.2.1 E-commerce
E-commerce refers to buying and selling goods, products, or services over the Inter-
net. Excellent examples are Amazon, Best Buy, and Shopify. APIs play a vital role in
shipping, and logistics services for accurate tracking and inventory management, order
management systems for streamlined processing, CRM systems for personalized cus-
tomer experiences, social media platforms for marketing and engagement, review and
4
and more. These APIs allow e-commerce platforms to seamlessly connect with var-
ious services, enhance functionality, and provide a seamless shopping experience for
APIs have revolutionized the banking system in how users communicate with the
server to perform transactions, deposit checks, check balances, and authenticate their
identity. This integration has made banking more accessible, convenient, and faster.
In addition, with the power of APIs, users can now enjoy the luxury of banking from
their mobile applications, eliminating the need to visit the bank physically. As a
result, using the API is both time-saving and a more cost-eective solution for banks
The Epic electronic health record (EHR) software from Epic Systems Corporation
uses APIs to provide seamless integration and interoperability across the medical
and improve care coordination, APIs are used to share data with external systems,
[20]. Patients may access their health information and communicate with healthcare
professionals. APIs assist clinical decision support tools, integrate telemedicine and
remote monitoring platforms, enable data analytics and reporting, and make it easier
for third parties to interface with internal systems. They also allow interoperability
with external systems like health information exchanges. APIs are used by Epic and
other medical and health systems to facilitate data sharing, teamwork, and better
5
patient care. As a result, the security of this application is in high priority because if
doctors can not access patients’ records, it can be caused put the life of the patients
in danger.
1.1.2.4 Stripe
take online payments securely. APIs handle the basic payment processing operations,
applications. This integration will enable clients to pay via various methods, while
To ensure that our API is secure, we must consider three essential pillars of security:
condentiality, integrity, and availability, commonly called CIA. In this section, I will
1.2.1 Condentiality
6
1. Insucient authentication and authorization: To maintain security, we
cryptions prevent attackers from intercepting the network and accessing the
data being transmitted. An attacker could easily sni the packet without en-
data, such as login credentials, date of birth, and even social security numbers.
To avoid data breaches and ensure condentiality, this data must be protected.
One ecient strategy is to ensure secure user data storage by putting strong
encryption measures in place for servers and databases that handle such data.
and make it far more dicult for unauthorized individuals to access and utilize
sensitive user data. Optimizing encryption may improve overall security posture
that only authorized entities can access sensitive data. Additionally, employ-
7
can further enhance the security posture of the API, limiting access to specic
tems should be in place for APIs to identify and react to unauthorized access
monitoring.
1.2.2 Integrity
tions, tampering, or data corruption, which can have severe consequences for systems,
applications, and users relying on the API. A study by Mendoza et al. (2018) found
that many mobile apps tidy up user input within the app, but if this diers from the
server, it can pose signicant security risks [17]. In addition, hackers can manipulate
the data by identifying the API endpoint, enabling them to purchase items without
payment. This underscores the importance of maintaining data integrity. In this sec-
tion, I will be discussing various vulnerabilities that have the potential to compromise
to make sure that user-provided data adheres to the desired format and fullls
the relevant requirements. On the other hand, sanitization entails removing any
8
put. By validating and sanitizating the input we can metigate SQL injectection,
inactivity.
break client integrations and cause integrity issues. For example, we patch the
older version’s vulnerabilities in the newer one, but the other version is still
available. In that case, the attacker can still use the older version to attack our
1.2.3 Availability
Authorized users must have uninterrupted access to the application, known as avail-
ability. This is because any disruptions caused by attackers can lead to service
outages, performance issues, or denial of service. This section covers some of the
the API infrastructure by sending many fake requests, which can disrupt the
service. To reduce the impact of these attacks, it’s vital to use DDoS protection
methods like rate limiting, trac ltering, and load balancing. In addition,
9
using services like Content Delivery Networks (CDNs) can also help by dis-
storage can result from improper management of APIs, making them subject to
attacks. Adopting measures like input validation, rate limitation, and resource
numbers, response times, and other resource utilization criteria is also advised
API that can withstand any attempts of hacking or unauthorized access. It is crucial
to prioritize security and testing, even if it means taking a little extra time to deliver
the product. In the long run, it will save a lot of time and money that could be lost
due to a security breach. So, let’s prioritize security while developing applications to
1.3 Breaches
with businesses big and small falling prey to cybercriminals. This especially worries
smaller companies, as they often need more resources to combat such attacks. The
root cause of these security breaches is often the pressure to meet deadlines and
API development is divided into two groups: the engineering team, which may lack
security expertise, and the security team, which may lack API knowledge [19]. To
prevent such incidents, developers must prioritize secure coding and ensure that APIs
10
themselves from potential security threats and safeguard their customers’ sensitive
plays a vital role. This section will discuss the recent security breaches in the past
few years.
1.3.1 Coinbase
On February 11th, 2022, the Twitter account reported that they had discovered a
potential vulnerability that could have signicant market implications for Coinbase.
Specically, it was found that the Retail Brokerage API endpoint was missing a logic
validation check, which allowed users to submit trades to a specic order book using
a mismatched source account. In this vulnerability, users can scrape the API calls,
manipulate four critical parameters in the API call, and sell the crypto they did
not own to the user [7]. This vulnerability is Broken Object Level Authorization
(BOLA), mentioned in the OWASP top 10 API vulnerability. This issue highlights
and vulnerabilities.
The US Postal Service (USPS) had a aw in its Informed Visibility program that
could have exposed the personal data of around 60 million users. Security expert
Brian Krebs discovered that the USPS API allowed users to request changes to other
accounts without checks to prevent unauthorized access. While passwords were not
exposed, spammers and phishing attackers could have exploited the vulnerability by
building up mass-targeted spam [8]. In addition, the API allowed users to convert
accounts into Informed Visibility business accounts and vice versa, which could have
11
created issues for the USPS’s largest customers. This is another Broken Object Level
Authorization.
A security aw was discovered, which allowed unauthorized access to the private ac-
count information of ride users. The open-source API permitted requests for user
data without any authentication. This exposed four million user accounts, including
those marked as private, such as Joe Biden’s. Despite the severity of the situa-
tion, the company failed to respond for 90 days [9]. However, the vulnerability was
include two OWASP top 10 such as Broken Object Level Authorization and Broken
Authentication.
1.3.4 Venmo
Venmo is a popular app for sending and receiving money, with a live feed of trans-
actions being made by strangers displayed on the home page. A hacker discovered
that the data for this feed was accessible through a public API endpoint, meaning
that anyone could make a GET request to see the latest 20 transactions made on
the app by anyone around the world, even outside the app, with no authorization
required. The hacker scraped this data and found that they could download 115,000
transactions daily, leading them to question the ease with which they could amass
an extensive collection of people’s nancial activity. The hacker discovered that the
public data is not as innocuous as it might seem. It can reveal information such as
which app is used for business on Venmo, which can be useful for nefarious purposes
such as phishing for Apple ID credentials [10]. These vulnerabilities broked the three
12
OWASP top 10 API security, such as Broken Authentication, Broken Object Level
1.3.5 Instagram
It’s been reported that Instagram recently experienced a security breach that allowed
hackers to access the personal information of high-prole users. The hackers exploited
the Application Programming Interface (API) bug to steal email addresses and phone
numbers. A 6-digit code is required to reset accounts, which the hackers could guess
using the API. While the guesses were limited to 200 per IP, researchers discovered
that by rotating through 5,000 IPs, the hackers could take over any account they
wanted [11]. The security breach was caused by two vulnerabilities in the API -
1.3.6 Bumble
It has come to light that there was a signicant breach in the security of a specic
API, which allowed unauthorized access to the details of a staggering 95 million user
accounts. Even more concerning is that incrementing the IDs led to scrapping the
entire database. This breach also enabled the exact location of users to be calculated
through triangulation. Another issue that arose was that paid features could be
enabled without the proper privileges. As a result of these vulnerabilities, there were
and Broken Function Level Authorization. This is a severe problem that needs to be
addressed immediately.
13
1.3.7 T-Mobile
Recently, a security breach occurred on January 5th, where an attacker gained access
to 37 million customer accounts on postpaid and prepaid plans due to a weak API.
Without any authentication, the attacker could get users’ data. T-Mobile has stated
that only certain personal information such as names, billing addresses, emails, phone
1.3.8 OPTUS
who successfully obtained and collected 9.8 million user details [12]. Alongside this
breach, the attacker also issued a ransom demand of $1 million. The compromised
data consisted of driver’s licenses, Medicare IDs, names, phone numbers, and email
addresses. This security breach occurred due to the absence of authentication pro-
tocols on API endpoints and the company’s failure to enforce restrictions on data
resource usage.
1.4 Motivation
Application Programming Interfaces (API) are growing in various areas like IoT,
websites, medical data, and banking. As a result, it is essential to ensure that the
that security by design for API implementation. Unfortunately, many API develops
lack knowledge of security and privacy. Moreover, pentesting is not well applied
before the APIs are used. One common API vulnerability is broken object-level
authorization (BOLA), which controls users’ access to resources. Exposures can occur
14
when users can access other users due to authorization aws. For instance, the UPS
hacks were due to BOLA, where users could authenticate with the server and pivot
1.5 Contribution
tributions:
tween OWASP’s top 10 API security concerns in 2019 and the latest trends
2023. This examination sheds light on the evolving landscape of API security
congure Ubuntu operating systems, equipping them with the full suite of pen-
ture exibility paves the way for future scalability and allows professors to
15
5. Addressing Critical API Security Challenges: My comprehensive re-
Dorking, Git Dorking, Wayback Machine, Shodan, Amass, and TrueHog. For
the 2019 and 2023 editions. Chapter 3 introduces and explains a suite of penetration
testing tools designed explicitly for APIs while culminating in unveiling an Ansible
delves even more profound, oering an in-depth analysis of each tool’s ags and
visionary course for future research in API security, and nally, Chapter 6 synthesizes
the thesis’s ndings, insights, and contributions, providing a profound conclusion that
underscores the research’s signicance and impact in the realm of API security.
16
Chapter 2
This chapter examines the top ten API security issues identied by the OWASP (Open
Web Application Security Project). The Open Online Application Security Project
on online application security. The OWASP top ten API security vulnerabilities
emphasize the most severe dangers connected with APIs and provide mitigation ad-
vice [24].
Our comprehensive examination will delve into the intricacies of each of the OWASP
top ten API security issues, unraveling subjects such as faltering authentication and
absence of robust resource and rate limits, among others. Emphasizing the critical
rity experts with knowledge about these issues empowers them to proactively identify
In addition, we will compare the 2019 and 2023 versions of the OWASP top 10 API se-
curity issues. This comparison will illuminate any new patterns or threats in the API
security landscape. It will provide vital insights into how the security landscape has
developed, allowing rms to keep current on best practices and security procedures.
17
2.1 API I: Broken Object Level Authorization (BOLA)
the code level to guarantee users only access authorized objects [24]. This security
measure is crucial in protecting API endpoints from unauthorized access and is widely
The object-level authorization ensures users have the appropriate privileges to ac-
controls at the code level, organizations can prevent unauthorized users from manip-
users.
One of the most prevalent security vulnerabilities in the API landscape is the ex-
To illustrate this vulnerability, let’s consider a scenario where two users, A and B, are
sequently, the API mistakenly grants access to user B’s private data, which should
tion can have severe consequences, ranging from unauthorized disclosure of sensitive
Developers and security practitioners must implement robust access control mecha-
This includes carefully validating and sanitizing input parameters, utilizing proper
18
authentication and authorization frameworks, and regularly auditing and reviewing
vital is the treatment of Forgot password / reset password processes, which should
ening the initial line of defense, stringent password policies should be enforced by
tiality, passwords must never be stored in plain text, devoid of encryption, weakly
hashed, or reliant on feeble encryption keys. The API can eectively thwart potential
A great guideline provided by OWASP Cheat sheet would help with authentication
19
2.3 API III: Excessive Data Exposure
Exposing sensitive data by mistake is a big concern in software design. Despite our
eorts to hide this data on the user’s device, clever attackers can still nd ways to
get it. They might spy on or capture the data sent between the user and the server.
This can lead to them accessing critical information they shouldn’t have access to.
Imagine an online store where someone who wants to cause trouble could add a
harmless comment to an online chat. When the server replies, it might accidentally
give away essential details meant to stay private. This situation exposes valuable
To solve this, we need to be diligent in our eorts. Relying only on hiding data on
the user’s device isn’t enough. The real solution is to make sure the server doesn’t
share any secret information in the rst place. We do this by creating strict rules for
the server to follow so it only shares pertinent user data with users.
Additionally, we need to be mindful about how we handle data. Using simple methods
that change data into a particular format, like to json() or to string(), can accidentally
provide more information than we want. Instead, we create specic methods that only
Another good idea is to have a special security check. This check looks at the data
before it’s given to the user. It makes sure everything is okay and follows the rules
we set. This way, even if something sneaky gets past the rst defenses, this check can
Ultimately, keeping sensitive data safe is a mix of dierent techniques. It’s not only
about hiding it on the user’s side, it’s about ensuring the server shares only what
20
needs to be shared, being careful with how we change data, and having a nal check
processing capability, memory allotment, and storage capacity. The user input nature
and the intricate business logic inherent in various API endpoints directly inuence
among multiple API clients competing for the same pool of resources. This com-
APIs are vulnerable when the necessary protective measures are not enforced. Lack
of rate limiting during authentication can make an API susceptible to brute force
role in API security. Excess, rigid, or lenient boundaries can make an API more
21
2. Max Allocable Memory: The upper ceiling on the memory amount that can be
5. Request Payload Size: The scale of data permissible in a single API request.
quests a particular client or resource can initiate within a specied span. Insuf-
7. Number of Records per Page: The quantum of records the API can provide
in response to a sole request. This could lead to ineectual data retrieval and
management and prudent rate limiting. Using a Docker streamlines the control of
memory, CPU, restart frequency, le descriptors, and processes while enhancing API
management by enforcing limitations on client calls within set timeframes and no-
tifying clients when exceeded, sharing limit counts and reset times. Additionally, it
bolsters the API’s security with thorough server-side validation, especially for pa-
strict limits on incoming elements and payloads, encompassing maximum data size,
22
2.5 API V: Broken Function Level Authorization (BFLA)
lined in the OWASP (Open Web Application Security Project) Top Ten list. It refers
to an application allowing users to perform functions or actions they are not autho-
rized to access based on their privilege level. In the context of APIs (Application
In the case of API IV, the primary concern revolves around improper enforcement
of authorization rules for various CRUD (Create, Read, Update, Delete) operations.
Let’s delve into the specic vulnerabilities that can happen based on CRUD:
create new users or tasks, even though these actions should only be allowed for
update any user’s information or tasks, regardless of their role, this can lead to
task attributes, disrupting the system’s integrity and leading to user confusion.
deletions, causing data loss and service disruption and potentially rendering the
23
Measures to mitigate broken function level authorization include:
1. The default approach should prohibit all access, necessitating explicit permis-
groups.
3. Ensure that all administrative controllers are derived from an abstract adminis-
trative controller. This parent controller should include checks for authorization
Mass Assignment vulnerabilities arise when an unauthorized actor gains the ability
to overwrite properties of objects they are not supposed to modify. A specic set of
conditions must align for this to occur: an API should possess endpoints that accept
user input, these requests must hold the capability to modify concealed values, and
the API ought to lack security measures that would typically thwart user input from
successfully includes parameters during the user registration to elevate their account
tion typically encompasses attributes like username, email address, and password.
24
However, a malicious entity could intercede with this request and introduce extra pa-
rameters such as isadmin: true as you can see in 7. Should the underlying data
structure contain a corresponding attribute and the API provider neglects to sanitize
the inltrator’s input, an avenue potentially opens for the intruder to register their
administrative account.
1 {
2 "name": "MassAssingment",
3 "email": "jack@email.com",
4 "isadmin": "true",
5 "password": "pasword123"
6 }
7
The application is also used to PUT requests to change the user name and age. The
GET response includes the credit balance property, which the attacker can replay to
25
To prevent this, we can minimize reliance on functions that automatically connect
client input to internal code variables or objects. Selectively permit updates to specic
properties by whitelisting them and employ system tools to block client access to
any segment of the app’s structure or if cloud service permissions are wrongly cong-
ured.
The most recent security xes are not in place, or the systems remains outdated.
Unneeded functionalities are activated (such as specic HTTP methods). With the
absence of Transport Layer Security (TLS). Clients aren’t given security directives
Resource Sharing (CORS) policy. Error messages reveal stack traces, or sensitive
An example would be when the attacker could gain access to the server’s root and
check the bash history of a server. As a result, the attacker could see the commands
run by the DevOps team. In addition, the attacker could nd the new endpoint for
26
To avoid these vulnerabilities, we need to establish a repeatable reinforcement pro-
context. In addition, conduct regular evaluations and updates of settings across the
entire API structure, encompassing orchestration les, API constituents, and cloud
for all API interactions, enabling access to static resources like images. Employ an
tive data to potential attackers. Ensure API access is conned solely to designated
HTTP verbs, while other HTTP verbs should remain inactive (e.g., HEAD). APIs
API injection attack, encompasses a range of techniques malicious actors use to ma-
nipulate the input elds of an API, aiming to compromise the system’s integrity, gain
malicious commands, queries, or code fragments. The result can lead to harmful con-
sequences, such as unintended system behaviors, data leaks, or even complete system
compromise.
API injection attacks come in various forms, each exploiting specic weaknesses in
27
1. SQL Injection: Attackers inject malicious SQL queries into API input elds,
2. Command Injection: Malicious commands are inserted into API inputs, often
of commands on the server, enabling attackers to gain control over the system.
3. XML Injection: Attackers insert malicious XML content into API input elds,
4. XPath Injection: This type of attack targets APIs that use XPath expressions
for querying XML data. Attackers manipulate input to gain unauthorized access
5. LDAP Injection: Exploiting APIs that interact with LDAP (Lightweight Direc-
6. NoSQL Injection: Similar to SQL injection, this attack targets NoSQL databases
Robust input validation, output encoding, and thorough input parameter sanitization
are essential to mitigate the risk of API injection attacks. Employing parameterized
queries, utilizing security libraries, and adhering to secure coding practices are crucial
steps to fortify APIs against these insidious threats. Regular security audits, continu-
ous monitoring, and staying informed about emerging attack vectors are fundamental
28
2.9 API IX: Imporper Assets Management
This issue happens if the previous version of the API is still running and unpatched
and does not have any plan on retiring the older API. The attacker will go to the older
This issue can be seen when the developer xes the rate limit for authentication, but
attackers were able to downgrade and brute force the authentication. Also, if they
integrated the services’ inventory, their rst or third company is outdated or missing,
non-operational API deployments. If circumstances require it, ensure that these end-
points receive identical security measures as those designated for production. Also,
use external safeguarding techniques like API security rewalls for all publicly acces-
sible iterations of your APIs, not exclusively for the existing live edition.
Insucient logging & monitoring happen when the server does not produce any logs,
logging is not set correctly, or logging messages do not include enough details. In
addition, the logs are not continuously monitored. Another important thing that
needs to be considered is if the server does not check for integrity which could cause
API VIII vulnerabilities. An example of this would be administrative APIs that were
leaked on a public repository, and the repository owner was notied, but it took 48
hrs to respond. As a result, data was leaked, and because of sucient logging, the
29
To overcome this issue, we must log all failed attempts, denied access, and input
validation errors. Log management needs to be formatted correctly so that log man-
agement can consume the logs and should include enough details to identify mali-
(SIEM) framework to centralize and oversee logs from every facet of the API stack
At the highest level, as illustrated in Figure 2.11.0.1, two risks that were previously
present have been removed, three have remained the same, four have been updated,
and ve new ones have emerged in 2023. The two formerly present risks, which
were injection attacks and insucient logging and monitoring, persist but are now
categorized outside of the API top 10, as the growing use of APIs has pushed them
beyond it. These two risks have been colored in red in Figure 2.11.0.1. Injection
attacks are still a possibility, but the implementation of better rewalls and other
mitigation techniques has reduced their risk. Three risks, namely Broken Object
indicates that four risks were simply renamed. The ve new risks, colored in blue, are
Server Side Request Forgery (SSRF), Unsafe Consumption of APIs, Broken Object
30
Figure 2.11.0.1: OWASP Top 10 API 2019 vs. 2023 [1]
nefarious hackers [41]. If you’re interested in the eld of ethical hacking, here are
1. Legal and Authorized Access: Before any engagement with any system or
hand [41]. This is crucial to avoid any infringement of legal statutes, guidelines,
data.
31
4. Informed Consent: It is necessary to make sure the stakeholders have an
report them to the companies so they can follow your guidelines to secure their
system.
Dierent resources can be used for ethical hacking practices, such as [42]:
• VulnHub • WebGoat
The information provided here, including discussions on penetration testing and se-
curity tools, is strictly for educational purposes. Any actions taken based on this
legal and ethical standards when engaging in activities related to penetration testing
individuals are strongly advised to obtain proper authorization before conducting any
security testing. This serves as a reminder to act responsibly, ethically, and within
32
the bounds of the law, promoting the use of knowledge for positive contributions to
33
Chapter 3
In pentesting, the most crucial step is setting up the required tools. This chapter will
cover the essential tools for learning API pentesting for reconnaissance and authen-
tication. I will conclude with the script I created, which can make life much easier
and sets up your system with only one command. The operating system I built and
3.1 Tools
In this section, I will provide a brief description of each pentesting tool for reconnais-
3.1.1 Burpsuite
Burp Suite is a highly regarded and widely embraced tool for testing web applica-
tion security. It has gained signicant popularity among ethical hackers due to its
robust capabilities. By utilizing Burp Suite, ethical hackers can eectively detect
vulnerabilities and possible security concerns in web applications. The suite encom-
passes various integrated tools, such as a proxy server, web spider, scanner, intruder,
curity assessment. This powerful tool enables ethical hackers to simulate attacks,
intercept and modify web trac, analyze application behavior, and uncover potential
34
for evaluating the security strength of web applications. As a result, ethical hackers
without revealing the origin of their written content. In addition, this application has
two versions: the community edition and the pro version. All my explanations about
Burp Suite in the next chapter are done in the community edition.
3.1.2 Ffuf
Fuzz Faster you Fool (FFuf ) is a web fuzzing tool widely used to identify hidden paths,
directories, and les in web applications through brute-forcing and fuzzing techniques.
It is built in the Go language, and its primary advantages include speed and eciency
compared to other tools. FFuf is capable of high-speed scanning and can process a
large number of requests in a short time, making it ideal for ethical hackers to explore
target applications for potential vulnerabilities that malicious actors could exploit.
The tool also oers exibility and customization, enabling ethical hackers to dene
their wordlists or use predened ones to fuzz various aspects of a web application,
such as URLs, parameters, or headers. This allows them to tailor their fuzzing eorts
FFuf supports various output formats, making it easier for ethical hackers to analyze
3.1.3 Wfuzz
replacing the FUZZ keyword with customizable payloads [22]. These payloads con-
sist of valuable data, enabling the injection of inputs into various aspects of an HTTP
35
Wfuzz surpasses being a web content scanner as it excels in identifying and exploiting
web application vulnerabilities. Its modular design fosters plugin development, while
its language interface empowers users to conduct comprehensive manual and semi-
automatic tests. This approach ensures a deep understanding of actions and context
For our pentesting, there are a couple of plugins required for Firefox.
1. Foxyproxy
2. uBlock-origin
ers, coin miners, popups, and more through a range of pre-enabled lter lists,
including EasyList, EasyPrivacy, Peter Lowe’s Ad server list, and the Online
additional lter lists like EasyList Cookie, Fanboy Annoyances, and AdGuard
personalized rules to override lter list entries, and access numerous advanced
features. The best part is that uBlock Origin is free, open source, and operates
under the public GPLv3 license, embodying a collaborative eort by users, for
users [23].
36
3. Wappalyzer
the technologies used by a website. It can detect the content management sys-
tem (CMS), web frameworks, programming languages, analytic tools, and other
components that comprise a website’s stack. This tool is useful for reconnais-
Ethical hackers can leverage this information to conduct exploit research and
be used to craft targeted attacks on the website. Knowing about the website’s
3.1.5 Zaproxy
ZAP (Zed Attack Proxy) is an open-source web application security testing tool
widely used to identify web application vulnerabilities. Ethical hackers and security
professionals use ZAP for penetration testing, automated scanning, and vulnerability
scans to detect common vulnerabilities. ZAP also assists in managing and tracking
ing security testing into the software development lifecycle. With its API security
testing capabilities and extensibility, ZAP provides a versatile toolset for enhancing
and mitigate potential vulnerabilities. Among its capabilities, it can check the valid-
37
ity of a token, ensuring the authenticity and integrity of the information it carries.
blank password vulnerability, and null signature vulnerability. Its ability to scan for
security breaches. Additionally, the tool employs fuzzing techniques to provoke unex-
les, public keys, and JWKS keys for validity. Furthermore, it can identify weak keys
Moreover, it oers the option to forge a new token header and payload content,
creating a unique signature using the key or employing alternative attack methods.
Timestamp tampering is another feature available, allowing for the examination and
manipulation of timestamp data. The tool also facilitates RSA and ECDSA key gen-
eration and reconstruction, leveraging JWKS les. These are just some of the func-
tionalities the logo embodies, and many more features remain to be discovered [25].
3.1.7 Postman
Postman is a widely utilized collaboration platform developers use to design, test, and
diverse request types (e.g., GET, POST, PUT, DELETE) to target API endpoints.
Through meticulous scrutiny of API responses and their intricate composition, these
common security pitfalls, such as cross-site scripting (XSS), cross-site request forgery
38
(CSRF), and deciencies in communication encryption. Moreover, Postman empow-
ers ethical hackers with automated test script functionality, request collections, and
the ability to manage environment variables. These features greatly enhance e-
sharing of test cases among team members. Importantly, Postman boasts compre-
an ideal tool for scrutinizing diverse API landscapes encompassing RESTful APIs,
3.1.8 Amass
Amass is an open-source tool that excels in network mapping and uncovering potential
vulnerabilities. It uses various techniques like active reconnaissance and external asset
discovery to collect extensive data. Amass is equipped with internal machinery and
seamlessly integrates with external services, enhancing its eciency and eectiveness.
This tool nds DNS, HTTP, and SSL/TLS data. It also works with APIs like the
SecurityTrails API to expand its capabilities. Additionally, Amass taps into web
archiving engines to uncover hidden online data. In addition, the framework saves
the ndings and metadata in a database (SQLite and PostgreSQL), which is updated
and queried across the sessions. This database is in a graph-like structure. Figure
3.1.8.1 the assets show details about the ndings, and the rows are connected to the
assets table. Furthermore, all the data is time-stamped when created and last seen.
39
Figure 3.1.8.1: Under the hood of Amass database [3]
In network discovery, Amass stands out as a powerful and discreet tool, evading AI
The Burp Suit provides both automated and semi-automated processes; however, the
new update of Zaproxy gives us the capability to use the YAML le. As a result,
such as Kubernetes and implementing CI/CD pipelines [44] [43]. In addition, when
Suite vs Zaproxy, it was discovered that both Burp Suite and Zaproxy have active
support from online forums and other support functions. Likewise, both Burp Suite
and Zaproxy come with well-documented manuals and product documentation. The
one area where we see a dierence is while both use a GUI interface, Zaproxy also
Furthermore, Burp Suite has more tools for vulnerability detection than ZAP. Burp
Suite also comes with the essential tools needed for initiation, with the capability
for add-ons if needed. Zaproxy, however, requires additional add-ons that must be
installed rst. These mandatory add-ons are necessary for proper functionality [48].
40
Alternatively, The Burp Suite has higher accuracy and fewer false positives than
Zaproxy [43]. Zaproxy is excellent for nding vulnerabilities, but it has limitations in
the scope of its scans. Lastly, Burp Suite is costly if you use the professional version;
Table 3.1.10.1 compares three tools used in our pentesting. There are several tools
available for content discovery, but the most commonly used ones for detecting vulner-
abilities are Gobuster, Ffuf, and Wfuzz. Although these tools share the same purpose
unique capabilities. Here is a comparison of the features of these three tools, which
Protocols Primarily designed for HTTP Supports multiple protocols (HTTP, FTP, etc.)
Customization Oers customization but streamlined Highly customizable with various options
Wordlist Support Ecient handling of large wordlists Extensive payload generation capabilities
Ease of Use Designed for simplicity Powerful but may have a steeper learning curve
The rst dierence is the language used; while Ffuf is written in Golang, Wfuzz
is based on Python [46]. The benet of using Python over Golang is the ease of
41
installation for most users who may not be familiar with Golang. When it comes to
fuzzing, the fuzzing speed is faster in the tools that use the Goland language, as the
threading in Golang is much faster than the threading speed used in Python. The
reason for this is due to Python only allows one thread to execute at a time and is
helpful for I/O-bound tasks. However, Golang has an advantage because it supports
concurrent programming using goroutines and channels. These goroutines allow both
I/O-bound and CPU-bound tasks. In one article reviewed (cite) that focuses on the
two fuzzing tools, Ffuz and Wfuzz, the author compared the two based on execution
study, it was found that Wfuzz was the leading in every metric except for the memory
footprint. However, in the conduction of this experiment, threading was not used.
can not be correct because Ffuf is faster because of the power of Golang. In Figure
3.1.10.2, the sys time plus user time indicates that the CPU time is more ecient
42
Figure 3.1.10.2: FFuf time performance
Rust, facilitates the execution of numerous tasks concurrently using a minimal number
of operating system threads. While Rustscan uses Rust, Nmap executes in C language
as seen in table 3.1.11.1. Rustscan provides caching, which can drastically reduce
scanning time on the extensive network [45]. On its own, Nmap speed is powerful
43
but often perceived as being slower 3.1.11.1. The reason is Nmap uses detection
evasion of rewalls and intrusion detection systems (IDS). However, Nmap uses ags
to speed up scans with the -sS, and -T ags. The -sS can be performed quickly with
the capability to scan thousands of ports per second. This is known as the stealthy
scan method. The -T provides a range of speed capabilities from very slow using the
Being faster, as in the case of Rustscan, doesn’t necessarily mean better. Newer
rewalls can easily detect fast scans and block IPs scanning the network. Therefore,
we can limit detection by rewalls and IDS devices using Nmap and slower scanning
methods.
Language Rust C
Speed Fast and ecient but noisy Powerful but may be perceived as slower
Scanning Techniques Simple and fast, focused on speed Versatile with a wide range of techniques
Ease of Use User-friendly command-line interface Extensive options, can be more complex
Community Support Growing community Large and active community, extensive resources
Flexibility Basic scans, quick reconnaissance Comprehensive feature set, suitable for various scenarios
In addition, Rustscan doesn’t use more than one thread and doesn’t call more than
one Nmap instance at a time [50]. Rustscan provides scans for both host and IP
to scanners that only scan hosts synchronously. The purpose of Rustscan is for port
scanning, and it does not support other features like Nmap. Nmap supports various
Rustscan gives an option by using – to run ags provided for Nmap. Rustscan can
44
have 65000 ports in 3 seconds; however, it’s essential to remember that this will be
To streamline the installation process, the initial step is to download the Ubuntu ISO
there are two available installation options. We can utilize virtual machines like
Ubuntu operating system, open the terminal and run the command below:
1 sudo apt-get install git ansible
2
We need git to clone the API-lab GitHub repository, and Ansible to congure our
system automatically. The script provided requires Ansible. The next step is to run
3.2.1 Ansible
Ansible is a free and open-source tool written in Python. Ansible can congure
The primary goal of Ansible is simplicity and ease of use. In addition, it has essen-
tial consideration of security and reliability. For deployment, it uses OpenSSH for
45
In this project, the purpose of using Ansible is users do not need to congure ev-
erything manually. Another critical thing to remember is we can use this script to
deploy to multiple servers so professors can implement this in their classrooms. This
will be an excellent opportunity for future developers to have the skills to develop
for deployment) is in YAML format, and les end with .yml. The directory structure
looks like the gure 3.2.1.1. The local.yml is the main YAMAL le, which includes
46
In local.yml, we set up all the hosts we want to run this script on. Here, we used
a local host. However, we can have a separate le in Ansible to dene all host IPs.
In this way, we can deploy our conguration to multiple servers. As we can see in
3.2.1.1, these are all the hosts we dene in our hosts’ le and give root permission
to run our cong as a sudo user. Vars is the variable that we predened that we
use later in our code. Tasks are the steps in which we want our project to congure
our system. In my local.yml, instead of all congurations in the same place, I used
include, which refers to the task folder, as you can see in 3.2.1.1. The le consists of
2 ---
3 - hosts: all
4 become: true
5 vars:
6 created_username: api
7
8 tasks:
9 - name: Install curl
10 apt:
11 name: curl
12 state: latest
13 update_cache: true
14
As you can see in the les folder, some les end in j2, which stands for Jinja. Ansible
47
3.2.2 Jinja
Jinja is an Ansible and Python template engine for generating dynamic content like
HTML, JSON, and text-based formats. It separates templates containing static text
cessed when rendered. With variables, lters, and control structures, Jinja eciently
in web frameworks like Flask and Django, Jinja facilitates tasks such as generating
web pages with personalized content or crafting conguration les and emails. Its
security features include automatic content escaping and guarding against potential
vulnerabilities.
After going to API-lab-Setup, we must run the following command in the terminal
1 ansible-playbook local.yml -K
2
sudo access to be installed on our system. Another conguration that can be set
By running the setup, we only install the based conguration, which includes installation-
based setup, without installing any cyber security tools. In addition, we can provide
multiple tags like setup, burp. This installs setup conguration and installs Burp
Suite. After installation, we must go to the terminal, right click, and choose the
48
preferences options. In the opened window from the menu tab, select the text and
hit the checkmark on Custom font. Next, choose the MesloLGS NF from the font
After completing the setup of your system, your desktop should look like gure 3.2.2.2.
49
Figure 3.2.2.2: Ubuntu desktop after conguration
To set up Foxyproxy, open Firefox and click on the plugin as per 3.2.3.1a, select
options to open the plugin, click on the Add button to congure your proxy
settings. Set up your proxy as shown in gure 3.2.3.1b and save the changes.
For both Postman and Burp Suite, the proxy IP is 127.0.0.1. In addition, the port
for Postman is 5555, and the Burp Suite is 8080. After conguration, it should have
50
3.2.4 Burp Suite Extentions
After opening the Burp Suite and accepting the conguration, go to the extensions
tab and click on BApp Store. Click on the search bar and look for Authorize. Figure
Click on the Download Jython to open the Jython website. Please download the
standalone version of this library. Then, from the menu, choose Extension settings.
In the Python environment, click on select le and choose the directory downloaded
51
Figure 3.2.4.2: Setup Jython
Close the menu, return to the App, and search the Authorize app again. The down-
load option should be available. Click download; it is crucial to install the Param
Miner extension. This extension is designed to identify hidden and unlinked parame-
ters and is particularly useful in detecting vulnerabilities related to web cache poison-
ing. The extension is equipped with sophisticated dierential logic inherited from the
Backslash Powered Scanner, along with a binary search method, which enables it to
these parameter names from a carefully curated internal wordlist, which is further
This script was built to run on Ubuntu 22.04. The script is mainly constructed to
get the application from a repository or website. One of the caveats that cause issues
is the version of Golang installation in golang.yml in the tasks folder is hard coded,
which in gure 3.2.5.1 indicates that we use version 1.21. If any dependencies that
52
later require the higher version, it must manually be changed to the version required
Another limitation after running the script, the user will need to go to Firefox to
53
Chapter 4
AUTHENTICATION
In this chapter, we will delve into an exploration of open-source tools designed for API
serves as the designated platform for evaluating the tools under consideration. It is
Reconnaissance constitutes the initial phase of ethical hacking, encompassing the sys-
tematic acquisition of information about the target system [37]. This data compilation
lous examination of websites that serve as instrumental tools for information gath-
54
ering. If tools are identied on GitHub that automate the process of extracting
information from this website, such tools will be presented in section. In active re-
connisance cover tools for actively gathering information. Table 4.1.0.1 indicated two
Shodan Gobuster
Amass
4.1.1 Passive
networks without actively engaging with them without interruption [21]. It relies on
data that can be publicly accessed through open-source intelligence (OSINT) research
industry trends, and consumer behavior as possible about the target without direct
interaction [38]. In addition, credentials such as usernames and credentials can help to
and API documentation can also help understand how to interact with API. If we can
use older APIs, maybe access some information that cannot be accessed through new
Git Dorking, Wayback Machine, Shodan, and Amass. In addition, it provides dierent
55
4.1.1.1 Google Dorking
Google Dorking is a technique that involves using specic search queries on the Google
website. These queries are listed in Table 4.1.1.1, which displays the most common
Google Dorking queries to use. The essential keywords used in the table are inurl,
When you use the inurl keyword, Google will display URLs that include the keywords
you were searching for. Similarly, intitle and intext will look for keywords in the
title or text of the page, respectively. The ext keyword searches for les with the
56
Table 4.1.1.1: Google Dorking Queries [1]
Query Expected Results
les.
directories.
intitle:index of api key OR api key OR apiKey -pool It lists potentially exposed API
keys.
mentation
Overall, Google Dorking is a powerful tool that can be used for both good and bad
The search functionality within Github represents a robust and valuable tool for
Github dorks, or specialized search queries, can potentially expose condential details,
57
encompassing personal and organizational data, including but not limited to private
Numerous companies have relied on the GitHub repository for their development
needs for several years. Despite having several competitors, GitHub continues to
be the most popular platform for software development. While many developers
such as environment variables, token keys, usernames, and passwords during stressful
moments. Figure 4.1.1.1 indicated that if you search for nasa.gov credentials in
GitHub, you will see that one of the software developers, by mistake, pushed the code
to GitHub with the credentials. As a result, malicious actors exploit the possibility
of such occurrences by using Git Dorking to search for sensitive data that may have
Table 4.1.1.2 demonstrated the common Git Dorking command, which is helpful such
In the following, I will discuss tools that automate the process instead of doing it
manually.
58
Table 4.1.1.2: Git Dork keys
GitHub Dork Info
lename: travis.yml nding les
extension: json nding the extension
like json
path: sites databases password nd the path
language: python nding languages
api key
api key
authorization bearer
oauth
auth
authentication
client id
password
Finding API keys, To-
user password
kens, and passwords
user pass
passcode
client secret
secret
password hash
OTP
user auth
user:name (user:admin)
org:name (org:google type:users)
in:login (<username>in:login)
Finding usernames
in:name (<username>in:name)
fullname:rstname lastname (fullname:<name><surname>)
in:email (data in:email)
created:<2012–04–05
created:>=2011–06–12
Finding information-
created:2016–02–07 location:iceland
specic dates
created:2011–04–06..2013–01–14 <user>in:username
1. Github-Dorks: [27]
Github-Dorks is a powerful and useful tool that enables us to search for sensitive
This repository is written in Python [27]. The good part is that users can give
59
Figure 4.1.1.2: Github-dorks usage
Figure 4.1.1.2 indicate many functionality in which we can search for the user,
Github repo, provide a Github Dork le, or monitor the user’s private feed and
2. TrueHog: [28]
This tool is excellent for nding leaked credentials in a git repository. This
program was written in Golang [28] and gave multiple ways to install this ap-
plication [28].
With TrueHog, you could scan a repo for only veried secrets, scan a GitHub
organization for only veried secrets, scan a repo for veried keys, and get JSON
output. Below is examples which we can use for pentesting. The –org specied
3. Gitrob: [29]
60
public repositories on GitHub. It works by cloning a user or organization’s
repositories to a depth that can be adjusted and then reviewing their commit
history to identify and highlight les that exhibit characteristics associated with
potentially sensitive data. These results are conveniently displayed via a web
interface, making navigating and analyzing them eortless. This code was de-
veloped with Golang. This library has not been updated in the last ve years
extensive web pages and multimedia les collected from the web over the last two
safeguarding digital content and ensuring its availability to the general public [31].
The Wayback Machine serves as a virtual time-travel tool for the internet. It permits
users to retrieve past iterations of websites and web pages precisely as they were
at distinct moments in history. The Wayback Machine curls the internet and takes
The benets of using Wayback Machine are for ve reasons [31]:
1. Historical data: The Wayback Machine oers access to past website data,
detecting alterations that might have introduced fresh security aws or vulner-
abilities.
61
website versions across timeframes. This process helps pinpoint modications
sensitive data that may have existed on a website previously, such as login
dated software or plugins that were once present on a website can be identied.
ously identied vulnerabilities. This ensures that security concerns have been
adequately resolved.
1. Go to archive.org/web.
2. Once there, navigate to the homepage, which should have a search bar.
3. In the search bar, enter the website for which you want to gather information.
Figure 4.1.1.3 shows that for owasp.org. The calendar allows us to nd the information
between the dierent periods and the changes that happened to the website.
62
Figure 4.1.1.3: Wayback Machine for owasp.org
The changes section button shows calender for each year and by clicking on each
squres shows the snapshot of the website content. By clicking on the URLs, we were
Wayback Machine oers exclude your website by emailing info@archive.orge and indi-
cate the URLs, the time period, the period you have control on the website to remove
Waybakurls:
The waybackurls tool can grab all URLs found by Wayback Machine. This was fully
Once the command displayed above is entered into the terminal, a urls.txt le will
be returned. The le will include all the domains from which we gather information
63
4.1.1.4 Shodan:
Shodan is also an excellent tool typically used in reconnaissance. This tool allows the
user to search for key words to nd information about dierent IPs and open ports on
those IPs. Additionally, Shodan can be used to gather information about a particular
API. Shodan has regularly monitored devices accessible to the internet and checked
all the IPv4 address spaces with open ports. For API pentesting, we can search in
the search bar ”content-type: application/json” to only display the APIs that
return JSON or change JSON to XML format to return XML formats. Figure 4.1.1.4,
shows 5,365,719 results based on our search. Also, Shodan enables us to lter from
the left side menu based on countries, organizations, and operating systems to get
more related results to our needs. In addition, to nd WordPress API, we can search
for ”wp-json”.
64
4.1.1.5 Amass:
Amass version 4.2 has two subcommands, intel, and enum. The following goes into
1. Intel: Intel command is used for collecting open source intelligence on the
organization and allows nding the root domain names associated with the
organization. When you run an Amass intel command, the command provides
a help menu on how to use the intel sub-command (see gure 4.1.1.5). After
the intel command, we could choose the optional ags and specify the domain
we will be pentesting. For example, gure 4.1.1.6 shows that OWASP owned
65
When using Amass intel for search operations, you have the exibility to en-
as the -active parameter, which initiates zone transfers and actively scans to
retrieve SSL/TLS certicates for data extraction. It’s crucial to emphasize the
In addition, with -org we can look for organizational names that return Au-
2. Amass enum enables you to engage in DNS enumeration and mapping of the
output directory using the -dir ag. The same arrangement applies to other
-passive and -active. The passive method is faster; however, Amass will not
check for DNS information, such as resolving the subdomains. The command
below displays the output of the Amass passive attack on the owasp.org.
66
Another option is the active conguration mode. This method will give us
more precise results, and more assets could be discovered because all DNS
The command below is active and performs subdomain brute-forcing with the
the specied resolver. The below command -d species the domain, and -w
species the wordlist we want to brute-force and saves the output results at
For the -cong, you can specify special congs which are located in our Ansible
script at .cong/amass/cong.yml.
In addition, we have other tools for Amass, which are installed on our system from
tools. Each of these tools includes dierent ags to run with default and non-default
commands that are common in all of them. Table 4.1.1.3 include the default ags
and the four tools included as oam i2y, oam subs, oam track, and oam viz.
-cong Path to the YAML conguration le oam command -cong cong.yaml
-dir Path to the directory containing the graph database oam command -dir PATH -d example.com
-silent Disable all output during execution oam command -silent -d example.com
67
1. The oam i2y is for converting legacy ini conguration formats to a new YAML
format. The ag provided for this tool is -ini, which is indicative of the ini le
we want to convert to. The -cf and -df are for cong.yml and dastasrc.yml,
2. The oam subs is for analyzing collected Amass assets. Oam subs conducts
actions related to the graph database, allowing users to view and control it.
This operation can utilize the SQLite le generated through enumerations or
the remote graph database settings specied in the conguration le [2].
-d Domain names separated by commas (can be used multiple times) oam subs -d example.com
-demo Censor output to make it suitable for demonstrations oam subs -demo -d example.com
-df Path to a le providing root domain names oam subs -df domains.txt
-ip Show the IP addresses for discovered names oam subs -show -ip -d example.com
-ipv4 Show the IPv4 addresses for discovered names oam subs -show -ipv4 -d example.com
-ipv6 Show the IPv6 addresses for discovered names oam subs -show -ipv6 -d example.com
-o Path to the text output le oam subs -names -o out.txt -d example.com
-show Print the results for the enumeration index + domains provided oam subs -show
-src Print data sources for the discovered names oam subs -show -src -d example.com
-summary Print just ASN table summary oam subs -summary -d example.com
3. The oam track command checks the dierence between enumerations that in-
clude the same target(s) for monitoring the target surface. The ags for this
tool are -d, where we dene the domain, and -df, the path to the le providing
the root domain. Lastly, -since is for excluding all enumerations before a spec-
68
ied date (format: 01/02 15:04:05 2006 MST) [2].
4. The oam viz generates illuminating network graph visualizations that enhance
the organization of collected information. This operation can utilize the SQLite
le generated through enumerations or the remote graph database settings spec-
The following displays options to display DNS and infrastructure ndings in the
Table 4.1.1.5: The oam viz ag for showing network graph
Flag Description Example
-d Domain names separated by commas (can be used multiple times) oam viz -d3 -d example.com
-d3 Output a D3.js v4 force simulation HTML le oam viz -d3 -d example.com
-df Path to a le providing root domain names oam viz -d3 -df domains.txt
-dot Generate the DOT output le oam viz -dot -d example.com
-gexf Output to Graph Exchange XML Format (GEXF) oam viz -gexf -d example.com
-o Path to a pre-existing directory that will hold output les oam viz -d3 -o OUTPATH -d example.com
-oA Prex used for naming all output les oam viz -d3 -oA example -d example.com
4.1.2 Active
In active reconnaissance, the attacker directly interacts with the target and gathers
information for later stages of attacks without disruption or noticeable impact [30].
It’s like softly knocking on a system’s digital doors and windows, discreetly seeking to
understand its vulnerabilities and weaknesses. This subtle approach leaves minimal
techniques eectively, security professionals can gain valuable insights into a system’s
conguration and potential entry points while maintaining a low prole to ensure
undetected operation.
69
4.1.2.1 Port Scanning
The initial step of each scanning is port scanning, which enables us to gather more
information about the ports in our client server. We do not know what type of
applications are running in the system. I will review the most common open-source
1. Nmap
Nmap is widely used for port scanning. It oers a variety of ags to suit dierent
needs but can be quite disruptive, so be sure to obtain permission before use on
your target. See Table 4.1.2.1 for a breakdown of the various ags, a description
nmap target Basic host discovery and open port scanning Discover hosts and identify open ports
nmap -F target Fast scan (top 100 ports) Quickly identify common open ports
nmap -p 1-65535 target Scan all 65,535 ports Thoroughly enumerate open ports
nmap -A target Aggressive scan with OS and service detection Gather detailed information about target
nmap -sV target Service version detection Identify running services and their versions
nmap -T4 target Set timing template (fast) Speed up the scanning process
nmap -T5 target Set timing template (insane) Fastest scan with minimal delay
nmap -p- target Scan all 65,535 ports (TCP) and common UDP ports Thoroughly enumerate all ports, including UDP
nmap -sn target Ping scan (disable port scan) Check host online status without scanning ports
nmap -Pn target Skip host discovery (assume all hosts are up) Force scan without host discovery
nmap -oA output target Output results to les Save scan results in various formats
nmap –script <script>target Run NSE scripts Execute Nmap Scripting Engine (NSE) scripts
For API pentesting, we need to run the scan twice - once for general detection
and once for all ports. The general method scans for default scripts and services
against a target.
1
70
2 nmap -sC -sV <target address or network> -oA nameOfOutput.txt
3
The -sC ag runs the default script, while -sV checks the service version. The
second scan checks all 65,535 TCP ports. See the command below.
1
For example, using Nmap, I performed a general detection on the website crapi.
viewed in gure 4.1.2.1. The scan revealed that the server had open ports for
2. Rustscan
Rustscan is a rapid port scanning tool that uses adaptive learning to improve
over time. This port scanner is high-speed; it can scan 65000 ports in less than
71
3 seconds. Rustscan now features a scripting engine that supports Python, Lua,
and Shell. Figure 4.1.2.2 indicated the helper page for the Rustscan.
Rustscan provides dierent ags to do port scanning. For example, I ran the
following command. The address can be specied using the -a command, while
Nmap ags can be used after –, such as -sC for the default script and -sV for
When the command -b is used with a specied number, such as -b 10, 10 ports
Users can activate FoxyProxy on their browser to intercept communication and switch
to Burp Suite mode. In the Burp Suite, the user must go to the proxy and set the
72
intercept on. After that, they can attempt to authenticate with the web server and
observe how the data is transmitted to the system by seeing it in the Burp Suite.
Figure 4.1.2.3 shows that the user tried to create a new account crapi.apisec.ai, a
vulnerable server for pentesting. We can see the server is trying to do POST requests
4.1.3 Gobuster
Gobuster is a tool with many functions, including directory brute force, which can
reveal available directories on a target. It can also perform DNS subdomain brute-
Gobuster includes a command for detecting S3 buckets and a host option to identify
other subdomains hosted by the system. It can also fuzz for brute-forcing passwords
by modifying the FUZZ keyword. To execute the command, follow this example.
73
2 gobuster dir -u 127.0.0.1 -w /opt/SecLists/Discover/Web-Content/
→ common.txt --threads 10 -delay 1s
3
This command performs directory brute-forcing using the dir argument. The -u
command is used to specify the URL, and the -w argument is for the wordlist. The
number of threads and delay are used to send ten requests per second.
4.2 Authentication
uinely corresponds to its claimed identity [33]. Technology for verication controls
system entry by validating whether the provided credentials align with those stored
cation ensures the security of systems, processes, and overall enterprise information.
Throughout this section, I will be covering three types of pentesting on brute force
and phishing attacks can compromise the system’s security. Additionally, users’
74
more additional verication measures. These could include the usage of a pin
sent to the recipient’s email through a message or using a physical key such as
Yubikey.
4. Single sign-on (SSO): In this way, the user has an account trusted by the
identity provider (IdP) and tells the application via cookies or tokens that the
user veried. This reduces the number of credentials a user needs to remember
cess their accounts using a physical device like a smartphone, security key, or
within a given timeframe, decreasing the necessity for multiple logins [34]. This
This attack is on the authentication API endpoints used for generating targeted
75
4.2.1.1 Wfuzz
Wfuzz is a password brute-forcing tool. It searches for the keyword FUZZ in your
command and continues to brute-force until it nds the password. To fuzz, you can
use -d to send post data in the body. If you want to hide responses with a specic
code, use the –hc ag. To set the payload for each FUZZ keyword, use -z. In our
Figure 4.2.1.1 shows how I ran crapi.apisec.ai. The 200 responses indicate that we
Figure 4.2.1.1: Crack the user password and get 200 response
76
4.2.1.2 Ffuf
In the uf we need to copy the request with the help of Burpsuite. For example, in
gure 4.2.1.2, you can see the post request intercepted by Burp Suite and the email
and password change with the keywords FUZZ and WFUZZ. We changed the email
and password because when we are brute-forcing the uf, look for keywords that have
Here’s a guide on using uf to brute force basic authentication. We need to specify
the le we copied to the request using Burp Suite in the -request eld. The protocol
we use is set in the -request-proto eld, which is HTTPS by default but can be
changed to HTTP, like in our example. The -mode eld allows us to choose from
multiple methods for brute forcing. By default, uf uses clusterbomb, which iterates
through a dierent payload set for each position [35]. This results in a combination of
sets. Another method is pitchfork, which iterates through a dierent payload set for
each dened position. The last method is sniper, which places each payload position
in turn [35]. The -w we specify the wordlist and the keyword they need to look for
changes. Last, the -mc to match HTTP status code in our request.
77
2 # -request-proto Protocol to use along with raw request (default: https)
3 # -mode Multi-wordlist operation mode. Available modes: clusterbomb,
→ pitchfork, sniper (default: clusterbomb)
4 # -w Wordlist file path and (optional) keyword separated by colon. eg.
→ ’/path/to/wordlist:KEYWORD’
5 # -c color
6 # -mc Match HTTP status codes, or "all" for everything. (default:
→ 200,204,301,302,307,401,403,405,500)
7 ffuf -request ./requirement.txt -request-proto http -mode pitchfork -w
→ ./emails.txt:HFUZZ -w ./pass.txt:WFUZZ -c -mc 200
8
Figure 4.2.1.3 indicates how we use uf for brute-forcing the password on a CrAPI
the server.
To ensure secure access to digital services like banks, one-time password authentica-
tion is commonly used. This method generates random strings or numbers the user
must authenticate with each time they log in to their account. However, it can be
vulnerable if the server has no rate limit and can be subjected to brute-force attacks.
78
Figure 4.2.1.3: Crack the user password and get 200 responses
79
To retrieve the OTP password request, you can intercept the post request from
Foxyproxy and Burp Suite. Figure 4.2.2.2 displays the results, showing that the
application uses v3 and is not susceptible to our attack. However, if the version
There are two methods to obtain an OTP pin using Wfuzz or Ffuf. Figure 4.2.2.2
the desired location, we use the FUZZ key and create a POST request body with
-d. In Wfuzz, using –hc hides the response 500, which prevents us from receiving too
many 500 responses. Instead, we only received the desired 200 responses. Similarly,
80
4
Figure 4.2.2.3 shows that we successfully brute-forced the OTP and used the Wfuzz
A JSON Web Token (JWT) serves as an open standard (RFC 7519), outlining a
parties in the form of a JSON object [36]. The credibility of this information is
upheld through digital signatures. JWTs can undergo signing processes, employing
either a secret (via HMAC algorithm) or a public/private key pair through RSA or
ECDSA [36].
Although JWTs provide encryption and secrecy, our focus is on signed tokens. The
signed key ensures the integrity of our information, while encrypted tokens hide it from
other parties. There are two reasons why we use JWTs: for user authorization when
logged in, for including JWT tokens in every request, and for securely transmitting
information.
81
JWT is structured in three parts, separated by dots. These three parts included
1 xxxxx.yyyyy.zzzzz
2
The header consists of two parts: the type of token, that is, JWT, and the signing
algorithm, which could be HMAC SHA256 or RSA. The example will be:
1 {
2 "alg": "HS256",
3 "type": "JWT"
4 }
5
This is encoded in Bas64Url. The payload is a predened claim that is not manda-
and aud(audience). Public claims are dened for the using of JWTs but should
consider collisions, and for evidence of that, they should dened in IANA JSON Web
Token Registery [36]. Last, private claims are customer claims for sharing infor-
mation between parties, which is encrypted as Bas64Url. The payload will look like
this:
1 {
2 "sub": "1234567890",
3 "name": "John Doe",
4 "admin": true
5 }
6
82
Listing 4.2.3.3: JWT Payload
secret key, and the chosen algorithm for the header. For instance, if we want to use
1 HMACSHA256(
2 base64UrlEncode(header) + "." +
3 base64UrlEncode(payload),
4 secret)
5
In summary, gure 4.2.3.1 indicates that users sent requests that are marked as one,
and the authorization server responded with the token. After that, the user can access
83
4.2.3.1 Attacking JWT
In our example of CrAPI, you get a token response after logging in to the system.
When intercepting the log-in page with Burp Suite and getting a response, it looks
like the gure 4.2.3.2. As we can see, dots separate the structure token.
Figure 4.2.3.2: Authentication with website and get token with Burp Suite
To get the information about our token, there are two paths you can take. one is the
website jwt.io and the other paths is using the jwt tool. If we use the website in the
encoded section, we provide the token and click on SHARE JWT. As a result, we
get an analysis of each section of the JWT token. On the other hand, we can use the
jwt tool, which is run in the terminal. To analyze our JWT token, we need to run
it as jwt tool jwt token. Figure 4.2.3.3 shows that we got the following results by
running that command. Figure 4.2.3.3 illustrates the payload and the header le.
84
Figure 4.2.3.3: jwt tool JWT token analysis
Jwt tool has a dierent mode of scanning for common vulnerabilities. With -M we
1. pb = playbook audit
4. at = All Tests!
Below is an example of how to run this for the playbook audit method with specifying
pb.
1 jwt_tool -t http://crapi.apisec.ai/identity/api/v2/user/dashboard -rh "
→ Authorization: Bearer Your_JWT_token" -M pb
2
Jwt tool provides dierent exploits against the JWT token. This can be specied
with -X. The set after -X makes the algorithm in the header none and generates new
85
tokens, which we can test to see if API is vulnerable to this token. Below is all the
1. a = alg:none
2. n = null signature
4. s = spoof JWKS (specify JWKS URL with -ju, or set in jwtconf.ini to automate
this attack)
This method is used to forcefully guess the secret for the signature by attempting
to sign a new token with various combinations of usernames or email addresses. For
instance, to access the CrAPI signature key, we can use the tool crunch to generate
multiple vital combinations. To generate all the variety of lengths of ve, run the
following command.
1 crunch 5 5 -o crAPI.txt
2
86
After saving all the combinations in the CrAPI.txt, we can use jwt tool to brute-force
the signed key. Figure 4.2.3.4 shows how to crack with jwt tool. We need to specify
the -C, which indicates we want to use crack attack, and -d for specifying our all-key
combination le.
Figure 4.2.3.4 shows that the signing key, crapi, was successfully cracked. If we visit
jwt.io, we could use this key to generate a new key and change the associated email
87
Chapter 5
5.1 Conclusion
In this thesis, rst I introduced the basics of APIs and the various API protocols used
are discussed. In the course of this thesis, we found that many vulnerabilities come
system, there’s less chance the system will be vulnerable. Additionally, we delved into
the integral components of API security, highlighting the crucial elements that form
security. These pillars serve as the bedrock for robust security measures and play a
pivotal role in shaping and fortifying API systems. Most common breaches occur in
large companies and expose them to the risk of data breaches, allowing the attacker
APIs top ten security vulnerabilities and compared the vulnerabilities between 2019
and 2023 to demonstrate the similarities and dierences between the years. We
covered deployable scripts that install the required pentesting tools to the Ubuntu
systems and prepares the system for pentesting for reconnaissance and authentication.
The script was written in Ansible, developed by RedHat, enabling the user to deploy
the script for system conguration. This script rst installs the necessary packages for
the Ubuntu system and uses the includes function in the local.yml le and all the
scripts included in the tasks folder to install necessary cyber security tools and system
88
congurations, such as background setup, FireFox plugins, terminal setup, Tmux
explored API reconnaissance and authentication, diving deeper into the active and
yet to be studied. First, to improve the deployment of the Ansible script discussed
tent and reproducible environment to run applications and bundles applications and
dependencies into a singular container. Some suitable Docker images like Webtop or
Kasmweb allow you to run the operating system in a web browser. You can then uti-
lize a Dockerle to congure images and install necessary packages with the Ansible
script. I faced a challenge when I attempted this approach. Two applications, Burp
Suite and Zaproxy, require a graphical user interface for installation, which prevented
the use of Docker due to the lack of a user interface during the compilation of the
Additionally, it’s worth noting that the OWASP API top ten for 2023 emphasizes a
API. The industry is presently shifting towards GraphQL as the preferred choice for
API development. Unlike REST APIs, where clients receive a xed data set in a
predened structure, GraphQL allows clients to request only the data they need in
89
a specied format. This exibility is more ecient and can handle faster interaction
Furthermore, all the tests were done on a vulnerable environment, CrAPI, which we
test their system, it will provide us the opportunity to work on real-life experiments.
Time constraints only allowed me to cover three areas under authentication pen-
Open Authorization, and signal sign-on (SSO) to understand the standards used in
90
BIBLIOGRAPHY
2021-07-21.
https://youtu.be/IgxPsv8MXMw?si=WT71Wrmz1A7GhrKL
8, 2023.
2023.
[7] J. Greig, Coinbase pays out largest bug bounty ever for trading interface
aw, https://www.zdnet.com/nance/blockchain/coinbase-pays-out-
[8] L. Tung, Usps nally xes website aw that exposed 60 million users’ data,
https://www.zdnet.com/article/usps-nally-xes-website-aw-that-
91
[9] Z. Whittaker, Peloton’s leaky api let anyone grab riders’ private account
data,
https://techcrunch.com/2021/05/05/peloton-bug-account-data-leak/,
https://www.wired.com/story/i-scraped-millions-of-venmo-payments-your-
[11] M. GAJANAN, Instagram says bug gave hackers data on ’high-prole’ users,
https://time.com/4922700/instagram-security-breach-veried-users/,
[12] C. Kanikee, The optus breach: How bad code keeps happening to good
companies, https://securityboulevard.com/2022/09/the-optus-breach-
2023.
https://www.makeuseof.com/api-architecture-types-how-work/, accessed:
July 8, 2023.
[15] Indeed, What is soap api? (plus comparison to rest api and benets),
https://www.indeed.com/career-advice/career-development/what-is-soap-
api#:∼:text=SOAP%20API%2C%20or%20simple%20object,Extensible%
92
[17] A. Mendoza and G. Gu, Mobile application web api reconnaissance:
[18] Bae, T-mobile hacked to steal data of 37 million accounts in api data breach,
https://www.bleepingcomputer.com/news/security/t-mobile-hacked-to-
steal-data-of-37-million-accounts-in-api-data-breach/#:∼:text=New%
20data%20breach%20impacts%2037,the%20API%20one%20day%20later.,
[19] T. Keary, T-mobile data breach shows api security can’t be ignored,
https://venturebeat.com/security/t-mobile-data-breach-shows-api-security-
8, 2023.
https://www.techtarget.com/whatis/denition/passive-reconnaissance,
July 8, 2023.
https://addons.mozilla.org/en-CA/refox/addon/ublock-origin/, accessed:
July 8, 2023.
93
[25] ticarpi, jwt tool, https://github.com/ticarpi/jwt tool.
https://www.ansible.com/overview/how-ansible-works.
https://securityboulevard.com/2021/07/active-reconnaissance-overview-
methodology-and-tools/, 2021.
[31] Cuncis, How the internet archive wayback machine can help pentesters nd
hidden vulnerabilities,
https://medium.com/@cuncis/how-the-internet-archive-wayback-machine-
can-help-pentesters-nd-hidden-vulnerabilities-2604fe31ba0c, 2023-04-10.
https://github.com/tomnomnom/waybackurls.git.
https://www.techtarget.com/searchsecurity/denition/authentication.
[34] Kyle Johnson, Use these 6 user authentication types to secure networks,
https://www.techtarget.com/searchsecurity/tip/Use-these-6-user-
authentication-types-to-secure-networks.
documentation/desktop/tools/intruder/congure-attack/attack-types.
94
[37] Cybersecurity Exchange, Understanding the basics of footprinting and
reconnaissance, https://www.eccouncil.org/cybersecurity-
exchange/ethical-hacking/basics-footprinting-reconnaissance/.
https://www.eccouncil.org/cybersecurity-exchange/ethical-hacking/basics-
footprinting-reconnaissance/.
[39] Baivab Kumar Jena, What is google dorking? the best google hacker, https:
//www.simplilearn.com/tutorials/cyber-security-tutorial/google-dorking.
https://help.archive.org/help/using-the-wayback-machine/.
[41] Rowena Johansen, Ethical hacking code of ethics: Security, risk & issues,
https://panmore.com/ethical-hacking-code-of-ethics-security-risk-issues.
https://bootcamp.du.edu/blog/the-complete-guide-to-ethical-hacking/.
[43] APIsec, Burp suite vs. owasp zap - which is better for api security testing?
https://www.apisec.ai/blog/burp-suite-vs-zap.
[44] Prashant Phatak, A comprehensive comparison of owasp zap and burp suite
https://www.valencynetworks.com/blogs/a-comprehensive-comparison-of-
owasp-zap-and-burp-suite-vulnerability-assessment-tools-part-1/.
[45] Ricahrd, Why you should use rustscan for port scanning, https:
//onlineblogzone.com/why-you-should-use-rustscan-for-port-scanning/.
95
[46] V. Aggarwal, D. Kaur, S. Mittal, T. J. S. Prasad, D. Batra, and A. Garg, A
Available: https://api.semanticscholar.org/CorpusID:86510564
https://www.zaproxy.org/docs/developer/quick-start-build/.
//github.com/RustScan/RustScan/issues/141#issuecomment-671308963.
96