A threat model lists paths from attackers to your assets. The attack surface is the other side of the same picture: the full set of those entry points. Two things matter about it. You can measure it, and you can usually make it smaller.
What counts as surface
Think of a house. Surface is every door, window, vent and delivery slot, whether or not you remember it is there. A computer system has the same kinds of openings.
| Kind | Examples | Question to ask |
|---|---|---|
| Network | Open ports, public web pages, remote login | What can be reached from outside this machine? |
| Software | Installed programs, libraries, plugins, browser extensions | What code runs here, and who wrote it? |
| Input | Forms, file uploads, API requests, emails | What can strangers send, and what does the program do with it? |
| Accounts and people | Logins, shared passwords, staff who can be tricked | Who or what can authenticate, and how well? |
| Data in motion and at rest | Backups, logs, exports, copies on laptops | Where does a copy of the secret exist? |
Every item is a place where a flaw might live. This leads to the idea that guides the rest of the lesson: an unneeded thing is pure cost. It cannot help you, it can only hurt.
Seeing a network surface
From the foundations level, a port is a numbered door on a computer where a program listens for connections. A program listening on a port is a service. Services can listen in two ways:
- On
127.0.0.1(also writtenlocalhost): reachable only from the same machine. - On
0.0.0.0or*: reachable from any network the machine is connected to.
That difference is the difference between a window inside your house and a door onto the street. A database that listens only on localhost cannot be probed by the coffee-shop network. The same database listening on every interface can.


Four moves that shrink it
- Remove. Uninstall the program, delete the account, close the port, switch off the feature. This is the strongest move because nothing remains to attack.
- Restrict. If it must exist, narrow who can reach it: bind to localhost, allow only certain addresses, require a login, give it fewer permissions (the least-privilege lesson comes at the end of this level).
- Patch. Keep what remains up to date, since known flaws in old software are the most reliable entry. The next lessons cover why this is harder than it sounds.
- Watch. For surface you must keep exposed, log it and look at the logs, as you practised earlier in this course.
The order matters. People reach for "watch" first because it feels like doing security, but removing a door is better than guarding it.
A test database was left running on a server and listens on every network interface, though nothing uses it. Which of the four moves fits best?
Remove: stop and uninstall it. If it were needed, you would restrict it to localhost. Patching or monitoring something that serves no purpose is wasted effort.
A real shape of the problem
Surface grows quietly. A team adds a debug page for one afternoon and forgets it. A developer installs a tool "just to try it". An old test account keeps working after the project ends. None of these is a decision to take a risk; they are the absence of a decision to clean up. This is why security people keep inventories: a current list of what exists, because you cannot reduce a surface you cannot see. The next lesson shows a real vulnerability record for a product whose administrative console was reachable in a way its owners never intended.
How AI changes this
Attackers measure surface faster. Scanning the internet for exposed services was already automated; AI makes it cheaper to write the glue around scanners, read what each service reports, and decide what to try next. The practical consequence is simple: a forgotten exposed service is found sooner. Beam's write-up of the month's attacks, AI-led attacks in October 2026, notes that old weaknesses such as exposed admin panels and unpatched edge devices still decided outcomes in almost every case it covered. The surface did not become new; the speed of finding it did.
An AI agent adds surface of a new kind. An agent has an attack surface made of two things:
- What it reads. Every web page, document, issue comment, or tool description that enters its context is an input channel. Text there can carry instructions the agent might follow (). So the reading list is part of the surface, not just the ports.
- What it can do. Each tool it can call, each server connected, each folder it can write and each credential in reach is a capability an attacker would love to borrow. See Beam's practical guide to MCP security for how tool connections widen this.
The shrink-the-surface moves translate directly. Remove tools and connections the task does not need. Restrict the agent to one project folder and short-lived, narrow credentials. Patch the agent software and its plugins. Watch its commands and file access.
Defenders can inventory with AI. Models are decent at reading a configuration or a scan result and summarising "these four things look unnecessary". Use that as a to-do list for a human to check; a model that is wrong about what is safe to switch off can cause an outage.
Try it
This lab only reads information about your own machine. It changes nothing.
On macOS:
lsof -iTCP -sTCP:LISTEN -n -P
On Linux:
ss -tlnp
Each line is a service waiting for connections. Find the address column. For each line, note whether it says 127.0.0.1 (or localhost) or * / 0.0.0.0. Make a small table:
program port reachable from do I need it?
Look up any program you do not recognise before doing anything. If one is listening on all interfaces and you do not need it, the right fix is to quit that program or change its setting to listen on localhost, not to leave it. Do not stop system services you do not understand; write the question down instead.
As a second pass, list the folders and tools your coding agent can reach. If it is connected to tools you never use, disconnect them.
Check yourself
What is the difference between a service listening on 127.0.0.1 and one listening on 0.0.0.0?
127.0.0.1 is reachable only from the same machine. 0.0.0.0 means every network interface, so other computers on the network can connect, which makes it far more exposed.
Why is removing a feature stronger than monitoring it?
A removed feature cannot be attacked at all, now or after a future flaw is found in it. Monitoring only helps you notice trouble, and it needs someone to read the output.
Name two parts of an AI coding agent's attack surface that a normal program would not have.
The text it reads (web pages, files, tool outputs), because instructions hidden in them may influence it; and the tools and credentials it can use, because a steered agent acts with all of them.
Next
Surface lists where flaws could live. Vulnerability records describe the flaws that were actually found. Next we learn to read one end to end.

