Match each term about borrowed code to its description.
Choose the match for each entry. Every match has to be right.
Modern software is assembled from parts. Some parts the team designs itself, as objects that each look after their own data. Most parts were written by strangers and are borrowed whole, as libraries. Both habits shape security: the first decides how far a mistake can spread inside a program, and the second decides whose mistakes the program inherits. No programming background is assumed.
In December 2021 the United States cyber agency CISA was responding to active, widespread exploitation of a flaw in Apache Log4j. Log4j is a library: a piece of ready-made code that other programs use to keep a record of what they do. CISA described it as very broadly used in consumer and enterprise services, websites and applications.
The flaw, known as Log4Shell, let a remote attacker with no account take control of an affected system. On 17 December 2021 CISA issued an emergency directive to federal agencies. Its guidance told every organisation to work out which of its products contained Log4j, and to include software written in house and systems not facing the internet.
Most of those organisations had never chosen Log4j. How did it come to be inside their systems, and what record would have answered CISA's question in an hour?
Many programming languages are object-oriented: the program is built from objects. An object is a bundle of data together with the operations that are allowed on that data.
A class is the template from which objects are made. It says what data every object of that kind holds and what each can do. One object made from a class is also called an instance of it.
A bank's account class
A bank's program has a class called Account. The class says that every account holds a balance and an owner, and can do three things: pay in, withdraw and report its balance.
Mrs Okafor's account and Mr Lindqvist's account are two objects of that class. They hold different balances. They behave by the same rules, because both were made from the one template.
The things an object can do are its methods. A method is the code that runs to carry out one of an object's operations, such as withdraw. Objects ask each other to act by sending a message: a request from one object to another to run one of its methods. A cash machine object sends the message withdraw 50 to an account object and waits for the answer.
Four properties of objects are examined by name.
month end to a savings account and it adds interest. Send it to a loan account and it charges interest. The sender does not need to know which kind it is talking to.Each has a security consequence. Encapsulation protects , because every change to the data passes through code that can check it. Inheritance spreads whatever the parent contains: a flaw in the parent class is a flaw in every child, and a correction to the parent corrects them all.
Common misconception
“Encapsulated data is protected from attackers, as encrypted data is.”
Encapsulation is a rule inside the program about which code may touch which data. It stops programming mistakes from spreading. It does not hide the data from someone who can read the computer's memory or the database.
A module is one self-contained part of a program. Two measures describe how well a program has been divided into modules.
| Measure | What it describes | What is wanted | Why |
|---|---|---|---|
| Cohesion | How closely the tasks inside one module belong together | High | A module that does one job is easy to understand, test and review |
| Coupling | How much one module depends on the insides of another | Low | A change or a fault in one module does not spread to the others |
A restaurant kitchen
The pastry station makes only desserts: high cohesion. It needs nothing from the grill station except a clean plate handed over at the pass: low coupling. If the grill catches fire, pastry carries on.
A kitchen where every cook does a little of everything and reaches into every fridge has low cohesion and high coupling. One mistake travels everywhere.
High cohesion, low coupling. Each module does one job and leans on the others as little as possible.
Teams rarely write common functions themselves. They borrow them, in three forms.
| Kind | What it is | Who is in charge | Everyday comparison |
|---|---|---|---|
| Library | Ready-made code for one job, such as , drawing charts or reading a file format | The team's code calls the library when it needs it | A power drill taken from the shelf |
| Software development kit (SDK) | A supplier's bundle of libraries, tools and instructions for building software that works with its product | The team's code calls the kit | The fitting kit sold with a kitchen |
| Framework | A reusable skeleton of a whole application that the team extends with its own parts | The framework calls the team's code | A house frame that the builder fills in |
Any outside component a program needs is a dependency. Libraries use other libraries, so a program also has transitive dependencies: the dependencies of its dependencies. A team may choose forty libraries and ship four hundred. That is how Log4j reached organisations that had never heard of it.
Borrowed code runs with the same access as the code around it. The organisation that ships a product answers for all of it, whoever wrote each part. Six controls manage the .
Two attacks aim at the moment a build fetches its components. In typosquatting the attacker publishes a malicious package whose name is one slip of the keyboard from a popular one. In dependency confusion the attacker publishes a public package with the same name as an organisation's private one, so that the build fetches the attacker's copy. Approved sources, pinned versions and hash checks defeat both.
Common misconception
“A flaw in a third-party library is for the library's author to deal with.”
The author can publish a corrected version. Only the organisation that shipped the old version can find where it is running and replace it. Until it does, its own product is vulnerable.
A customer cannot replace a library inside a product that a supplier maintains. It raises the flaw with the supplier, under the agreements in their contract, and asks for the supplier's fix or a statement of whether the product is exposed. Meanwhile it applies a , a temporary safeguard such as the supplier's workaround or cutting the product off from the network.
A charity's donation website is built from about forty open-source libraries. A critical flaw is announced in one widely used library. The trustees ask whether the site is affected. It takes the web team three days of searching to answer, because nobody knows which libraries, or which versions, each release contains. The security lead is asked what to put in place so the next announcement can be answered quickly.
What should be put in place FIRST?
Answer: A. An inventory of every component and version in each release
5 questions on this unit, easiest first. Confirm an answer to see the reasoning for it, then the right answer, the other options and the rule to reuse. Your answers are kept in this browser and feed readiness and review.
These questions are drafts that no named reviewer has approved yet.
Question 1 of 5
Match each term about borrowed code to its description.
Choose the match for each entry. Every match has to be right.
A library is ready-made code, usually written by others, that a program reuses. It runs with the program's own access, so its flaws become the product's flaws, and it brings its own dependencies with it. Controls: approved sources, review before first use, pinned and hashed versions, an inventory of every component, monitoring for known vulnerabilities with prompt updates, and removal of unused components.
A class is a template and an object is one instance made from it. Encapsulation seals data behind the object's methods. Inheritance passes a parent class's data and methods to a child, flaws included. Polymorphism lets different classes answer one message in their own way. High cohesion and low coupling are wanted, so a fault stays in one module.
A method is the code that runs to carry out one of an object's operations, such as withdraw. A message is a request from one object to another to run one of its methods, as when a cash machine object sends withdraw 50 to an account object.
A library is ready-made code for one job, which the team's code calls. An SDK is a supplier's bundle of libraries, tools and instructions for building software that works with its product. A framework is a reusable skeleton of a whole application that calls the team's code. Transitive dependencies are the dependencies of a program's dependencies.
In typosquatting the attacker publishes a malicious package whose name is one slip of the keyboard from a popular one. In dependency confusion the attacker publishes a public package with the same name as an organisation's private one. Approved sources, pinned versions and hash checks defeat both.