Sample Midterm Exam
-
The following code fragment exists in a program that is setuid to root. Its function is to read a series of lines from the standard input and append them to the file named in the variable file. However, for security reasons, it must not append the lines if file is a symbolic link to another file. The following sequence is intended to implement this functionality. Please determine if it does correctly (i.e.., does this code pose a security risk)? Justify your answer, of course. (Note: the label error is defined elsewhere to handle error conditions.)
/* get the attributes of the file associated with
the name; do not follow any symbolic links */
if (lstat(file, &buf) < 0)
goto error;
if ((buf.st_mode&S_IFLNK) == S_IFLNK){
fprintf(stderr, "%s is a symbolic link\n", file);
goto error;
}
/* open the file, write to it, and close it */
if ((fp = fopen(file, "a")) == NULL)
goto error;
while(fgets(buf, BUFSIZ, stdin) != NULL)
fputs(buf, fp);
(void) fclose(fp);
-
Why is a precise statement of security requirements critical to the determination of whether a given system is secure?
-
Please describe how the vulnerabilities models are used during the Flaw Hypothesis Methodology. Be explicit: which phase of the methodology uses them, and how?
-
Into which category or categories of the Program Analysis classification do the following fall? Please justify your answer.
-
Buffer overflow causing a return into the stack?
-
Allowing an ordinary user to alter the password file?
-
Simultaneous writes to a shared database?
-
Reading a UNIX file by directly accessing the raw device and reading first the superblock, then the file's inode, and finally the file's data blocks?
-
Consider the Bell-LaPadula multilevel security model. If a subject with security label (L, C) can read an object with security label (L', C'), then (L, C) is said to dominate (L', C'). Prove that this dominates relation is reflexive, antisymmetric, and transitive.