Port Scanning: The Same Question Asked of Every Address
Security
A port scan gets described as the opening move of an attack. The more informative description is arithmetic, because the cost of asking one address one question has been measured, and it comes to between one and three packets. Who scans you, and whether it matters, both follow from that number.
What it costs to ask
The measurement comes from a peer-reviewed paper, ZMap: Fast Internet-Wide Scanning and Its Security Applications, presented by Zakir Durumeric, Eric Wustrow and J. Alex Halderman of the University of Michigan at the 22nd USENIX Security Symposium in August 2013. The authors built a scanner and then measured it, which makes the paper a description of the economics rather than an opinion about them.
The technique it implements is the ordinary one. The paper names it as “a probing technique known as SYN scanning or half-open scanning”, chosen “instead of performing a full TCP handshake based on the reduced number of exchanged packets”.
Then it sets out the count, case by case: “In the dominant case where a host is unreachable or does not respond, only a single packet is used (a SYN from the scanner); in the case of a closed port, two packets are exchanged (a SYN answered with a RST); and in the uncommon case where the port is open, three packets are exchanged (a SYN, a SYN-ACK reply, and a RST from the scanner).”
Three packets is the expensive case. What each of those outcomes means, and why a refusal and a silence are not the same result, is a separate subject, and what a refusal and a silence each tell you handles it properly.
The per-address cost is what sets the scale. The same paper reports a scanner “capable of surveying the entire IPv4 address space in under 45 minutes from user space on a single machine”, on an entry-level server with a gigabit connection. That belongs to 2013 and to the hardware of its day, and it is reported here on those terms. The figure itself is not the point. The ratio is: one question, put to everything, at the price of a packet each.
Your address was not chosen
A sweep of that kind does not work through the address space in numerical order. Engineering decides that, not discretion. The paper is explicit that “ZMap scans addresses according to a random permutation of the address space”, because going in order “would risk overloading destination networks with scan traffic”.
The assumption that makes the speed possible points the same way. The authors assume “that the targets are randomly ordered and widely dispersed (so no distant network or path is likely to be saturated by the scan)”. Dispersal stops the scan concentrating anywhere, and your line is one of the places it is not concentrating.
There is an opt-out, and its nature matters. The scanner keeps an exclusion list, and the paper gives two sorts of reason for an entry on it. Some ranges are left out “for performance reasons (e.g., skipping IANA reserved allocations)” and others “to honor requests from their owners to discontinue scanning”. A request, honoured by a researcher who chose to honour it. Not a control on your router, and not a right you hold.
The act does not classify itself
The paper’s framing of its own subject is the part to carry away, because it declines the easy version. Internet-wide scanning, the authors note, is “often associated with botnets and worms”, and has also “proved to be a valuable methodology for security research”. One probe serves both purposes, and the probe does not announce which it is.
They then record an asymmetry that makes the picture less comfortable: “this methodology has been more accessible to attackers than to legitimate researchers, who cannot employ stolen network access or spread self-replicating code”. Their response was to publish the scanner openly rather than describe the technique and stop.
The restraint they propose is procedural rather than technical. The paper sets aside a section for “best practices for good Internet citizenship when performing Internet-wide surveys”, on the ground that “users must be careful not to cause harm by inadvertently overloading networks or causing unnecessary work for network administrators”, and it reports “the complaints and other reactions we have received” over a year of scanning. A scan makes work for somebody even when it finds nothing at all.
Where the statute puts the line
In the UK the question of lawfulness runs through the Computer Misuse Act 1990, which received Royal Assent on 29 June 1990. Its long title states the subject: “An Act to make provision for securing computer material against unauthorised access or modification; and for connected purposes.”
Section 1 sets out three elements and all three have to be present. A person is guilty if “he causes a computer to perform any function with intent to secure access to any program or data held in any computer”, if “the access he intends to secure … is unauthorised”, and if “he knows at the time when he causes the computer to perform the function that that is the case”.
The load-bearing word there is access. Asking whether a port answers obtains no program and no data. That describes how the section is built rather than predicting any particular case. Whether a given act satisfies all three elements is a question for a court, not for an article.
What section 1 does not require deserves more attention than it gets. Subsection (2) provides that the intent “need not be directed at” either “any particular program or data”, or “a program or data of any particular kind”, or “a program or data held in any particular computer”.
So indiscriminacy is not a defence. The scanner’s design assumes its targets are randomly ordered and widely dispersed. The statute, drafted twenty-three years before that paper and for quite unrelated reasons, says the intent need not be aimed at any particular machine. Two documents from separate worlds, both treating the choice of target as beside the point.
Section 3 covers different ground, and the limb that bears on this is recklessness. It reaches an unauthorised act where the person “is reckless as to whether the act will do any of the things mentioned” in its own list, which includes to “impair the operation of any computer”, and it adds that “a reference to impairing, preventing or hindering something includes a reference to doing so temporarily”. The Act therefore treats impairment as a separate question from access. The researchers’ worry about overloading a network and the statute’s recklessness limb are circling the same conduct from opposite ends.
Why obscurity stopped working
The paper’s least comfortable observation is about expectations rather than packets. It notes that “many developers have the preconceived notion that the Internet is far too large to be fully enumerated, so the reality of high speed scanning may disrupt existing security models, such as by leading to the discovery of services previously thought to be well hidden”.
The consequence the authors draw from their own results is about timing. Cheap enumeration, they write, “creates the possibility for an attacker with control of only a small number of machines to scan for and infect all public hosts suffering from a new vulnerability within minutes”.
That is what sets the exposure window, and obscurity is not what narrows it. The window is the gap between a flaw becoming known and the fix arriving on the thing that has it. An unusual port number changes neither end of it.
What the answer is worth
The part you can act on is small, because the asking decides nothing by itself.
The significance of a scan sits entirely in what answers it. A probe that reaches a line with nothing exposed collects one bit and moves on. The cases that matter are the ones where something answered and nobody had decided that it should.
You can produce one of those answers deliberately. Where this differs from everything above is arity: a sweep puts one question to every address it can reach, and when you send that question to yourself it goes to a single address, the one you arrived on, because you asked for it. The answer covers the number you nominate, and the numbers that never occurred to you stay unexamined. It also folds two of the protocol’s replies into one, reporting a refusal and a silence alike as closed, so the distinction drawn above is one the protocol makes and the result does not.
An answer attaches to an address rather than to a person. The page for what an address discloses on its own states that limit in its own words, that “IP lookup data is not a person lookup”, which is worth holding on to when a log entry starts to feel personal.
The results worth acting on are the ones nobody chose. A remote administration interface reachable from outside is the standing example, and where that gets switched on is the first thing to go looking for. Volume is a different subject again, because traffic aimed at filling a line arrives whether or not anything is willing to receive it.
A port scan costs between one and three packets to send, and the scanner that set that benchmark treats every address as interchangeable by design. The statute arrives at the same act from the other side and treats the choice of target as irrelevant to intent, which leaves access as the thing it turns on. What is left is the answer, which is the only part of the exchange you have any say over.