This is an IDOR/BOLA authorization vulnerability: the backend trusts the `userId` from the URL. Assumption: the URL is something like `/users/:userId`. Fix authorization server-side on every affected endpoint: ```ts // GET /api/users/:userId const requestedId = req.params.userId; const authenticatedUser = req.user; if (authenticatedUser.id !== requestedId && !authenticatedUser.roles.includes("admin")) { return res.status(404).json({ error: "Not found" }); // or 403 } return res.json(await use...
Scanned 9/5/2026
Install to Claude Code
npx -y skills add HoangNguyen0403/agent-skills-standard --skill react-security --agent claude-codeInstalls into .claude/skills of the current project.
Are you the author of React Security?
Add the live security badge to your README — it updates automatically with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-react-security-a1f28263)More formats (shields.io, HTML) on the badges page.
This is an IDOR/BOLA authorization vulnerability: the backend trusts the `userId` from the URL.
Assumption: the URL is something like `/users/:userId`.
Fix authorization server-side on every affected endpoint:
```ts
// GET /api/users/:userId
const requestedId = req.params.userId;
const authenticatedUser = req.user;
if (authenticatedUser.id !== requestedId && !authenticatedUser.roles.includes("admin")) {
return res.status(404).json({ error: "Not found" }); // or 403
}
return res.json(await userService.getPrivateData(requestedId));
```
Prefer deriving the ID from the authenticated session when users may only access their own data:
```ts
const user = await userService.getPrivateData(req.user.id);
```
Do not rely on React route guards or hidden UI controls; **no client logic for permissions**. Backend authorization must validate ownership or an explicit role for every read and write operation, including nested resources and alternate API routes.
Also:
- Store sessions/JWTs in `HttpOnly` and `Secure` cookies, never `localStorage`.
- Use `SameSite=Strict` where applicable and CSRF tokens for state-changing requests.
- Validate and sanitize the URL ID and all other inputs on the backend.
- Add tests proving user A cannot access user B’s data, including guessed IDs, UUIDs, alternate methods, and missing/invalid IDs.
- Run `npm audit` or `pnpm audit`, and **pin specific dependency versions**.
Is this your skill, or is something wrong with this listing? . Author removals are honored within 72 hours.
No comments yet. Be the first to comment!