Algorithm Search⌘K

Conceptintro

Software vulnerability

Also called security bug, exploitable bug.

A flaw in a program that an attacker can trigger to break its confidentiality, integrity or availability.

A software vulnerability is a flaw in a program that an attacker can trigger, by inputs or actions that the threat model allows, to make the program break a security property: the confidentiality of its data, the integrity of its data or behavior, or its availability. Every vulnerability is a bug, but not every bug is a vulnerability. The flaw must be reachable by the attacker, and its effect must matter for security. Two public lists of MITRE organize the field. The Common Weakness Enumeration (CWE) names the types of flaws, such as an out-of-bounds write or the use of an external format string. The Common Vulnerabilities and Exposures (CVE) program gives an identifier to each disclosed flaw in a specific product. This page defines the concept, its parts and the ways to find and remove vulnerabilities.

In plain words

A program has rules it must keep. Only the owner of an account may read its mail. A server must not crash because of one bad message. A file that the user did not write must not change.

A vulnerability is a mistake in the program that lets someone break one of these rules on purpose. A typo in a help text is a bug but not a vulnerability. A missing check that lets any user read any mailbox is a vulnerability.

Two things make a bug a vulnerability. Someone outside must be able to reach it, for example by sending a message. And reaching it must cost the owner something: a secret, the correct data, or the service.

People find vulnerabilities by testing with many strange inputs, by tools that read the code, and by careful review. The fix is a change to the program, called a patch.

The idea

Fix a program PP, a security policy SS that says which behaviors of PP are allowed, and a threat model that says which inputs and actions the attacker controls. A vulnerability of PP is a flaw such that some run of PP, on inputs that the attacker can choose, violates SS. Three parts are needed, and the absence of any one of them removes the vulnerability:

  • A flaw. Code that does not do what its author meant, such as a missing check, a wrong bound or a wrong order of steps.
  • Reachability. A run that the attacker can cause reaches the flaw with a state that triggers it. A flaw on a path that only the administrator can reach is not a vulnerability against a remote attacker, though it may be one against a local user.
  • Impact. The triggered flaw violates the policy: it reveals data (confidentiality), changes data or control (integrity), or stops the service (availability).

Weakness types and instances. CWE describes a weakness as a condition in a component that can, in some circumstances, contribute to vulnerabilities. It is a type, such as CWE-119 (operations outside the bounds of a buffer) or CWE-134 (an externally controlled format string). A CVE record names one instance: one flaw in one product, with the affected versions. Tools and audits map a finding to a CWE entry, and advisories and patches refer to a CVE identifier.

Classes. Common classes are memory safety errors, such as a buffer overflow or a use after free; integer overflow in a size; the misuse of untrusted data as code or as a command, as in SQL injection, cross-site scripting and the format string vulnerability; a race condition between a check and a use; and missing or wrong checks of permission.

A model of memory corruption. Szekeres, Payer, Wei and Song (IEEE S&P 2013) model memory corruption attacks as a chain of steps. A memory error first makes a pointer invalid, out of bounds (a spatial error) or to freed memory (a temporal error). The invalid pointer is then used to read or write. The result is then used: the attacker can change code, change the target of a control transfer, change data that decides a later action, or leak data. Each step is a place where a defense can stop the chain: bounds and lifetime checks at the first step, and data execution prevention, control-flow integrity and address space layout randomization at later ones. The model explains why defenses that act late are easier to deploy but stop fewer attacks.

Limits of detection. Whether a program has a run that violates a nontrivial policy is a property of the function that the program computes, so it is undecidable by Rice's theorem. An analysis that always ends must therefore either miss some vulnerabilities (false negatives) or report some flaws that are not real (false positives). Testing and fuzz testing report only real failures but can miss flaws. Sound static analyses miss no flaw of their class but report false ones. Buffer overrun detection by range analysis makes the same trade of many false alarms for coverage, but it ignores pointer aliasing, so it is not sound for real C and can miss overruns. The rate at which random testing finds new flaws also falls over time; see the exponential cost of vulnerability discovery.

The life cycle. A vulnerability is introduced in a version, found by a tester, a researcher or an attacker, reported to the vendor, fixed by a patch, and removed when users install the patch. The time between disclosure and installation is the window in which users are exposed. A patch also shows where the flaw was, which is the subject of patch-based exploit generation.

Examples

  • An out-of-bounds read. A server keeps a table of 16 entries and reads an index from each request without a check. A request with index 20 makes the server send back memory that follows the table. The flaw is the missing check, the attacker reaches it with one request, and the impact is a loss of confidentiality. A check of the index removes it.
  • A missing permission check. A web service lets a user change a profile by its number and checks that the user is logged in, but not that the profile is the user's own. Any user can change any profile, a loss of integrity. The flaw is in the logic, not in memory.
  • A crash on bad input. A parser stops the whole service when a length field is zero, because it divides by the length. One message stops the service for all users, a loss of availability.
  • A bug that is not a vulnerability. A report tool rounds a total in the wrong direction, and only the user who made the report sees it. No attacker gains anything, so this is a defect, not a vulnerability.
  • The threat model decides. A program crashes on a malformed configuration file. If only the administrator can write the file, there is no vulnerability against other users. If the program also loads such files from downloads, the same flaw is a vulnerability.

Where it is used

The concept is the subject of the whole area of vulnerability discovery. Fuzz testing and its variants run the program to find triggers; taint analysis, the code property graph and range analysis search the code for flaws of a given class; symbolic execution finds inputs that reach a given point; and vulnerability signature generation filters inputs that reach a known flaw until a patch is installed. CWE entries give the classes that tools check and that lists of the most serious weaknesses rank, and CVE identifiers let vendors, scanners and advisories refer to the same flaw. The memory corruption model of Szekeres et al. organizes the defenses of the memory safety pages.

References

  1. MITRE, About CWE (Common Weakness Enumeration), the definition of CWE as a community-developed list of common software and hardware weaknesses, and of a weakness as a condition in a component that can contribute to vulnerabilities
  2. The CVE Program, Overview, the overview of the program that gives identifiers and records to publicly disclosed vulnerabilities
  3. Laszlo Szekeres, Mathias Payer, Tao Wei and Dawn Song, SoK: Eternal war in memory, IEEE Symposium on Security and Privacy 2013, pages 48-62, the general model of memory corruption attacks as a chain of steps, and the survey of the defenses that stop each step

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/RWGDW1/text.yaml