My Favorite API Hacking Vulnerabilities & Tips

NahamSec
24 Jun 202410:07

Summary

TLDRAPIs are crucial in web security, and understanding how to identify vulnerabilities is essential for bug bounty hunters, pentesters, and security enthusiasts. The video highlights key API vulnerabilities, including authentication flaws, authorization issues, and improper content type handling. It provides practical tips for finding leaked credentials on platforms like GitHub and Postman, and emphasizes the importance of thorough testing for privilege escalation and unauthenticated access. The video also touches on advanced techniques like using X-Forwarded-For headers to bypass authentication and the significance of correctly set content types in preventing XSS attacks.

Takeaways

  • πŸ˜€ APIs are a common target for finding vulnerabilities, important for bug bounty hunters, pentesters, and web security enthusiasts.
  • πŸ“š An update to the Udemy course on web security is available, with new content on XSS, CSP, CSRF, and more.
  • πŸ” The speaker emphasizes the importance of looking beyond the generic OWASP Top 10 vulnerabilities when examining APIs.
  • πŸ”‘ Authentication vulnerabilities are often overlooked, but can be found by searching for leaked credentials on GitHub or Postman.
  • πŸ” Using tools like 'porsch pirate' on Postman can help uncover API specs with hardcoded keys, leading to potential vulnerabilities.
  • 🚫 Authentication can sometimes be bypassed using 'X-Forwarded-For' headers, which can reveal different application behaviors.
  • πŸ‘₯ Authorization vulnerabilities involve testing for access to endpoints that should be restricted, with severity levels varying based on who can access them.
  • πŸ”„ Privilege escalation testing involves comparing the functionality accessible to different user levels within an application.
  • πŸ“ Documentation is key for understanding the correct access controls for different user types in applications.
  • πŸ›‘ Misconfigurations in content type handling can lead to XSS vulnerabilities if HTML is returned within a JSON response.
  • πŸ”Ž Fuzzing API endpoints for parameters that might return raw input can reveal overlooked vulnerabilities.

Q & A

  • Why is it important to understand API vulnerabilities?

    -Understanding API vulnerabilities is crucial for bug bounty hunters, pentesters, and web security enthusiasts because APIs are ubiquitous and can have many hidden bugs. Knowing how to approach and find these vulnerabilities allows for more comprehensive security assessments.

  • What is the significance of the OWASP Top 10 in the context of APIs?

    -The OWASP Top 10 is significant because it highlights common vulnerabilities such as XSS, IDORs, and SSRF that are not only relevant to traditional web applications but also applicable to APIs. This helps security professionals to know which vulnerabilities to look for in API testing.

  • Why do authentication vulnerabilities pose a challenge for many hackers?

    -Authentication vulnerabilities pose a challenge because they often involve finding ways to bypass or manipulate the login process, which can require advanced techniques and a thorough understanding of the system. Many hackers may be intimidated by the need for credentials or may not know where to look for them.

  • What are some common methods to find API credentials?

    -Common methods to find API credentials include searching GitHub repositories, examining Postman collections, and looking for leaked credentials or specific header names and cookie values that might contain sensitive information.

  • How can the X-Forwarded-For header be used to bypass authentication?

    -The X-Forwarded-For header can be used to bypass authentication by spoofing the IP address to match those whitelisted by the application, such as localhost or a specific VPN range. This can trick the application into granting access based on the perceived IP address.

  • What is the difference between authentication and authorization in API security?

    -Authentication is the process of verifying the identity of a user, typically through login credentials. Authorization, on the other hand, determines what resources a user is allowed to access after they have been authenticated.

  • What are some common authorization vulnerabilities?

    -Common authorization vulnerabilities include unauthenticated paths that reveal sensitive information and improper privilege escalation, where lower-privileged users gain access to functions or data meant for higher-privileged users.

  • Why is testing for different user privilege levels important?

    -Testing for different user privilege levels is important because it helps identify improper access controls. By ensuring that only authorized users can perform certain actions, you can prevent lower-privileged users from accessing sensitive functionalities or data.

  • How can content type misconfigurations lead to vulnerabilities in APIs?

    -Content type misconfigurations can lead to vulnerabilities if an API returns HTML content within a JSON response, potentially allowing stored XSS attacks to succeed if the HTML content is rendered by the browser.

  • What is a useful tool mentioned for finding API credentials and how does it work?

    -Postman, along with a tool like 'Porsch Pirate,' is mentioned as useful for finding API credentials. These tools can search for company names and related assets, potentially revealing hardcoded API keys in publicly available Postman collections.

