The Gate of Broken Names - CTF Writeup

Challenge: The Gate of Broken Names Category: Web Difficulty: Easy/Medium

Challenge Description

Among the ruins of Briarfold, Mira uncovers a gate of tangled brambles and forgotten sigils. Every name carved into its stone has been reversed, letters twisted, meanings erased. When she steps through, the ground blurs�the village ahead is hers, yet wrong: signs rewritten, faces familiar but altered, her own past twisted. Tracing the pattern through spectral threads of lies and illusion, she forces the true gate open�not by key, but by unraveling the false paths the Hollow King left behind.

Initial Reconnaissance

The challenge presents a web application running on 167.172.XX.XX.XX:XXXXX with a notes/journaling system. Users can register accounts, login, and manage personal notes.

Application Structure

The application appears to be a Node.js/Express application with the following key features:

  • User registration and authentication

  • Note creation and management

  • Public and private note visibility

  • Session-based authentication

Source Code Analysis

After examining the application source code, several key files reveal the vulnerability:

Authentication System (/server/routes/auth.js)

The authentication system allows user registration and login with basic validation:

Notes System (/server/routes/notes.js)

The critical vulnerability lies in the notes endpoint:

Vulnerability Identified: The endpoint checks if a user is authenticated but does not verify ownership of the requested note. This creates an Insecure Direct Object Reference (IDOR) vulnerability.

Data Initialization (/server/init-data.js)

The initialization script reveals how the flag is stored:

Key findings:

  • The flag is stored in a private note (is_private: 1)

  • The note is placed at a random position among ~200 generated notes

  • Note IDs start from 11 (after 10 system notes)

  • The flag note belongs to user ID 1 (admin)

Exploitation

Vulnerability: Insecure Direct Object Reference (IDOR)

The /api/notes/:id endpoint allows any authenticated user to access any note by ID, regardless of:

  • Note privacy settings (is_private)

  • Note ownership (user_id)

Exploitation Strategy

  1. Register a new user account

  2. Authenticate with the application

  3. Enumerate note IDs to find the flag

  4. Extract the flag from the private note

Exploit Implementation

Mitigation

To fix this vulnerability, implement proper authorization checks:

Key Takeaways

  1. Authentication ? Authorization: Just because a user is logged in doesn't mean they should access all resources

  2. IDOR vulnerabilities are common in applications that use predictable resource identifiers

  3. Always implement ownership checks before returning sensitive data

  4. Private/sensitive data should never be accessible through direct object references without proper authorization

Last updated