QA Interview Hub · Knowledge base · Quizzes · Українська

Penetration Testing › Recon and attack surface mapping

The application map: crawling, hidden paths, attack surface

The attack surface is every place where an outside party can interact with a system. Examples: domains, ports, pages, API endpoints, parameters, forms, integrations and roles. The map is built by crawling, robots.txt, JavaScript files, OpenAPI and path discovery, separately for each role. What is not in the menu is often protected worse. The result is an inventory in which every item has an owner and a "checked" mark.

Pentest · Recon

The interface shows ten pages. How many addresses does the server actually serve?

A tester goes through scenarios from the menu and thinks they know the application. A pentester builds a map: all addresses, parameters, roles and APIs, including those that no link points to. What is not shown in the interface is often protected worse, because developers did not expect anyone to go there. This lesson covers how that map is built and the concept of the attack surface.

How it works and why. The attack surface is every place where an outside party can interact with a system: domains and hosts, open ports, pages, API endpoints, parameters, forms, file uploads, integrations with third-party services, user roles. The more such places there are, the more has to be checked, so reconnaissance ends in an inventory where each item has an owner and a “checked” mark.

Layers of the map

1. Domains and subdomains2. Hosts, ports, services3. Web application paths and parameters4. API, roles, integrationseach layer feeds the next one
Figure 3. The map is built top to bottom, and the width of each layer depends on what was found above.

The main sources for the third and fourth layers:

SourceWhat it gives
Crawling (ZAP, Burp)pages, forms, parameters
robots.txt, sitemap.xmlpaths the owner mentioned
JavaScript filesAPI paths missing from the menu
OpenAPI / Swaggera full list of endpoints
Wordlist guessing (ffuf)addresses with no links
Proxy historyreal requests and roles

Example: a map from three findings. First, robots.txt protects nothing: it asks search bots not to come in, and to an attacker it lists interesting paths.

User-agent: *
Disallow: /admin-old/
Disallow: /backup/

Second, the file app.js contains a string with an address that is not in the menu (a made-up example):

fetch('/api/internal/v1/users?role=admin')

This is a new endpoint to check: does it require authentication, does it return other people’s data, does it tell roles apart. Third, wordlist guessing:

ffuf -u https://shop.example/FUZZ \
  -w words.txt -rate 20 -mc 200,301,302,403
admin         [Status: 302, Size: 0]
backup.zip    [Status: 200, Size: 48211]
api           [Status: 301, Size: 312]

The -rate 20 parameter limits requests per second and -mc keeps the needed codes. If a site answers any address with 200 and a page of the same size (a so-called soft 404), every word will appear in the results. Then a filter by size is added, for example -fs 1532. The finding backup.zip of 48 KB is not opened or examined further than needed as proof: the report gets the fact of public access and the content is masked.

Forgotten and third-party assets. A separate class of findings is dangling DNS records. If the subdomain old.shop.example points by CNAME to a service where the application was long deleted, anyone can register that name at the service and show their own content under the company’s domain (subdomain takeover). The fix is to remove the record. Third-party components are checked too: analytics panels, widgets, payment forms (their owner is another party, so testing is only within scope).

A real case. In 2021 UpGuard researchers reported that more than 40 organizations, including government bodies, had exposed about 38 million records through Microsoft Power Apps portals: an OData-based API returned list data without authentication because of a default setting. At first Microsoft, according to the UpGuard report, called the behaviour by design, and later changed the settings so that new portals have table permissions enabled by default. This is not a penetration test but an example of how an attack surface (API addresses missing from the interface) stays open until someone walks through it. A tester who builds a map of an application with an API finds such endpoints before an attacker does.

Limits. A crawler will not get through where a login, complex JavaScript or a sequence of actions is required, so for each role the map is built separately with its session. A wordlist finds only what it contains. An automatic crawl may submit forms and change data (create hundreds of records), so in production it is limited or run on a test environment.

Common mistakes.

  • Treating robots.txt as protection: it is only a request to bots.
  • Building the map from the interface and one account only: endpoints of other roles stay invisible.
  • Not filtering soft 404 and bringing hundreds of “findings” to the report.
  • Taking a found archive or dump into work: it is enough to record the fact of access.

Check yourself

ffuf returned 200 for all 5000 words of the wordlist, the response size is the same (1532 bytes). What does this mean and what to do?

Answer

The site returns a stub page with code 200 for any address (soft 404). Filter the results by size (-fs 1532) or word count and only then look at the responses that differ.

Why is the finding “old.shop.example points by CNAME to a service where the application was deleted” considered serious?

Answer

Anyone can create an application with that name at the service and serve their own content on the company’s subdomain: phishing, theft of cookies scoped to the parent domain. It is fixed by removing the DNS record.

In an interview. Junior: “The attack surface is every point where an outside party can interact with a system. I build a map: crawling, JS files, API documentation, path guessing, and check each item”. Middle/Senior: I add: a map for every role, filtering soft 404 and a rate limit, forgotten assets and subdomain takeover, the Power Apps 2021 example where an open API lived outside the interface.

More articles in this chapter