Outlines

00:00

πŸ” Exploring API Vulnerabilities and Udemy Course Update

The speaker begins by emphasizing the importance of understanding APIs and their vulnerabilities for bug bounty hunters, pentesters, and web security enthusiasts. They announce an update to their Udemy course, which now includes new content on various web security topics such as XSS, CSP, CSRF, and more. The course is available for free to existing Udmi members and can be accessed at a discount for new subscribers. The speaker then shifts focus to discussing common vulnerabilities found in APIs, such as XSS, IDORs, and SSRF, which are also applicable to traditional applications. They aim to provide a deeper approach to API hacking beyond the generic OWASP Top 10 vulnerabilities.

05:01

πŸ”‘ Authentication Flaws and Bypass Techniques in APIs

The speaker delves into authentication vulnerabilities within APIs, which often deter hackers due to the requirement of credentials. They suggest using GitHub to search for leaked credentials by inputting the API's URL and looking for any exposed keys or unique cookie values. Additionally, the speaker introduces the use of Postman and tools like 'porsch pirate' to find hardcoded API keys in public API specifications. They also discuss the potential of using 'X-Forwarded-For' headers to bypass authentication by mimicking trusted IP addresses. The speaker shares a personal anecdote where this technique led to the discovery of additional vulnerable endpoints.

πŸ›‘οΈ Authorization Issues and Testing for Privilege Escalation

The speaker explains the difference between authentication and authorization, focusing on the latter. They discuss finding unauthorized access points (unauthenticated APIs) that may leak sensitive information or require elevated access. The speaker advises removing authentication tokens to test if an endpoint can be accessed without proper authorization, a method that has helped them escalate the severity of vulnerabilities. They also suggest testing privilege escalation across different user levels within an application, such as comparing the access rights of an admin, a manager, and a regular user, to uncover misconfigurations in access controls.

🎯 Hunting for Misconfigured Content Types and XSS Opportunities

The speaker highlights the often-overlooked vulnerability of misconfigured content types in API responses. They point out that while JSON is the expected format, APIs sometimes return HTML content, which can lead to XSS attacks if not handled properly. The speaker encourages finding API endpoints that return HTML content types and then determining how to inject user input into the response while the content type is set to HTML. They describe this as a fun and rewarding challenge that has led to the discovery of significant vulnerabilities, often missed by others due to a lack of attention to detail.

Mindmap

Keywords

πŸ’‘API

API stands for Application Programming Interface. It is a set of rules and protocols for building and interacting with software applications. In the context of the video, APIs are the focus for finding vulnerabilities, which is crucial for web security enthusiasts, bug bounty hunters, and pentesters. The script mentions the importance of understanding APIs to uncover potential security flaws.

πŸ’‘Vulnerabilities

Vulnerabilities refer to weaknesses in a system that can be exploited by hackers to gain unauthorized access or perform malicious actions. The video's theme revolves around identifying such vulnerabilities within APIs, which is a significant aspect of web security and the focus of the speaker's expertise.

πŸ’‘Bug Bounty Hunter

A bug bounty hunter is an individual who is rewarded for discovering and reporting bugs, particularly security vulnerabilities, in a system. The script positions the audience as potential bug bounty hunters, emphasizing the importance of finding API vulnerabilities to benefit from such rewards.

πŸ’‘Web Security Enthusiast

A web security enthusiast is someone who is passionate about learning and improving web security practices. The video script is directed at this audience, aiming to educate them on how to find and exploit vulnerabilities in APIs for the purpose of enhancing security.

