Skip to content

Commit 2b1a457

Browse files
author
Robert Quander
committed
Added more documentation, will finish second exploit and rest tomorrow :D
1 parent 74a600f commit 2b1a457

File tree

11 files changed

+86
-1
lines changed

11 files changed

+86
-1
lines changed

documentation/001register.png

30.5 KB
Loading

documentation/002posting.png

45.3 KB
Loading

documentation/003posting.png

140 KB
Loading

documentation/README.md

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Facepalm Documentation
33

44
## Table of Contents
55

6+
[Facepalm Documentation](#facepalm-documentation)
67
- [Facepalm Documentation](#facepalm-documentation)
78
- [Table of Contents](#table-of-contents)
89
- [1. Introduction](#1-introduction)
@@ -11,6 +12,15 @@ Facepalm Documentation
1112
- [3.1 Clone the Repository](#31-clone-the-repository)
1213
- [3.2 Running the Service](#32-running-the-service)
1314
- [3.3 Running the Checker](#33-running-the-checker)
15+
- [4. Usage](#4-usage)
16+
- [Registering](#registering)
17+
- [Posting](#posting)
18+
- [Uploading profile pic and bio](#uploading-profile-pic-and-bio)
19+
- [Creating, viewing and joining Events](#creating-viewing-and-joining-events)
20+
- [5. The Exploits and their fixes](#5-the-exploits-and-their-fixes)
21+
- [5.1 Insecure UUID Generation](#51-insecure-uuid-generation)
22+
- [Exploit](#exploit)
23+
- [The Fix](#the-fix)
1424

1525

1626
## 1. Introduction
@@ -62,7 +72,12 @@ cd service
6272
docker compose up --build -d
6373
```
6474

65-
*Note: It could take some time for compilation, Swift build times are a little much sometimes*
75+
*Note: It could take some time for compilation, Swift build times are a little much sometimes (5th gen mobile ryzen 5 ~200s)*
76+
77+
Taking a look at the running containers, either in the Docker UI or using `docker ps`, three containers can be seen running associated with facepalm:
78+
1. The service itself
79+
2. The DB to store the user data
80+
3. A cleanup container that keeps the DB footprint small
6681

6782
### 3.3 Running the Checker
6883

@@ -72,4 +87,74 @@ In the same fashion as the service has been started, the checker can be deployed
7287
cd checker
7388
docker compose up --build -d
7489
```
90+
Taking a look inside the running containers, we can now observe 2: the checker itself, and a Mongo DB it needs for its data.
91+
92+
## 4. Usage
93+
94+
Once Facepalm has finished building, you can access the web interface with any browser. The service can be found on port `4269` (i.e. `localhost:4269`).
95+
96+
While using, special attention is required at the top bar - the buttons move around, just to keep the users on their toes.
97+
98+
### Registering
99+
100+
Registering must be done with a unique user name
101+
102+
![registration](001register.png)
103+
104+
### Posting
105+
106+
Posts can be made either privately or publically, by unchecking the private checkmark.
107+
108+
![creating post](002posting.png)
109+
![Successfully posted](003posting.png)
110+
111+
### Uploading profile pic and bio
112+
113+
The profile picture and bio can both always be seen publically on the home-of address
114+
115+
![Settings Profile pic and bio](image.png)
116+
![Profile pic and bio set](image-1.png)
117+
118+
### Creating, viewing and joining Events
119+
120+
When creating an event, the date can be set freely, since it's stored as a string. Private fields are noted as such. The only important field to set is the title, the rest is optional
121+
122+
![Create Event](image-2.png)
123+
124+
After all data for the event has been entered, a key is shown for one time (similarly to a token on GitLab) and can be forwarded to anyone who wants help organize the event. However, an event can also be joined by sending a request to the given event and then being accepted by an event invitee. This can be accomplished on the event info page.
125+
![Key shown](image-3.png)
126+
![Finished event](image-4.png)
127+
128+
Then all events can be viewed, and, if not already in it, access can be requested, and granted (here, another user logged in to view the event, who is not invited:).
129+
130+
![All events](image-5.png)
131+
![hidden event details](image-6.png)
132+
133+
## 5. The Exploits and their fixes
134+
135+
### 5.1 Insecure UUID Generation
136+
137+
The User IDs and the Post IDs are both derived deterministically (in the classes `IdentifierGenerator.swift` and `PostIDGenerator.swift`, respectively).
138+
139+
The User ID is directly derived from a (padded or cut) username, while the PostID is derived from the User ID, a counter (initialized to 0) and a timestamp (with `minute` precision). These values are `XOR`ed together, and then form the (derivable) PostID.
140+
141+
#### Exploit
142+
143+
`Flag hint: username`
144+
The 'fun' in this exploit is the difference between python and Swift handling uppercase vs. lowercase (hex) strings, and the different ways they `XOR` things.
145+
146+
The easy mode of the exploit might be just copying the given swift files, and then writing a little python script that calls it with the given time stamp of the current system time, and username, and then passing the result forward. However, if the exploit is to be written in python, specific libraries have to be used to achieve the same result. This even baffles most (current) AI systems that have been tested, and solving it using LLMs results in quite long troubleshooting steps, since it should work, but somehow just does not.
147+
148+
A working and annotated example of a python implementation for the exploit can be seen in `checker/src/FinalFinalTry.py`.
149+
150+
#### The Fix
151+
152+
Fixing the exploit is as simple as replaxing the entire class contained in `service/Sources/App/Models/IdentifierGenerator.swift` with
153+
154+
```Swift
155+
return uuid()
156+
```
157+
158+
This returns a secure uuid, from which the postID is then derived. For additional security, this could also be replaced by the same logic.
75159

160+
Alternatively, only the PostID generation could be made secure. In the current state of development for facepalm, the deterministic User ID does not have implications (that have been found).

documentation/image-1.png

139 KB
Loading

documentation/image-2.png

70.3 KB
Loading

documentation/image-3.png

52.1 KB
Loading

documentation/image-4.png

74.1 KB
Loading

documentation/image-5.png

24.8 KB
Loading

documentation/image-6.png

67.2 KB
Loading

0 commit comments

Comments
 (0)