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:Authentication (if credentials provided)
If you provide credentials, the agent authenticates first to discover protected endpoints and authenticated functionality.
Subdomain Enumeration (optional)
When enabled, the agent discovers subdomains using:
- DNS brute-forcing with wordlists
- Certificate Transparency logs
- DNS zone transfers (if misconfigured)
Service Discovery
The agent probes for running services using:
- Port scanning (nmap)
- HTTP/HTTPS probing
- Service fingerprinting
- Technology detection
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
API Endpoint Discovery
The agent discovers API endpoints through:
- JavaScript source analysis
- Common path enumeration
- OpenAPI/Swagger discovery
- GraphQL introspection
Blackbox Agent Configuration
Blackbox Discovery Tools
The blackbox agent uses these tools:execute_command
execute_command
Runs reconnaissance commands:
nmapfor port scanningdigfor DNS queriescurlfor HTTP probingsubfinderfor subdomain enumeration
browser_navigate
browser_navigate
browser_snapshot
browser_snapshot
Captures the DOM to:
- Extract links and forms
- Identify authentication mechanisms
- Map page structure
document_asset
document_asset
Records discovered assets:
create_attack_surface_report
create_attack_surface_report
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
cwd is provided, Pensar Apex:
- Detects the framework (Express, FastAPI, Rails, Django, etc.)
- Extracts routes from framework-specific routing files
- Maps endpoints to their HTTP methods and parameters
- Identifies authentication requirements and middleware
- 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 anAttackSurfaceResult:
What Gets Mapped
- Endpoints
- Pages
- Authentication
- Infrastructure
- 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:Authentication During Discovery
If you provide credentials, the agent will authenticate before discovering the attack surface:- Authenticate using the provided credentials
- Export the authenticated session (cookies, tokens)
- Use the session for all subsequent discovery
- 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
Choose the Right Mode
Choose the Right Mode
- 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
Provide Authentication
Provide Authentication
- 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
Control Scope Carefully
Control Scope Carefully
- Enable
strictScopefor production environments - Test scope configuration with a dry run first
- Document excluded paths and rationale
Review Discovery Results
Review Discovery Results
- 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
Related Resources
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