πŸ’‘OAS Top 10

OAS Top 10 refers to the Open Web Application Security Project (OWASP) Top 10, a list of the most critical web application security risks. The script mentions this list to highlight common vulnerabilities that should also be considered when examining APIs.

πŸ’‘Authentication

Authentication is the process of verifying the identity of a user or device. The video discusses how to approach APIs that require authentication, including finding credentials and using techniques like X-Forwarded headers to bypass authentication mechanisms.

πŸ’‘XSS

XSS stands for Cross-Site Scripting, a type of security vulnerability that allows attackers to inject malicious scripts into trusted websites. The script mentions XSS as one of the vulnerabilities to look for in APIs, emphasizing the importance of content security policies.

πŸ’‘CSRF

CSRF stands for Cross-Site Request Forgery, an attack that tricks a user's browser into making an unwanted action on a website they are authenticated with. The video script includes CSRF as one of the vulnerabilities that can be found in APIs, which is relevant to the discussion on web security.

πŸ’‘Authorization

Authorization is the process of giving permission to users to access certain resources or perform certain actions within a system. The script differentiates between authentication and authorization, discussing how to find vulnerabilities related to unauthorized access to resources.

πŸ’‘Privilege Escalation

Privilege escalation is the act of exploiting a bug or vulnerability to gain higher-level access rights in a system than the original permissions. The video script suggests testing for privilege escalation among different user types to uncover authorization vulnerabilities.

πŸ’‘Content-Type

Content-Type is an HTTP header used to indicate the nature of the content being transferred. The script highlights the importance of examining the Content-Type of API responses, as incorrect handling can lead to vulnerabilities such as reflected XSS when HTML content is returned in a JSON response.

Highlights

APIs are everywhere and understanding how to approach them is crucial for finding vulnerabilities.

New content has been added to the Udemy course, including updates on XSS, CSP, CSRF, and more.

APIs can have the same vulnerabilities as traditional applications, such as XSS and IDORs.

Authentication vulnerabilities in APIs can be discovered by searching GitHub for leaked credentials.

Unique cookie values or header names can be indicators of potential vulnerabilities.

Postman is an underutilized resource for finding API credentials and specifications.

X-Forwarded-For headers can be used to bypass authentication mechanisms.

Authorization vulnerabilities involve testing for unauthenticated access to sensitive endpoints.

Privilege escalation testing involves checking access levels across different user types.

Content type vulnerabilities in APIs can occur when HTML is returned within a JSON response.

Fuzzing API endpoints can reveal parameters that lead to error responses with user input.

Top hackers pay attention to small details such as content types to find vulnerabilities.

The video offers a deeper approach to hacking APIs beyond traditional web vulnerabilities.

The importance of not being intimidated by authentication requirements in APIs.

The potential for increased bounty rewards by escalating access through authorization vulnerabilities.

The call to action for viewers to request more in-depth videos on path traversal or GraphQL.

The encouragement for viewers to like, subscribe, and engage with the content for future videos.

Transcripts

play00:00

apis are everywhere and if you don't

play00:02

know how to approach an API and find

play00:04

vulnerabilities then you are definitely

play00:07

missing out in a lot of bugs whether

play00:08

you're bug bounty hunter pentester or

play00:10

just a web security Enthusiast before we

play00:12

jump into the video though I'm going to

play00:13

quickly do a Shameless plug a lot of you

play00:15

guys have been asking for an update to

play00:16

the udmi course it is here if you have

play00:18

udmi access already it is there you can

play00:20

go get it for free it's a part of what

play00:22

you have purchased for in the past if

play00:23

you don't have access you want to get it

play00:25

there's a ton of new content on xss CSP

play00:28

client side vones csrf you name it it is

play00:31

also going to be updated three more

play00:32

times in the next 6 months all you have

play00:34

to do is click on the link down in the

play00:36

description or the pin comments and get

play00:38

it for half off as of today all right

play00:40

now let's jump into the video well in

play00:42

this video I want to talk about some of

