Skip to main content
Be Bitwise

Attack Surface Analysis

Introduction to Vulnerability Research · VR Foundations track

7 min read

In this module

Mapping Where Bugs Live

Before you read a line of code or spin up a fuzzer, you need to know where in the target vulnerabilities are likely to live. Attack surface analysis is the systematic process of mapping every point where untrusted data enters the system and tracing how it moves through the code. It's how you avoid burning time on parts of the target that can't hurt you.

What Is an Attack Surface?

The attack surface of a program is the set of all points where an attacker can send data to the system or extract data from it. A smaller attack surface means fewer opportunities for an attacker; a larger one means more code to audit and more potential for flaws.

Consider a web server. Its attack surface includes:

  • Network listeners - every port the server binds to, every protocol it speaks (HTTP, HTTPS, WebSocket)
  • File parsers - configuration files, uploaded files, cached data read from disk
  • Environment variables - paths, locale settings, proxy configurations
  • IPC mechanisms - Unix sockets, shared memory, D-Bus interfaces
  • Command-line arguments - if the server can be configured via arguments

Each of these is an entry point - a place where attacker-controlled data crosses a trust boundary and enters the program's processing logic.

Identifying Entry Points

Systematically enumerate every way data enters your target. The technique depends on the type of software:

Network services - use netstat, ss, or lsof to identify listening ports. For each port, determine the protocol and trace the code that handles incoming data:

bash
# Find all listening ports for a process
ss -tlnp | grep target_process
# Trace all network-related system calls
strace -e trace=network -f -p $(pidof target_process)

File format handlers - identify which file types the program processes. Look for calls to open(), fopen(), mmap(), and then trace how the file contents are parsed. File parsers are historically among the most vulnerability-dense code.

User input handlers - for GUI applications, trace input from keyboard, mouse, clipboard, and drag-and-drop. For CLI tools, examine how argv, stdin, and environment variables are processed.

IPC receivers - look for shared memory operations (shmget, mmap with MAP_SHARED), message queues, pipes, Unix domain sockets, and platform-specific IPC like D-Bus on Linux or COM on Windows.

Cross-Privilege Entry Points

Every entry point that accepts data at a higher privilege level than the sender is especially dangerous. If a user-space application sends data to a kernel driver, or if an unauthenticated network client sends data to a root-privileged service, vulnerabilities at that boundary have maximum impact. Prioritise these cross-privilege entry points in your analysis.

Trust Boundaries

A trust boundary is a line between components that operate at different trust levels. Data crossing a trust boundary must be validated because the sender may be malicious. Common trust boundaries include:

User space to kernel - system calls are the primary trust boundary on any operating system. The kernel must validate every argument because user-space programs can pass arbitrary values. Kernel vulnerabilities at this boundary give local privilege escalation.

Network to application - data arriving from the network is completely untrusted. The receiving application must validate all aspects: length fields, format compliance, character encoding, and semantic correctness.

Unprivileged to privileged process - when a setuid binary, a system service, or a service running as root accepts input from a normal user, that input crosses a privilege boundary.

Sandboxed to unsandboxed - browser sandboxes, container boundaries, and SELinux/AppArmor policies create trust boundaries. A sandbox escape vulnerability crosses this boundary.

Here are all four on a typical Linux web server. Each dotted crossing is a place where one side must treat the other's data as hostile:

Mapping trust boundaries immediately surfaces the highest-value audit areas. A bug in code that only handles trusted internal data is a different class of problem from a bug sitting right on a trust boundary.

Threat Modelling for Vulnerability Research

Formal threat modelling frameworks like STRIDE (Spoofing, Tampering, Repudiation, Information Disclosure, Denial of Service, Elevation of Privilege) are designed for software architects, but vulnerability researchers can adapt them.

For each entry point, ask:

  • What can an attacker send? - what is the range of possible inputs? Is the format documented? Are there length constraints?
  • What assumptions does the code make? - does it assume input is well-formed? Does it check lengths before copying? Does it validate before using?
  • What happens if assumptions are violated? - will the program crash, corrupt memory, leak data, or behave incorrectly?
  • What is the impact of exploitation? - code execution, information leak, denial of service, privilege escalation?

This systematic questioning turns vague "look for bugs" into specific, testable hypotheses about where vulnerabilities might exist.

Reducing Scope to High-Value Targets

A modern software system has millions of lines of code. You cannot audit all of it. Strategic scope reduction is essential:

Parser code is always high-priority. Complex, untrusted input (network protocols, file formats, serialised data) plus complex state management is a historically productive combination. Parsers account for a disproportionate share of critical vulnerabilities.

Length and size calculations are where integer overflows and buffer overflows lurk. Any arithmetic that determines allocation size or copy count is a candidate.

Privilege transitions — setuid binaries, kernel modules, system services — have the highest impact. A bug in a setuid-root binary is a root access bug.

Unmaintained legacy code tends to have more issues than actively developed code. If your target has components that haven't been audited recently, put them near the top.

Recently changed code hasn't been tested in production yet. If you have version control access, scan commits touching security-sensitive areas in the last few months.

bash
# Find recently changed files in a git repository
git log --since="6 months ago" --name-only --format="" | \
sort | uniq -c | sort -rn | head -20
# Focus on files that handle parsing or network input
git log --since="6 months ago" --name-only --format="" | \
grep -E "(parse|decode|read|recv|handle|process)" | \
sort | uniq -c | sort -rn

Data Flow Mapping

Once you have identified entry points and high-value areas, trace how data flows from entry points to dangerous operations. This is the core analytical technique of vulnerability research.

A data flow map tracks untrusted input from the moment it enters the program (a source) to the point where it is used in a security-sensitive operation (a sink). If there is a path from source to sink without adequate validation, you may have found a vulnerability.

For example, in a web server:

  1. Source: recv() reads HTTP request from network socket
  2. Data is copied into a request parsing buffer
  3. HTTP headers are extracted by searching for \r\n delimiters
  4. The Content-Length header value is converted to an integer
  5. Sink: The integer is used as the size argument to malloc() and then memcpy()

If step 4 does not validate that the integer is reasonable (not negative, not too large, not causing overflow when used in calculations), you have a potential vulnerability. The data flow map makes this visible.

The next module covers formal source-and-sink analysis and taint tracking. For now, practise drawing these flows on paper or in a text file for your target. The intuition you build doing it manually is what makes the formal tools useful later.

Document Everything

As you analyse attack surface, write down what you find. Maintain a document listing every entry point, what data it accepts, what trust boundary it crosses, and what validation you observe (or do not observe). This documentation becomes invaluable when you are deep in analysis and need to remember the big picture, and it forms the foundation of any vulnerability report you later write.