Lay down the laws of the land

This commit is contained in:
Connor Nelson
2023-02-17 11:33:05 -07:00
committed by GitHub
parent 329e56f2db
commit c7ec95a4cf
+36
View File
@@ -18,3 +18,39 @@ See each challenge's README for further information:
- [earth](./world/earth) - [earth](./world/earth)
- [mars](./world/mars) - [mars](./world/mars)
- [venus](./world/venus) - [venus](./world/venus)
## Challenge Writing Laws
### The Flag
The flag is located at `/flag`, and is only readable by root.
The challenge will execute as root.
Nothing else is true.
Do not assume any structure to the flag.
It may or may not have a prefix/suffix.
It may or may not be 50 bytes long.
These things WILL change, and if you rely on them, your challenge WILL break.
### The Challenge
The challenge is [`setuid`](https://en.wikipedia.org/wiki/Setuid).
This is how your challenge will execute as root.
What this *really* means:
- The process will run with an **effective** user of `root`.
- The process will run with a **real** user of `hacker`.
While an **effective** user of `root` is sufficient for opening the flag, there are some caveats.
When `/bin/sh` (which is linked to `/bin/dash`) is run under this, it will immediately set the **effective** user to the **real** user (unless the `-p` flag is provided).
This means that both the **effective** and **real** user will be `hacker`, and the flag will not be accessible.
This affects `system`, which ultimately just runs `/bin/sh`.
The challenge can rememedy this by explicitly setting the **real** user to the **effective** user:
```c
setreuid(geteuid(), -1)
```