play00:43

my favorite vulnerabilities that I look

play00:45

for in an API how to look for him how to

play00:47

approach him and why are these the ones

play00:49

that I go through starting with your

play00:51

generic OAS top 10 because I want to get

play00:53

this out of the way but the generic o

play00:55

top 10 is the vulnerabilities like your

play00:56

xss your idors you want to look for your

play00:58

ssrf any abilities that you would find

play01:01

in a traditional application you also

play01:04

want to look for those in an API because

play01:06

the API is the backend of this system so

play01:10

any vulnerabilities that is covered in

play01:12

an OAS top 10 or any version of OAS top

play01:15

10 then it is kind of also applicable to

play01:18

uh an API I don't want to cover this

play01:20

because I feel like there's a lot of

play01:21

content around looking for these

play01:24

traditional web WS on an API so I want

play01:27

to kind of take a deeper approach to

play01:28

hacking API and kind of show you what is

play01:31

the vulnerability that I look for so I

play01:32

wanted to kind of get that out of the

play01:33

way but now let's talk about the

play01:35

additional vulnerabilities starting with

play01:37

looking at authentication

play01:39

vulnerabilities because authentication

play01:40

is a thing that I think scares off a lot

play01:42

of hackers when it comes down to looking

play01:44

for vulnerabilities and by that I mean a

play01:46

lot of times hackers find an API where

play01:48

they can't authenticate to maybe it

play01:50

requires some credentials and a lot of

play01:52

people actually don't look for them and

play01:54

there's a lot of ways you can actually

play01:55

do that the obvious approach to looking

play01:57

for credentials for an API is just

play01:59

obviously going on GitHub doing the

play02:00

generic putting the URL of that website

play02:03

or that specific API into the search and

play02:06

looking and seeing if anything has been

play02:07

leaked but that only works if that

play02:10

specific domain or subdomain has been

play02:12

mentioned in a repo and if it has then

play02:15

you can look for this keys and pull them

play02:16

out and use them but also the other

play02:18

thing that you can do is looking at

play02:19

specific header names or cookie value so

play02:21

if a cookie value has something very

play02:23

unique to this application or to this

play02:25

website or this company also you want to

play02:26

look for that and see if you can't find

play02:28

anything but I feel like GitHub is been

play02:30

the easiest to clean up a lot of

play02:32

companies are more aware of leaking

play02:33

credentials on GitHub and a lot of

play02:35

hackers are looking for it but I think

play02:36

something that's not fully covered yet

play02:38

is Postman actually you can go on

play02:39

Postman and use something like porsch

play02:41

pirate I think that's what the tool is

play02:42

called it's been an amazing one that

play02:43

it's in my toolkit that I use but you

play02:45

can just type in a search for a company

play02:47

name and relate it to this specific

play02:48

asset but this is just also very noisy

play02:50

so you have to do a lot of manual work

play02:52

or just have some scripts or wrappers

play02:54

around this tool that's going to clean

play02:56

it up and give you better results but

play02:57

Postman is a really good place because a

play02:59

lot of times people just dump their API

play03:01

specs into a file and then they just

play03:03

post it on post man.com and they forget

play03:05

that their keys may have been hardcoded

play03:06

this has got me some really cool

play03:08

bounties and even if I haven't gotten

play03:09

any bounties then it's giving me access

play03:11

to a lot of cool assets that I've played

play03:13

around with and it's generated leads for

play03:15

me so keep that in mind that is one

play03:17

approach you can look at Postman GitHub

play03:19

past spins go on Google and do some

play03:21

Google dking but always remember that

play03:23

there's always a way to get into these

play03:25

applications whether it's self-

play03:26

registration or looking for credentials

play03:28

so if you see something that requires

play03:29

you to be authenticated don't get scared

play03:31

find a way to get authenticated the

play03:32

second one and it's kind of hand inand

play03:34

with this specific vulnerability type is

play03:37

using X forwarded like headers to bypass

play03:40

authentication because sometimes a lot

play03:42

of these applications are whitelisting

