Reader small image

You're reading from  Defending APIs

Product typeBook
Published inFeb 2024
PublisherPackt
ISBN-139781804617120
Edition1st Edition
Right arrow
Author (1)
Colin Domoney
Colin Domoney
author image
Colin Domoney

Colin Domoney (BSc. MSc. CSSLP, CEH) is an API Security Research Specialist and Developer Advocate with deep expertise in the development of secure software. As VP of AppSec, he took on the challenge of securing software on a large scale and running the global AppSec program at Deutsche Bank. At Veracode, as an evangelist, he produces countless webinars, and blog posts, and speak globally at conferences. Currently, he has embraced the challenge of securing APIs with 42Crunch where he has produced the API industry's first security maturity model and contributed to numerous webinars, talks, and blogs. Currently, he is working on the industry's first defensive API developer training course. He is also the curator of the APISecurity weekly newsletter.
Read more about Colin Domoney

Right arrow

Discovering APIs

In the previous chapter, we explored the foundations of attacking APIs, focusing on many of the tools that attackers use. In this chapter, we’ll use these skills to learn how to discover APIs in the real world. We will learn how to discover APIs using passive methods (where we do not interact with the API directly) and active methods (where we interact with the API directly). We will also learn how to find details of how the API is implemented and how to use this knowledge to attack an API.

For an API defender, it is important to understand the techniques used by your adversaries in discovering your APIs so that you can implement defensive measures to prevent easy discovery and further analysis. In particular, defenders should pay attention to attackers’ techniques in identifying implementation details and use this knowledge to harden their implementations.

For an API attacker, a thorough reconnaissance process provides useful information about...

Technical requirements

For this chapter, you will need a development machine capable of the following:

  • Running Docker locally
  • Running VS Code with various marketplace extensions
  • Access to the internet and a GitHub account to access the examples

This chapter contains many code samples in various languages; these can either be run locally, which will require the installation of compilers, SDKs, and frameworks, or from within a Docker build container.

The example code and various breaking changes to the instructions can be found in the Chapter 6 folder on the book’s GitHub repository here: https://github.com/PacktPublishing/Defending-APIs/tree/main/Chapter6

Passive discovery

In the first section of this chapter, we will investigate various methods of the passive discovery of APIs. Not surprisingly, the techniques involve utilizing different search engines or online repositories to mine useful API metadata.

The finer details of a passive discovery phase will be determined by the target in mind. Sometimes the intent will be to search far and wide (for example, try and identify all APIs that an organization owns) and gain as much information as possible about the number of exposed targets available on the public internet. For example, let’s imagine you are attempting to exploit the API of a new router with a vulnerability—in this case, you will probably be attempting to find online instances with public IP addresses.

In other scenarios, you may know about a particular exploit and want to gain a deeper knowledge of using the exploit in practice. You might use a more narrow and deep strategy (for example, identify only...

Active discovery

We will now look at various techniques for the active discovery of APIs in the real world. By active, we mean that we will interact with the API and/or its network by monitoring the traffic or directly accessing the API or its host.

Note – ensure that you have permission to access the computing resources

The use of active discovery using the tools and techniques described in this section may be against the terms and conditions of use of various services, ranging from your ISP to the relevant cloud hosting service. If you are unsure whether you are authorized to perform such scanning, you should err on the side of caution and seek explicit permission. In many cases, such scanning may also be against the applicable laws within your country, and any violations may have serious consequences. Fortunately, many of the scenarios described can easily be recreated in a laboratory environment that is totally under your control.

Network discovery and scan

Typically...

Implementation analysis

Finally, we will conclude this chapter with some tips on how to glean additional information about the implementation of the API’s server, including the host OS and the libraries and frameworks used, including version numbers. Such information can be immensely useful when attempting to reverse-engineer an API.

Verbose error and debug messages

The first category is the now infamous (due to the high instances of information leakage via this method) error category of excessively verbose error and debug messages. Application developers include various levels of diagnostic information to aid in the debugging of applications in the field. Users can capture the log and send it to the support team for analysis. Unfortunately, such logging can be overly verbose and, along with useful debug information, can also divulge the specifics of the inner workings of the application and details of the implementation.

As an example, consider the commonly encountered...

Summary

This chapter took us on a complete journey from zero knowledge of a target right through to being able to determine the version of the database used. The passive reconnaissance techniques principally used Google and the query operators, as well as the Shodan database, to determine a range of likely candidate targets for exploration.

We learned how to use active reconnaissance to actively focus on the API implementations on the hosts by examining their behavior under live probing using nmap or Massscan, while OWASP ZAP can provide a wealth of insight using spider scanning. Finally, we learned how to use information leakage to gain insight into the inner details of the implementation, allowing us to understand details such as the host OS and database.

By conducting a thorough discovery phase, you will have placed yourself in a perfect position to move on to the final chapter in the section—on attacking APIs.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Defending APIs
Published in: Feb 2024Publisher: PacktISBN-13: 9781804617120
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Colin Domoney

Colin Domoney (BSc. MSc. CSSLP, CEH) is an API Security Research Specialist and Developer Advocate with deep expertise in the development of secure software. As VP of AppSec, he took on the challenge of securing software on a large scale and running the global AppSec program at Deutsche Bank. At Veracode, as an evangelist, he produces countless webinars, and blog posts, and speak globally at conferences. Currently, he has embraced the challenge of securing APIs with 42Crunch where he has produced the API industry's first security maturity model and contributed to numerous webinars, talks, and blogs. Currently, he is working on the industry's first defensive API developer training course. He is also the curator of the APISecurity weekly newsletter.
Read more about Colin Domoney