UP | HOME
../../

Lab: Software without Security Holes

Table of Contents

1 Overview

1.1 Background

  1. ShellShock:: Refresh your hold on bash syntax and usage.
  2. Coding Guides:: For C and C++: Part of this course. For Java: Not part of this course. Become familiar with CERT Coding Guide on C.
  3. System Programs: mount, fusermount, sudo, su, passwd, chsh, … We expect these to be free of security holes.
  4. Ordinary/ non-system programs/ utilities: cat, ls, date, make, and even login, bash, ash, dash, csh, zsh and other shells.
  5. Background: Study FUSE documentation from within the kernel source tree: https://www.kernel.org/doc/Documentation/filesystems/fuse.txt,

1.2 Prerequisites for this Lab

  1. sudo is a standard command present in all Linux distros already. In this lab, we will DIY build it. Download the source code of the latest stable release of sudo from http://www.sudo.ws/sudo/.
  2. Install sudo apt install splint Visit https://splint.org/
  3. Install sudo apt install valgrind Visit http://valgrind.org/

2 Tasks

2.1 Task: Analyze sudo

  1. Download the source code of sudo Build it. Read the included man page, not man sudo. Check that it "works." Submit details of how you checked.
  2. Run splint, with no flags (except for include-related), collectively on all the source code files of sudo. No need to insert its messages into the lab report.
  3. Select three interesting messages regarding source code errors generated by splint, and explain the messages and the causes for their generation.

2.2 Task: Code Style

  1. Holzmann's paper (see the References of ../SecSoftware) presents "Ten Rules for Writing Safety Critical Code":
    1. Restrict to simple control flow constructs.
    2. Give all loops a fixed upper-bound.
    3. Do not use dynamic memory allocation after initialization.
    4. Limit functions to no more than 60 lines of text.
    5. Use minimally two assertions per function on average.
    6. Declare data objects at the smallest possible level of scope.
    7. Check the return value of non-void functions, and check the validity of function parameters.
    8. Limit the use of the preprocessor to file inclusion and simple macros.
    9. Limit the use of pointers. Use no more than two levels of dereferencing per expression.
    10. Compile with all warnings enabled, and use one or more source code analyzers.
  2. List all violations of these rules that sudo makes. Do this by manual inspection. Or, write a script.

2.3 Task: Experience Past Exploits: ShellShock

  1. Background: Learn about ShellShock 2014 bug in bash. Older versions of Bash can be tricked into executing arbitrary commands. Study these:
    1. https://en.wikipedia.org/wiki/Shellshock_(software_bug)
    2. https://www.sophos.com/hu-hu/lp/bash-shellshock.aspx
  2. Check if bash, as is, in a modern Linux has this vulnerability. Include details of the bash version. Describe in detail how you checked. Develop a detection script.
  3. Download a version claimed in the articles above as being vulnerable from http://ftp.gnu.org/gnu/bash/, which has older and current versions of bash. Build it. Rename the current /bin/bash as /bin/bash-orig . Install the one you built as /bin/bash. Verify that this version of bash has the vulnerability. Include details of the bash version you installed. Describe in detail how you verified. Develop a script that demonstrates.

2.4 Task: System Program fusermount

  1. Download from https://github.com/libfuse/libfuse. Build it, following the Installation guide. Become familiar with its files. Understand security-implications.
  2. Check that the just built fusermount works. Describe in detail how you verified. Develop a script that demonstrates.

2.5 Task: CERT Coding Guides

  1. Understand the following rules of CERT Coding Guide on C.
    1. EXP39-C. Do not access a variable through a pointer of an incompatible type
    2. EXP45-C. Do not perform assignments in selection statements
  2. Analyze, manually, the source code of fusermount.c for any violations of the above rules. Discover and explain at least two violations.

3 Submission

  1. You must follow the Lab Report Template. There should be a section on each of the tasks. A couple of lines of an answer to each (implied/ explicit) question/ discussion item.
  2. Submit a PDF file named exactly Report-L3.pdf. (Scripts are used to check various things – so file names should obey such "rules".)

4 References

  1. Prabhaker Mateti, ../SecSoftware 2020. Required Reading.

5 End


Copyright © 2020 www.wright.edu/~pmateti • 2020-09-30