play03:44

or allowing specific IP addresses

play03:46

whether that's a local host or whether

play03:48

is the range of the VPN that this

play03:51

company uses so if you can find a way of

play03:53

finding out what is the IP range that

play03:55

they use or you can Brute Force for it

play03:56

or just maybe put Local Host in there

play03:58

this will get you past the first authen

play03:59

iation mechanism and then you have to

play04:01

battle the whatever is behind that

play04:03

specific authentication method so one of

play04:05

the examples that I have recently in my

play04:07

Discord some of the hackers that I work

play04:08

with found this asset on a bug Bounty

play04:10

program and not I was authenticated and

play04:12

somehow somebody put an X forwarded for

play04:14

header on there and it's put out a

play04:16

different error message than the one

play04:17

that we were seeing previously and by

play04:19

seeing the different behavior on the

play04:22

application based on this specific

play04:24

Heather then we were able to log in and

play04:26

feed that application into FFF and then

play04:28

find additional endpoints points that

play04:30

were vulnerable so that's one example of

play04:32

it that you can do so maybe your

play04:34

approach to getting authenticated isn't

play04:36

to find credentials or to sign up and

play04:38

get a actual uh cookie but you can find

play04:41

other headers including x44 and

play04:44

everything else that's similar to it

play04:45

that will list down below that you can

play04:47

use to bypass authentication so far we

play04:50

have taken care of authentication and

play04:52

now we need to talk about authorization

play04:54

there's a difference between the two

play04:55

authentication is how you log in how you

play04:57

get past the login on this application

play05:00

versus authorization to me is being

play05:02

authorized to use a specific resource

play05:05

with authorization there's two different

play05:06

vulnerability types that come in the

play05:08

first one just being looking for onof

play05:11

pads which means unauthenticated pads

play05:13

you can access that may have juicing

play05:16

information and require to be authorized

play05:18

or have some sort of a leverage access

play05:21

to be able to access that so for example

play05:23

think about a endpoint that may be maybe

play05:26

a list of users that this application is

play05:29

supposed to have access to but somehow

play05:31

or just by directly going to that list

play05:33

you can get a list of that user for that

play05:35

application you want to look at that

play05:36

because the difference between reporting

play05:38

that vulnerability as a hey information

play05:40

disclosure it leaks a list of users

play05:42

versus hey information disclosure it

play05:45

leaks the list of users to an onof user

play05:48

those two have different severity levels

play05:50

and and obviously you want to make sure

play05:51

you look out for those so anytime you

play05:53

find a vul ability or you find an

play05:54

endpoint that is Juicy that is

play05:56

interesting it doesn't have to be a get

play05:58

request it could actually be a post you

play05:59

can just remove the cookie or you can

play06:00

remove your o token or the beer token

play06:03

whatever it is that you're authorizing

play06:04

yourself within the application and see

play06:06

if you can access that inpoint without

play06:08

the authorization header that has been a

play06:11

good place for me to double my bounties

play06:13

or actually escalate my bounties so keep

play06:15

that in mind but there's also another

play06:17

approach to authorization the second

play06:19

layer of authorization isn't applicable

play06:21

to a lot of apis but my favorite thing

play06:24

to do with authorization vulnerabilities

play06:26

is testing privilege escalation with

play06:29

different users so this is kind of

play06:30

similar to the last one but it requires

play06:32

this to have different user types so for

play06:34

example think of this as an HR program

play06:36

this HR program or application allows

play06:39

you to have maybe a member a manager and

play06:41

maybe some HR Manager for example you

play06:43

want to be able to test out every single

play06:45

functionality within each of those

play06:48

different user levels and see which ones

play06:50

you have access to which ones you can

play06:51

use and which ones you cannot use a lot

play06:53

of times I feel like a lot of

play06:54

organizations introduce new

play06:56

functionalities into these applications

play06:58

and they completely forget to look for

play07:00

the different access controls or

play07:01

different access levels that these users

play07:03

have actually Archangel Douglas day has

play07:06

a really good talk from the hamcon last

