Hidden and malicious code
Some harmful code does not break in from outside. It is written into the product: a secret way in left by the builders, a routine that waits for a date, a quiet signal between two programs. Because it sits inside trusted software, the usual defences against intruders do not look for it. Finding it and keeping it out is a matter of how code is reviewed, approved and released. No programming background is assumed.
By the end of this unit you will be able to:
- Tell apart a back door, a maintenance hook and a logic bomb
- Explain the difference between a covert storage channel and a covert timing channel
- Tell apart hidden code from malware that arrives from outside
- Choose the controls that stop hidden code reaching a release
Half a second too slow
In March 2024 a software developer noticed that logging in to one of his test computers over the network had become slower: 0.807 seconds instead of 0.299. He was not a security researcher, but he investigated.
He traced the delay to xz Utils, a small library that makes files smaller and that many Linux systems rely on. Its official versions 5.6.0 and 5.6.1 contained hidden code that interfered with the program accepting remote logins. Part of it was in the downloadable release packages and not in the project's public source history. He published his findings on 29 March 2024.
The hidden code came out in the project's own official releases. Which controls could have caught it before it shipped?
Back doors, trap doors and maintenance hooks
Every system has a front door: the sign-in, with its password and its checks. A back door is any other way in that avoids those checks and is usually hidden. It can arise in three ways: as an honest mistake, built in on purpose by the system's makers, or planted in secret by an intruder. A trap door is the same thing under another name.
A maintenance hook is a back door the developers built for themselves. It is a special instruction that lets them into the program quickly while testing or repairing it, without the usual checks. Builders fitting out a shop may leave a side door unlocked while they work. That is harmless during the work and dangerous if it is still open on opening day.
Typical hooks are a hidden account with a fixed password, a combination that opens an administration screen, and a debug setting that switches off the password check. Each has to be found and removed before the software goes live.
Common misconception
“A hidden account the supplier keeps for support is not a security flaw, because its purpose is innocent.”
Anyone who learns the secret can use it, and the owner cannot watch or close what it does not know exists. Support access should be a documented account that the owner controls and switches off when not in use.
Logic bombs: code that waits for a condition
A logic bomb is malicious code inside legitimate software that does nothing until a set condition is met, then causes harm. The condition may be a date, a number of runs, or an event such as a name vanishing from a list.
Logic bombs are usually written by insiders: a developer or administrator who can add code that nobody else reads. Until the condition arrives the program behaves normally, so it passes every test of its features.
The unpaid invoice
A contractor writes a stock control system for a wholesaler. Hidden in it is a check: if no payment code has been entered by 1 June, lock every user out. The wholesaler disputes the final invoice. On 1 June the warehouse stops.
Testing the features finds nothing, because the bomb is not a feature. A person reading the code finds a date check that no requirement explains. Comparing the released program with the version that was approved also exposes it.
Covert channels: storage and timing
A is a route for passing information that the system's rules never meant to allow. Inside software it lets a program that may read secret data signal it, bit by bit, to a program that may not. Two kinds are told apart by how the signal travels.
- Covert storage channel
- The sender writes to a place that the receiver later reads, although neither is meant to communicate. A secret program creates or deletes a temporary file once a second. An ordinary program checks whether the file exists: present means one, absent means zero.
- Covert timing channel
- The sender changes how it uses a shared resource, and the receiver measures the effect on its own response times. The sender keeps the processor busy for a one and leaves it idle for a zero. The receiver times its own work.
Developers are best placed to find covert channels, because they know which resources programs share. Covert channel analysis lists the possible channels and estimates how many bits a second each could carry. Timing channels can rarely be removed entirely without slowing the system badly, so the usual aim is to cut their capacity. Even an error message can carry a covert signal, which is one reason error messages reveal as little as possible.
Keeping hidden code out of what is released
- Code review by someone other than the author before a change is accepted. A second reader is the control most likely to notice code with no business being there.
- : whoever writes a change cannot also approve it or release it.
- Controlled change: every change is tied to an approved request, so code with no request behind it stands out.
- A release checklist and an automated scan that remove debug switches, test accounts and maintenance hooks.
- Comparing what is released with the reviewed source. In xz Utils part of the hidden step was in the release package and not in the source history, the very gap this check closes.
Code signing helps a user confirm that a release came from its publisher unchanged. It proves who released the code, not that the code is honest: a trusted insider's logic bomb carries a valid signature.
Malware is let in. Hidden code is written in. Review every change, separate the duties, and check the release against what was approved.
A question, worked through
A housing association's rent system was written by a contractor. After the contract ended in a dispute, every tenant account was locked on 1 April. The cause was a routine in the contractor's code that fired on that date. The system had passed full testing of its features before going live. The board asks which control would most likely have stopped it.
Which control would MOST likely have prevented this?
Decide on your answer, then open the reasoning
- Code written into the product waited for a date and then did harm. That is a logic bomb. The question asks which control would most likely have stopped it.
- Rule out d. Encryption keeps data from people who should not read it. The routine ran inside the system, which handles the data unencrypted.
- Rule out c. Anti-malware looks for known harmful programs arriving from outside. A routine written into the association's own system matches no known sample.
- Between a and b: feature testing checks that the system does what was asked. The bomb was not a feature, so more testing would still pass it. A second developer reading the code would see a date check that no requirement explains.
- Independent review before acceptance is the control most likely to catch it. Option a.
Answer: A. Review of the contractor's code by another developer before acceptance
Choosing between good answers
- Code inside a legitimate program does harm only when a date or event arrives
- it is a logic bomb. A program that looks useful but hides a harmful purpose from the start is a Trojan horse.
- Developers left a way into the program that skips the normal checks
- it is a maintenance hook, a kind of back door. The answer removes it before release. Documenting it does not make it safe.
- Programs pass information through a file appearing or through changes in response time
- it is a covert channel: storage if something is written and read, timing if a delay is measured.
- A question asks for the control that catches code an insider added on purpose
- choose independent code review with separation of duties. Testing features and scanning for malware miss code that was written in.
Check your understanding
4 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 4
What to remember
- A back door, or trap door, is a hidden way in that avoids the normal checks. A maintenance hook is one that developers left for themselves and must remove before release.
- A logic bomb is malicious code inside legitimate software that fires when a condition such as a date is met.
- A covert storage channel signals by writing something another program reads. A covert timing channel signals by changing response times.
- Malware is let in from outside. Hidden code is written in, often by someone trusted, and anti-malware rarely recognises it.
- Independent code review, separation of duties, controlled change and checking releases against reviewed source keep hidden code out. A signature proves who released code, not that it is honest.
Say it from memory
Tell apart a back door, a maintenance hook and a logic bomb.
A back door, also called a trap door, is any hidden way in that avoids the normal checks, whether by mistake, by the makers or by an intruder. A maintenance hook is a back door developers left for testing and must remove before release. A logic bomb is malicious code inside legitimate software that does harm when a condition, such as a date, is met.
How does a covert storage channel differ from a covert timing channel, and what is done about them?
A storage channel signals by writing to something another program reads, such as a file existing or not. A timing channel signals by changing use of a shared resource so the receiver's response times change. Covert channel analysis lists them and estimates their capacity. Timing channels are usually reduced, not removed.
Which controls keep code an insider adds on purpose out of a release?
Code review by someone other than the author, and separation of duties between writing, approving and releasing. Change control tying every change to an approved request. A release checklist and scan for hooks and debug settings. Comparing the released package with the reviewed source.
How do a Trojan horse, a virus and a worm differ in how they get in and what sets them off?
A Trojan horse is disguised as useful software and runs once installed. A virus attaches itself to a host file or program and runs when a person opens or runs the host. A worm is a standalone program that spreads itself over the network through a flaw in a networked service, with no user action.
Sources
- backdoor in upstream xz/liblzma leading to ssh server compromise, Andres Freund, posted to the oss-security mailing list (Openwall)The story: login timings of 0.299 and 0.807 seconds, the poster not being a security researcher, the backdoor in xz Utils 5.6.0 and 5.6.1, its presence in the release tarballs and not in the git repository, its effect on the remote login service, and the date of 29 March 2024.
- Reported Supply Chain Compromise Affecting XZ Utils Data Compression Library, CVE-2024-3094, Cybersecurity and Infrastructure Security Agency (CISA)Malicious code embedded in xz Utils versions 5.6.0 and 5.6.1, and the advice to downgrade to an uncompromised version such as 5.4.6.
- RFC 4949: Internet Security Glossary, Version 2, IETFBack door as hidden access by other than the usual procedure, arising by flaw, by the creator or by an intruder; trap door as its synonym; maintenance hook as special instructions allowing entry without the usual checks, to be removed before live use; logic bomb; Trojan horse; covert channel.
- SP 800-53 Rev. 5, Security and Privacy Controls for Information Systems and Organizations, NISTCovert storage and timing channels, developers being best placed to find them, estimating their bandwidth, timing channels rarely being removable without performance cost (SC-31), and error messages as a possible covert channel (SI-11).
- CWE-489: Active Debug Code, MITRE (CWE programme, sponsored by CISA)Debug code left active in released software, such as a debug parameter that skips the password check, and removing it before deployment.
- NIST SP 800-83 Rev. 1: Guide to Malware Incident Prevention and Handling for Desktops and Laptops, NISTViruses, worms and Trojan horses as classic categories of malware, and a Trojan horse as a non-replicating program that appears benign but has a hidden malicious purpose.
- Security Considerations for Code Signing (NIST Cybersecurity White Paper), National Institute of Standards and TechnologyCode signing providing integrity, showing the code was not modified, and source authentication, identifying who signed it, and signing of malicious code as a threat.