Definition
An attack precondition is a condition that must be true before a particular attack can succeed. Some preconditions are capabilities of the attacker, such as being in radio range, holding a secret key or having physical access §1.32 to the hardware. Others are states of the target, such as an optional feature being switched on or a connection being open. An attack succeeds only when all of its preconditions hold at once, so its list of preconditions says who can carry out the attack and which defenses can stop it.
The idea
A report says: “an attacker can crash the device by sending a malformed update message.” The sentence leaves open the question that decides how serious the flaw is: which attacker? If any radio transmitter in range can do it, the flaw is open to everyone near the device. If only a sender who holds the device’s update key can do it, the flaw is open to the vendor, to a dishonest employee and to whoever has stolen that key. If the attacker must first open the device’s case, the flaw is open only to someone who holds the device. The crash is the same in all three cases, but the set of possible attackers differs, and so does the defense that closes the flaw.
Picture an attack as a path from the attacker to the damage, with a gate at every point where something must already be true. The attacker must pass every gate on the path, and each precondition is one gate. A defense works by keeping a gate shut against this attacker. The picture explains why one defense stops one attack and not another. Authentication §1.6, a check that a key holder tagged the message, shuts the gate “holds the key”; on a path that has no such gate it does nothing. The picture stops being accurate in one respect. Some gates are opened by the attacker, not kept shut by the defender: if a device accepts a connection from anyone, “has an open connection” is a step the attacker takes, not a barrier.
How it works
Analyze one attack at a time, in this order.
Name the entry point and the effect. The entry point is the interface where the attacker’s input or action arrives: a radio message, a network port, a file, a debug connector. The set of all such entry points is the system’s attack surface §1.5. The effect is the harm: a crash, a leaked secret, an unauthorized change.
Trace the path. Follow the input through the code, or through the physical procedure, from the entry point to the effect, step by step.
List the preconditions. At every step, write down what must already be true for the step to proceed: the interface can be reached, a connection or session is open, the message carries a valid tag (a short value that only a holder of the secret key can compute), the message passes the parser, a feature is enabled, the device is in a particular mode.
Classify each precondition. Decide whether the threat model §1.2, the written statement of what the attacker can do, grants it to the attacker; whether the attacker can bring it about alone; or whether it needs something the threat model withholds, such as a secret key.
Name the mechanism behind each closed gate. For each precondition that the attacker cannot meet, name the mechanism that keeps it false and the assumption on which that mechanism rests.
The position of the flaw relative to the authentication check decides most of the answer. Code that runs before the check, such as the framing code that splits the message to find its tag, is reached by anyone who can deliver bytes to the interface. Code that runs only after a valid tag is reached with a message of the attacker’s choosing only by a key holder, by someone who has stolen the key, or by someone who tricks a key holder into tagging a message the attacker chose. That last case, in which a trusted party is misused to act for an attacker, is called a confused deputy §1.25. Anyone else reaches that code only by delivering a genuine message recorded earlier; a freshness check §1.26, such as a counter, stops such a message from being accepted twice.
A security analysis applies the same method to a whole threat model. For each attacker capability that the threat model grants, it records four things: the attacks the capability enables; the mitigation, meaning the mechanism that stops each attack; the assumption on which that mitigation depends; and the residual risk, meaning what the attacker can still do once the mitigation is in place.
Vulnerability scoring systems record common preconditions as fixed values. Version 3.1 of the Common Vulnerability Scoring System (CVSS), for example, rates the attack vector as Network, Adjacent (sharing a local network or radio link with the target), Local or Physical, and the privileges required as None, Low or High. These values summarize the preconditions; they do not replace the trace that establishes them.
Worked example
A device receives update messages over a radio link and accepts a connection from anyone in range. Each message has a 2-byte length field, a payload and a 32-byte tag computed with a key . The vendor’s server and every device hold ; the device needs it to check tags. The receiving code copies the payload into a 64-byte buffer, then checks the tag, then carries out the update. Three flaws are reported.
Flaw A. The copy trusts the length field. A message whose length field says 200 makes the code write 200 bytes into the 64-byte buffer, which is bytes past its end, before the tag is checked. Preconditions: being in radio range and opening a connection. The attacker meets both alone. No key is needed, because the damage is done before the tag check runs. The tag check therefore cannot stop flaw A; a check that rejects any length above 64 before the copy can.
Flaw B. An update may contain a small program that the device runs. A program with a valid tag can contain a loop of steps. At steps per second it occupies the processor for seconds, during which the device does nothing else. Preconditions: a valid tag on the attacker’s program, so either possession of or a key holder who can be tricked into tagging that program. An outsider in radio range meets neither. The tag check stops the outsider. It does not stop a dishonest insider or a thief of ; a limit on the number of steps per run stops all three.
Flaw C. The debug port, a hardware connector through which a debugging tool can stop the processor and read its memory, is left unlocked, so anyone with the device on the bench can read out of memory. Preconditions: physical access to one device and an unlocked debug port. Locking the port with the chip’s readout protection §16.5, a setting that blocks memory reads through the debug port, closes this path.
The flaws combine. is the same in every device, so a key read out of one device through flaw C gives the attacker valid tags for every device. Flaw C thereby supplies the precondition of flaw B for the whole fleet. Calling all three “remote attacks” would be wrong for flaw C, which needs a device in hand, and incomplete for flaw B, which arrives over the radio like flaw A but also needs a valid tag on the attacker’s program.
Stated precisely
Let an attack goal have alternative paths , and let path have the preconditions , where is the number of preconditions of that path. Write for the statement that precondition holds for the attacker : it is a capability that the threat model grants to , or a state that can bring about with those capabilities. Then where means that all the listed conditions hold and means that at least one of the listed alternatives holds.
A set of defenses stops for exactly when, on every path, at least one precondition is false for . Shutting a gate on one path is not enough while another path stays open. This structure, a choice among alternative paths each of which needs all of its preconditions, is what an attack tree draws: the goal at the root, the alternative paths as branches of which any one suffices, and the preconditions of each path as branches that must all hold.
The formula is a statement of logic, not of probability. Multiplying an estimated probability for each precondition gives a number without justification unless each probability is measured and the preconditions are shown to be independent. Preconditions are often dependent, and the attacker chooses which ones to pursue.
Limits and common mistakes
A precondition does not make a flaw harmless. “Requires a valid tag” excludes outsiders who must write the message themselves, but it leaves in the key holders, anyone who steals the key, any confused deputy and, if a genuine message already triggers the flaw, anyone who records that message and sends it again. State the flaw’s severity for the attackers who can meet its preconditions instead of dismissing it.
A precondition that the attacker can meet alone is not a barrier. “Requires an open connection” protects nothing when the device accepts connections from anyone.
Preconditions are judged against a threat model. An attack that needs a capability the threat model excludes, such as flaw C under a model without physical access, is outside the model’s scope; it is not impossible. Changing the threat model changes which attacks count.
A flaw that exists only when an optional feature is switched on has that setting as a precondition. A test run with the feature switched off says nothing about the flaw. A finding in the source code does not show that every deployed configuration switches the feature on.
Attacks chain. One attack can establish a precondition of another, as flaw C supplies the key that flaw B needs, so analyze which attacks enable which, not only each attack alone. A label taken from the entry point alone, such as “remote attack”, hides whether a key, an open session or an action by a legitimate user is also required.
Questions answered
Does the attacker need an authenticated session, a valid tag, or physical access?
It depends on where the flaw sits on the path from the attacker’s input to the harm, and the answer must be worked out for each attack separately by tracing that path. Each condition that must hold along the path is an attack precondition. Three cases cover most flaws.
If the flaw is in code that runs before the authentication check, such as the framing code that reads a message to find its tag, the attacker needs only to deliver bytes to the interface. No session and no valid tag are needed.
If the flaw is reached only after a valid tag, a short value that only a holder of the secret key can compute, the attacker needs the key, or a key holder who can be tricked into tagging the attacker’s message. If a genuine message that a key holder tagged earlier already triggers the flaw, an outsider needs only a recording of that message, unless the device rejects repeated messages. Otherwise an outsider without the key is stopped; a dishonest insider or a key thief is not. An authenticated session works the same way: it is a precondition only if the flawed code is reached through no other route and the attacker cannot open such a session alone.
If the attack goes through the hardware, such as a debug connector or a power cut at a chosen moment, the attacker needs physical access to the device, and the software’s checks are not in the way.
For each answer, also name the mechanism that keeps the precondition false, the assumption that mechanism rests on, and whether the threat model grants the capability. Remember that one attack can supply a precondition of another: a key read out through a debug connector supplies the valid tag for every attack that needs one.
Take each adversary capability in your threat model in turn: which mechanism stops it, on which assumption, and what remains possible?
Answer with one row for each capability that the threat model grants; the threat model is the written statement of what the attacker can do. Each row has four entries: the attacks the capability enables, the mitigation that stops each attack, the assumption on which the mitigation depends, and the residual risk, meaning what the attacker can still do. For a device that obeys radio commands carrying a tag, a short value that only a key holder can compute, three rows might read as follows.
Send any radio message. The tag check stops forged commands, assuming the key stays secret and the check runs before every action. Length and format checks that run before any copy stop malformed messages, assuming those checks are correct for every input. Residual risk: flooding or jamming the radio, which no message check prevents.
Record and resend messages. A replay attack, sending an old valid message again, is stopped by a counter in each message that must exceed the last accepted value, assuming a restart cannot reset the stored counter. Residual risk: delaying or dropping messages.
Hold a device. Locking the debug port stops reading the key through it, assuming the lock resists attacks such as briefly disturbing the supply voltage. Residual risk: an attacker who opens the chip itself may still extract that device’s key, which is why each device should have its own key.
A row with no residual risk deserves suspicion: every mitigation rests on an assumption, and the row should say what follows if that assumption fails.
Related entries: Threat model (§1.2), Attack surface (§1.5), Security claim scope (§1.45), Confused deputy (§1.25), Physical versus logical access (§1.32).