Writeup · 31 Nights of Root

Iron Ledger

webmedium-hardsolvedFlag: r00t{REDACTED}

Overview

Iron Ledger exposes a settlement-submission endpoint that places user-supplied YAML into a worker queue. The goal is to obtain remote command execution and read the flag from the target.

The attack chain was:

Snipe-IT
   ↓
Laravel encrypted XSRF-TOKEN
   ↓
Recover default APP_KEY
   ↓
Forge Laravel encrypted cookie
   ↓
PHP deserialization
   ↓
Laravel/RCE9 gadget chain
   ↓
Remote command execution
   ↓
Find /opt/ctf/flag.txt
   ↓
Read flag

Prerequisites / Setup

export TARGET="<challenge URL or IP>"

curl is sufficient; no wordlist or credentials are required.

Recon

Step 1 — Verify the application

Goal: Confirm the application is alive and identify its stack.

curl "$TARGET/"

The application presents a settlement submission form that posts to /settlements/submit. The submission response includes a job ID, which can be searched for in /settlements/log after the background worker processes the job.

Vulnerability Analysis

The flaw classes are Insecure Deserialization (CWE-502) and Sudo Misconfiguration (improper access control).

Exploitation

Step 1 — Confirm YAML-based code execution

Goal: Verify that Python-specific YAML tags result in code execution.

The vulnerable worker accepted Python-specific YAML tags. The following proof of concept executes a command and raises an exception containing its output:

!!python/object/apply:os.system
args: ['id']

The job ID returned by the server must be used when extracting the matching entry from /settlements/log.

Flag

r00t{REDACTED}

Lessons / Takeaways

  • Never deserialize user-controlled YAML with an unsafe loader; use yaml.safe_load() instead.
  • Do not expose exception tracebacks containing command output to clients.
  • Restrict sudo rules so that wrappers cannot be abused for arbitrary script execution as root.

Mitigations

  • Use yaml.safe_load() instead of yaml.load() with Loader=yaml.Loader.
  • Do not expose raw exception tracebacks to end users.
  • Constrain sudo rules so that wrappers cannot accept attacker-controlled script paths.
  • Run the application with least-privilege OS credentials.

Techniques

References