This document contains conceptual exercises and programming problems related to security for a SimpleWebServer application.
The conceptual exercises ask about the relationship between authentication and authorization and about threats posed by allowing file uploads.
The programming problems involve modifying the application to include file storage and logging functionality, mounting an attack to deface a home page, and mounting another attack to gain root access on the system running the server while covering tracks in the web log.
1. CHAPTER 4
Exercises for Part 1
Slides adapted from "Foundations of Security: What Every Programmer
Needs To Know" by Neil Daswani, Christoph Kern, and Anita Kesavan
(ISBN 1590597842; http://www.foundationsofsecurity.com). Except as
otherwise noted, the content of this presentation is licensed under the
Creative Commons 3.0 License.
2. Conceptual Exercises
Are there dependencies between any of the
security concepts that we covered? For
example, is authentication required for
authorization? Why or why not?
What happens if a client connects to
SimpleWebServer, but never sends any data
and never disconnects? What type of an attack
would such a client be able to conduct?
3. Programming Problem (1)
HTTP supports a mechanism that allows users
to upload files in addition to retrieving them
through a PUT command.
What threats would you need to consider if
SimpleWebServer also had functionality that could
be used to upload files?
For each of the specific threats you just listed, what
types of security mechanisms might you put in place
to mitigate the threats?
4. Programming Problem (2)
public void storeFile (BufferedReader br, OutputStreamWriter osw,
String pathname) throws Exception {
FileWriter fw = null;
try {
fw = new FileWriter(pathname);
Modify the
String s = br.readLine();
while (s != null) {
processRequest()
fw.write(s);
s = br.readLine();
method in SWS to
}
fw.close();
use this file storage
osw.write("HTTP/1.0 201 Created");
} catch(Exception e) {
and logging code.
osw.write("HTTP/1.0 500 Internal Server Error");
}
}
public void logEntry(String filename,String record) {
FileWriter fw = new FileWriter (filename, true);
fw.write(getTimestamp()+ " " + record);
fw.close();
}
public String getTimestamp() {
return (new Date()).toString();
}
5. Programming Problem (3)
Run your web server and mount an attack that
defaces the index.html home page.
Assume that the web server is run as root on a
Linux workstation. Mount an attack against
SimpleWebServer in which you take
ownership of the machine that it is running on.
By taking ownership, we mean that you should
be able to gain access to a root account, giving
you unrestricted access to all the resources on
the system. Be sure to cover your tracks so that
the web log does not indicate that you mounted
an attack.
Editor's Notes
Welcome to SEC103 on Secure Programming Techniques. In this course, I assume that you have some background in computer security, but now you want to put that background to use. For example, in the Computer Security Principles and Introduction To Cryptography courses, we cover topics such concerning trust and encryption. In this course, we put these principles into to practice, and I’ll show you have to write secure code that builds security into your applications from the ground up.