Controls reduce the chance or the effect of program flaws and malware. They work at three levels: during development, in the operating system, and in administration and use.

Development Controls

  1. Secure coding standards and training.
  2. Peer review and code inspection, and static analysis tools that scan source code for flaws.
  3. Testing: unit, integration, fuzzing (random and malformed input), and penetration testing.
  4. Modularity, simple design and information hiding, so that flaws stay contained.
  5. Version control and change control, with signed releases and separation of duties so that one person cannot insert hidden code.
  6. Use of safe languages and libraries and dependency checks for known vulnerable components.
  7. Threat modelling and a secure development life cycle.

Operating System and Run-Time Controls

Least privilege (programs run with minimum rights), sandboxing and virtual machines to isolate programs, address space layout randomisation (ASLR) and non-executable memory (DEP) that make memory-corruption attacks harder, stack canaries, code signing (only trusted code runs), and access control on files.

Administrative and User Controls

Antivirus and anti-malware software (signature-based, heuristic and behaviour-based detection), timely patching, firewalls, backups (including offline copies against ransomware), user training against phishing, disabling macros and autorun, application whitelisting, and incident-response plans. Intrusion detection and monitoring catch malware that gets in.

Measuring a Detector

No detector is perfect. It can miss malware (false negative) or flag a clean file (false positive). Useful measures are detection rate (recall) = TP / (TP + FN), false-positive rate = FP / (FP + TN) and precision = TP / (TP + FP).

Definition: Sandbox. A restricted, isolated environment in which a program runs with limited access to files, network and system resources, so that any harm it causes is contained.

Table 2.3: Controls by level

Level Control Purpose
Development Code review, fuzzing, static analysis Find flaws before release
Run time Sandbox, ASLR, least privilege Limit what an attack can do
Administration Patching, antivirus, backups Remove weaknesses, recover
Users Awareness training Reduce phishing success

Example 2.3: Evaluating a malware detector

Problem: A detector scans 1,000 files, of which 20 are malicious. It catches 18 of them and also wrongly flags 10 clean files. Find TP, FN, FP, TN, the detection rate, the false-positive rate and the precision.

Solution:

  1. TP = 18, FN = 20 − 18 = 2, FP = 10, TN = 980 − 10 = 970.
  2. Detection rate = 18/20 = 90 percent.
  3. False-positive rate = 10/980 = 1.02 percent.
  4. Precision = 18/(18 + 10) = 64.3 percent.

Result: The detector finds 90 percent of the malware with a 1 percent false alarm rate, but only 64 percent of its alarms are real, because malicious files are rare.

tp, fn, fp, tn = 18, 2, 10, 970
print("Detection rate (%):", 100 * tp / (tp + fn))
print("False-positive rate (%):", round(100 * fp / (fp + tn), 2))
print("Precision (%):", round(100 * tp / (tp + fp), 1))

Output

Detection rate (%): 90.0
False-positive rate (%): 1.02
Precision (%): 64.3

Common mistakes

  • Relying on antivirus without patching or backups.
  • Running programs with administrator rights by default.
  • Keeping backups online where ransomware can encrypt them.
  • Releasing code without review or testing.

Key takeaways

  • Development: review, static analysis, fuzzing, secure life cycle.
  • Run time: least privilege, sandbox, ASLR, DEP, code signing.
  • Administration: patching, antivirus, backups, training.
  • Detector measures: detection rate, false-positive rate, precision.

Practice questions

  1. What is fuzzing?
  2. What does ASLR do?
  3. What is a false positive?

Answers to the practice questions

  1. Testing a program with random or malformed input to find crashes and flaws.
  2. It randomises memory addresses so that memory-corruption attacks are harder.
  3. A clean file wrongly flagged as malicious.

Sources

  • Official BCA syllabus Computer Security, course code 25BCA406DS02, Unit II