play07:07

year that he did on this I'll link it

play07:09

down below take a look at it but the

play07:10

approach to this is you make a list of

play07:12

all the different functionalities

play07:13

starting with the admin the highest

play07:15

level of access that you have and then

play07:16

you look at the different documentation

play07:18

and you mark which ones are supposed to

play07:20

have access to what so for example if

play07:22

you have something like submit an

play07:23

expense you want to make sure that you

play07:24

know an admin can submit an expense and

play07:26

a user can insult on a manager so those

play07:28

are applicable to to three users but

play07:30

maybe the different functionality that

play07:32

isn't meant to be for all three is

play07:33

adding a user to the organization maybe

play07:35

the admin is the only one that can do

play07:36

that not the manager and not the

play07:37

different users that you have but you

play07:39

want to test out that functionality with

play07:40

the other two lower level privileges so

play07:43

that is a really good place it's very

play07:44

very manual and it's a lot of like work

play07:46

to do but a lot of people skip it

play07:48

because it's it's a lot of Labor it's a

play07:49

lot of time but that's why you find

play07:51

better bugs if you spend the time to

play07:53

actually understand the application and

play07:55

understand the logic of this application

play07:56

in order to look for vulnerabilities and

play07:58

I kept the best for Last by keeping the

play08:00

xss or maybe not even xss per se but

play08:04

looking at the content type of these

play08:06

apis for last because that is also one

play08:08

of the most underrated vulnerability

play08:10

types that a lot of people miss and

play08:11

that's because when you're interacting

play08:13

with an API a lot of times you expect

play08:14

the API to return a value in Json format

play08:18

and if you're not familiar with this any

play08:19

API that comes back it's supposed to

play08:20

give you a text it's supposed to be Json

play08:22

and if you have HTML within a Json

play08:24

content type then that HTML is not going

play08:27

to render but what I've noticed a lot of

play08:28

times is companies actually mess this up

play08:31

and they return an HTML within that

play08:33

response then the HTML will render and

play08:34

if you put cross scripting there it

play08:36

could fire the challenge here is to find

play08:38

a way for your HTML to get in the

play08:40

response sometimes you can't do that

play08:42

because of the uh nature of the

play08:43

application but that is what makes it

play08:45

really really fun so the first thing you

play08:47

want to do here is you want to find a

play08:49

API end point that returns as the

play08:51

content type set to HTML then you want

play08:53

to find how can I get my input whether

play08:55

it's my path maybe it's something that I

play08:57

put in the post data or in the get

play08:58

request how can I get this input to

play09:01

reflect in the response while the

play09:04

content type is set to HTML those make

play09:06

for some really really cool vs and a lot

play09:07

of cool challenges and then fuzzing that

play09:09

endpoint and seeing if there are any

play09:11

parameters or any way of getting an

play09:13

error that's going to just return

play09:15

whatever you have given it in the

play09:16

response they've been really really cool

play09:17

I found a ton of those in the past

play09:19

they're still very very valid but I feel

play09:21

like a lot of hackers missed that

play09:22

because you have to pay attention to the

play09:24

content t and a lot of time people don't

play09:26

look at it in that's why a lot of the

play09:27

top hackers and a lot of the better

play09:29

hackers

play09:29

when because they are paying attention

play09:31

to small details but that's pretty much

play09:33

all the ru and ability that I think I

play09:35

want to cover for this episode there is

play09:37

one more there is path traversal if you

play09:39

want to see a full video on path

play09:40

traversal or graphql next drop me a

play09:43

comment maybe I'll do one or the other

play09:44

maybe I do both that depends on how many

play09:46

comments we get so drop me a comment let

play09:47

me know which one you want to see next

play09:49

and if you haven't already do me a favor

play09:51

hit that like hit that subscribe button

play09:53

and becomeing that homie and I will see

play09:54

you all in the next video peace

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
API SecurityBug BountyWeb HackingAuthenticationAuthorizationXSSContent TypeVulnerability TestingSecurity EnthusiastPenetration Testing