Horizontal Privilege Escalation
Description
Detects when user-controlled input is used to access resources belonging to other users at the same privilege level without verifying ownership.
What Shoulder detects
How to fix
Filter queries by authenticated user ID to verify ownership.
```javascript
const profile = await User.findOne({
where: { id: req.params.userId, userId: req.user.id }
});
```
Learn more: https://shoulder.dev/learn/javascript/cwe-639/horizontal-privilege-escalation
Applies to
Languages
Frameworks
express
fastify
nextjs
koa
hapi
nestjs
References
Scan for this issue
Detect with Shoulder CLI
npx @shoulderdev/cli trust --rule=javascript-horizontal-privilege-escalation .