BETA Shoulder is in beta — Findings may sometimes be wrong. Your feedback shapes what we fix next. Share feedback

TypeORM Mass Assignment Vulnerability

Description

Directly assigning req.body to entities allows attackers to modify protected fields like role, isAdmin, or credits.

What Shoulder detects

Entity properties assigned directly from user input without whitelisting. This allows unauthorized field modification.

How to fix

Use explicit field assignment instead of spreading request data.

```typescript
const user = repository.create({
  username: req.body.username,
  email: req.body.email
  // role and isAdmin not assigned from user input
});
```

Learn more: https://shoulder.dev/learn/typescript/cwe-915/mass-assignment

Applies to

Frameworks

typeorm

References

Scan for this issue

Detect with Shoulder CLI
npx @shoulderdev/cli trust --rule=typeorm-mass-assignment .

Related rules