React Security
ASecurityThis 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...
- 584 stars
- 0 votes
- 0 copies
- 2 views
- Added September 5, 2026
Works with
Security analysis
100/100Pro scans all 11 files and shows the line behind each finding
npx -y skills add HoangNguyen0403/agent-skills-standard --skill react-security --agent claude-codeAre you the author of React Security?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-react-security-a1f28263)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**.
Files in this skill
- eval-1.baseline.md
- eval-1.with-skill.md
- eval-2.baseline.md
- eval-2.with-skill.md
- eval-3.baseline.md
- eval-3.with-skill.md
- trigger-1.md
- trigger-2.md
- trigger-3.md
- trigger-4.md
Attribution
Related skills
View all in development →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.