Skip to main content

Overview

Attack surface discovery is the reconnaissance phase where Pensar Apex identifies all entry points, endpoints, services, and authentication flows in your application. This phase is critical because it determines what gets tested in subsequent penetration testing phases. Pensar Apex supports two discovery modes:

Blackbox Mode

Probes a live target from the outside with no source code access. Mimics how an external attacker would discover your application.

Whitebox Mode

Analyzes source code directly to extract routes, endpoints, and authentication flows. Provides complete coverage of your API surface.

Blackbox Attack Surface Discovery

In blackbox mode, the agent treats your application as a completely opaque system and discovers its attack surface through external observation.

Discovery Phases

The blackbox attack surface agent follows a systematic methodology:
1

Authentication (if credentials provided)

If you provide credentials, the agent authenticates first to discover protected endpoints and authenticated functionality.
2

Subdomain Enumeration (optional)

When enabled, the agent discovers subdomains using:
  • DNS brute-forcing with wordlists
  • Certificate Transparency logs
  • DNS zone transfers (if misconfigured)
3

Service Discovery

The agent probes for running services using:
  • Port scanning (nmap)
  • HTTP/HTTPS probing
  • Service fingerprinting
  • Technology detection
4

Web Crawling

For web applications, the agent:
  • Crawls HTML pages and follows links
  • Executes JavaScript to discover SPA routes
  • Extracts API endpoints from JavaScript bundles
  • Maps authentication and form flows
5

API Endpoint Discovery

The agent discovers API endpoints through:
  • JavaScript source analysis
  • Common path enumeration
  • OpenAPI/Swagger discovery
  • GraphQL introspection
6

Asset Documentation

All discoveries are documented using the document_asset tool:
  • Domains and subdomains
  • Open ports and services
  • Web pages and routes
  • API endpoints
  • Authentication mechanisms

Blackbox Agent Configuration

Blackbox Discovery Tools

The blackbox agent uses these tools:
Runs reconnaissance commands:
  • nmap for port scanning
  • dig for DNS queries
  • curl for HTTP probing
  • subfinder for subdomain enumeration
Loads web pages in a headless browser to:
  • Execute JavaScript and discover SPA routes
  • Capture rendered content
  • Follow navigation flows
Captures the DOM to:
  • Extract links and forms
  • Identify authentication mechanisms
  • Map page structure
Records discovered assets:
Generates the final report when discovery is complete. This tool triggers the stop condition.

Whitebox Attack Surface Discovery

In whitebox mode, the agent analyzes your application’s source code to extract the complete attack surface with 100% accuracy.

How It Works

When cwd is provided, Pensar Apex:
  1. Detects the framework (Express, FastAPI, Rails, Django, etc.)
  2. Extracts routes from framework-specific routing files
  3. Maps endpoints to their HTTP methods and parameters
  4. Identifies authentication requirements and middleware
  5. Cross-references with the live target to verify accessibility

Supported Frameworks

Express.js

  • Route definitions
  • Middleware chains
  • REST and GraphQL

FastAPI

  • Path operations
  • Pydantic schemas
  • OAuth2 flows

Django

  • URL patterns
  • Class-based views
  • Django REST Framework

Ruby on Rails

  • routes.rb definitions
  • Controller actions
  • API mode endpoints

Spring Boot

  • @RequestMapping
  • @RestController
  • Spring Security

Next.js

  • App Router routes
  • API routes
  • Server Actions

Whitebox Output Example

Attack Surface Output

Both modes produce an AttackSurfaceResult:

What Gets Mapped

  • REST API endpoints
  • GraphQL endpoints
  • WebSocket connections
  • gRPC services
  • HTTP methods (GET, POST, PUT, DELETE, etc.)
  • Query parameters and request bodies

Scope Control

Control what the agent discovers with scope constraints:
Strict scope mode prevents the agent from scanning outside allowed hosts. This is essential for bug bounty programs and production testing where scope violations can have serious consequences.

Authentication During Discovery

If you provide credentials, the agent will authenticate before discovering the attack surface:
The agent will:
  1. Authenticate using the provided credentials
  2. Export the authenticated session (cookies, tokens)
  3. Use the session for all subsequent discovery
  4. Include authentication info with high-priority targets

Prioritization

The agent automatically prioritizes targets based on:
  • Risk factors: Admin panels, API endpoints, file uploads, authentication flows
  • Technology indicators: Outdated frameworks, known vulnerable libraries
  • Complexity: Endpoints with many parameters, complex authentication
  • Exposure: Publicly accessible vs. authenticated-only

Best Practices

  • Use blackbox for external security assessments and bug bounties
  • Use whitebox for internal testing and pre-deployment validation
  • Consider running both modes to compare coverage
  • Always provide credentials if the application has authentication
  • Authenticated discovery finds 3-5x more endpoints than unauthenticated
  • Include all user roles to discover role-specific endpoints
  • Enable strictScope for production environments
  • Test scope configuration with a dry run first
  • Document excluded paths and rationale
  • Manually inspect the attack surface report
  • Verify that critical endpoints are discovered
  • Check for false positives in asset list
  • Adjust scope and re-run if needed

Example: Complete Discovery Flow

Agent Architecture

Learn about the agent system that powers attack surface discovery

Penetration Testing

Use discovered targets for vulnerability testing

Session Management

Understand how sessions store discovery results

API Reference

Complete API documentation for attack surface agents