Skip to content

Commit 00708b6

Browse files
authored
Merge pull request #95 from vgharini/immutable-versioned-assignment
ImmutableVersionTwo
2 parents d154a54 + 585d021 commit 00708b6

File tree

1 file changed

+193
-0
lines changed

1 file changed

+193
-0
lines changed
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
# Security layer testing and penetration
2+
3+
In this assignment you will learn how to attack a reference monitor. The
4+
reference monitor you will be testing uses the security layer framework
5+
(encasement library, etc.) for the Seattle testbed. It is possible to do this
6+
assignment separately, but it is recommended that this assignment be completed
7+
after [Part One](./ImmutableVersionOne.md). Either way you should already have a working
8+
security layer or access to one. Testing the security layer is done by running a
9+
series of test cases that an adversary may use to circumvent your system. This
10+
assignment is intended to prepare you for thinking about security paradigms in a
11+
functional way. The ideas of information, security and privacy have been
12+
embedded into the steps of this assignment.
13+
14+
15+
## Overview
16+
17+
In this assignment you are a tester. You have been sent a bunch of reference
18+
monitors that need testing before they are deployed. Your job will be to ensure
19+
an attacker cannot circumvent these security layers. In order to do this, you
20+
will attempt to write testcases that check if the reference monitors behave as
21+
they should for any valid action that can be taken by a user. These testcases
22+
will try to trigger unexpected behaviours in the reference monitor. If they are
23+
able to do so, then the security layer is not secure. The future of the system depends on your
24+
ability to test code thoroughly!
25+
26+
Three design paradigms are at work in this assignment: accuracy, efficiency, and
27+
security.
28+
29+
* Accuracy: The security layer should only stop certain actions from being
30+
blocked. All other actions should be allowed.
31+
32+
* Efficiency: The security layer should use a minimum number of resources, so
33+
performance is not compromised.
34+
35+
* Security: The attacker should not be able to circumvent the security layer.
36+
37+
38+
Within the context of this assignment these design paradigms translate to:
39+
40+
- **Accuracy:** The defense monitor should precisely and consistently manage file operations. All unspecified actions must behave exactly as in the underlying API.
41+
- **Efficiency:** The security layer should use minimal resources. Do not cache or copy entire files in memory—only copy when creating a new version.
42+
- **Security:** The defense layer should be robust against tampering and circumvention. Attackers must not be able to bypass, disable, or exploit the defense monitor’s enhanced behaviors, ensuring that immutability and versioning are always enforced as intended.
43+
44+
You will submit a zip file containing all of the tests you have created. You
45+
will gain points for every student's reference monitor you find a flaw in. It is
46+
good if multiple tests of yours break a student's reference monitor, but you
47+
gain the same number of points whether one or more tests break the layer.
48+
49+
50+
## Prerequisites
51+
52+
This assignment assumes you have both the latest Python 2.7 and RepyV2 installed
53+
on your computer. Please refer to the [SeattleTestbed Build
54+
Instructions](../Contributing/BuildInstructions.md#prerequisites) for
55+
information on how to get them.
56+
57+
58+
### Helpful links
59+
60+
The following links will aid students in becoming comfortable with Python, Repy
61+
and seattle:
62+
* Official [Python tutorial](http://docs.python.org/tutorial/)
63+
* [Differences between RepyV2 and Python](../Programming/PythonVsRepyV2.md)
64+
* List of [RepyV2 API calls](../Programming/RepyV2API.md)
65+
66+
67+
## Testing security layers
68+
69+
### Hypothesis, test case, counter example
70+
71+
The goal of a good tester is to test hypotheses. A hypothesis is just a
72+
scientific way of asking a question. The hypothesis of this assignment is "This
73+
security layer is well designed." The questions you will ask when running your
74+
test cases will always be the same
75+
76+
* "Is this reference monitor secure?"
77+
78+
* "Does this reference monitor hamper performance?"
79+
80+
* "Does this reference monitor prevent actions that should be allowed?"
81+
82+
Notice that these questions are parallels of the security paradigms: security,
83+
efficiency and accuracy, respectively.
84+
85+
If we can find a case where the hypothesis is false, then the security layer is
86+
not secure. Such a case is referred to as a counter example. Hence all test
87+
cases should be designed to test for these three types of flaws.
88+
89+
#### Information on: Try, Except, Else, Finally
90+
91+
The try, except, else and finally statements are part of **exception handling**.
92+
For more information on exception handling please visit:
93+
94+
* [http://docs.python.org/tutorial/errors.html]
95+
* [http://wiki.python.org/moin/HandlingExceptions]
96+
* [http://www.tutorialspoint.com/python/python_exceptions.htm]
97+
98+
### Hints and Ideas for testing
99+
100+
When writing your own tests it is important to test for a complete set of
101+
possible penetrations. Keep in mind, it only takes one test case to break
102+
through a security layer. Some of the things you may want to test for include:
103+
104+
* threading
105+
* correct error handling
106+
107+
And more! Remember a good security layer can't be broken by anyone! Which is
108+
all part of the fun! It's about solving a puzzle. First you make the puzzle -
109+
write the security layer, then you solve the puzzle - try to bypass it. If your
110+
puzzle is "good enough", no one will be able to break it, no matter what.
111+
112+
113+
> Note: When creating tests, the best practice is to separate them into
114+
> different files. Each test file should focus on testing one specific scenario
115+
> or functionality. If there is a flaw in any part of a test file, we will
116+
> discard the entire test file. This modular approach helps isolate issues - if
117+
> there is a flaw in one test file, it will not affect or invalidate the other
118+
> test files, since each file is independent and testing distinct functionality.
119+
120+
121+
## Notes and Resources
122+
123+
* The following link is an excellent source for information about security
124+
layers: https://ssl.engineering.nyu.edu/papers/cappos_seattle_ccs_10.pdf
125+
126+
* In repy `log` replaces `print` from python. Many students find this to be a
127+
stumbling block.
128+
129+
* Note that you should not assume that any files exist in your directory. You
130+
should create any files (e.g., `testfile.txt`) yourself in your test program.
131+
132+
* It's important to note that if a test has a flaw in any part of it, the
133+
entire test will be considered invalid. So, it's advisable to break your
134+
tests into different files.
135+
136+
## How to run your tests on many reference monitors
137+
138+
Create a directory that the security layers will write their files into. You
139+
need to run repy with only access to this directory. You can write a test
140+
program that does `log(str(listfiles()))` to see if you are in the right place.
141+
142+
Have all the reference monitors to test and the test cases inside the same
143+
directory where the `repy.py` file exists.
144+
145+
* In the bash shell on Mac and Linux:
146+
```bash
147+
for referencemonitor in reference_monitor_*; do for testcase in <net_id>_*; do python repy.py restrictions.default encasementlib.r2py $referencemonitor $testcase; done; done
148+
```
149+
150+
* In the Command Prompt on Windows:
151+
```cmd
152+
FOR %r IN (reference_monitor_*) DO @FOR %a IN (<net_id>_*) DO @python repy.py restrictions.default encasementlib.r2py %r %a
153+
```
154+
155+
* In PowerShell on Windows:
156+
```powershell
157+
foreach ($referencemonitor in Get-ChildItem reference_monitor_*) { foreach ($testcase in Get-ChildItem <net_id>_*) { python repy.py restrictions.default encasementlib.r2py $referencemonitor.Name $testcase.Name } }
158+
```
159+
160+
This will print out the output from each program. Make sure that you replace
161+
`<net_id>` with your NetID.
162+
163+
If you want to spot the reference monitor that failed during the test run, add
164+
echo the name of each reference monitor before the inner loop, like so:
165+
166+
* In the bash shell on Mac and Linux:
167+
```bash
168+
for referencemonitor in reference_monitor_*; do echo $referencemonitor under test; for testcase in <net_id>_*; do python repy.py restrictions.default encasementlib.r2py $referencemonitor $testcase; done; done
169+
```
170+
171+
* In the Command Prompt on Windows:
172+
```cmd
173+
FOR %r IN (reference_monitor_*) DO @(ECHO %r under test & FOR %a IN (<net_id>_*) DO @python repy.py restrictions.default encasementlib.r2py %r %a)
174+
```
175+
176+
* In PowerShell on Windows:
177+
```powershell
178+
foreach ($referencemonitor in Get-ChildItem reference_monitor_*) { Write-Host $referencemonitor.Name; foreach ($testcase in Get-ChildItem <net_id>_*) { python repy.py restrictions.default encasementlib.r2py $referencemonitor.Name $testcase.Name } }
179+
```
180+
181+
This will print out the name of each reference monitor before it starts
182+
executing the test cases against it.
183+
184+
185+
## What to turn in?
186+
187+
* Turn in all the test cases in a zip file. The name of each testcase must match the following format: `<netid>_attackcase<num>.r2py`. For example, if your netid id `abc123`, then the submitted zip files must contain a set of files named as `abc123_attackcase1.r2py`, `abc123_attackcase2.r2py`. There are no restrictions on the number of attackcases that can be submitted.
188+
189+
* **Never raise unexpected errors or produce any output.** Your attackcase must not produce any error or output, if the reference monitor is behaving as it should. This applies for error checking as well. If the attackcase tries to trigger an expected error, it should catch and suppress that error if the reference monitor correctly raises that error.
190+
191+
* While you're allowed to test if the correct errors are being raised, you aren't allowed to check the error message for any errors. That means checking for `FileInUseError` is valid, but it's not valid to check the specific error message.
192+
193+
* Attackcases should be independent of each other. This means that you should not try to use any file (or it's contents) across different attackcases.

0 commit comments

Comments
 (0)