# VNX-915: Mass assignment: the whole request body is written onto a model

Reports mass assignment in JavaScript/TypeScript: the whole request body written onto a model (Object.assign, new Model, ORM create/update, Prisma data.

| Field | Value |
|---|---|
| Rule ID | `VNX-915` |
| Severity | High |
| SARIF level | `error` |
| Kind | `sast` |
| Languages | JavaScript / TypeScript |
| CWE | [CWE-915](https://cwe.mitre.org/data/definitions/915.html) |
| CAPEC | [CAPEC-66](https://capec.mitre.org/data/definitions/66.html) |
| ATT&CK | [T1190](https://attack.mitre.org/techniques/T1190/) |
| CWSS vector | `CWSS:1.0/TI:H/AP:A/AL:A/IC:N/FC:LT/RP:N/RL:A/AV:I/AS:N/IN:A/SC:A/BI:H/DI:H/EX:H/EC:N/P:H` |
| Tags | `mass-assignment` `cwe-915` |
| Source | [`internal/sast/rules/vnx-915.rego`](https://github.com/Vulnesis/cli/blob/main/internal/sast/rules/vnx-915.rego) |

## Overview

The request body is copied wholesale onto a persistent object, so a client can set any field the model has (`role`, `isAdmin`, `price`, `ownerId`). In JavaScript/TypeScript the rule reports `Object.assign(target, req.body)`, `new Model(req.body)`, ORM writes (`create`, `insert*`, `update*`, `findByIdAndUpdate`, `upsert`, `set`, `merge`) given `req.body`, `req.body.<member>`, `req.query` or `ctx.request.body` directly or spread into an object literal, Prisma `data: req.body`, MongoDB `{ $set: req.body }`, and the same through a variable assigned from the body.

Ruby mass assignment (`.permit!`, ActiveRecord `new`/`create`/`update`/`assign_attributes` given a raw `params[:key]` or `params.to_unsafe_h`, and a `permit(...)` list that admits a privilege attribute) is the same weakness and is reported by [VNX-RUBY-006](/sast/rules/vnx-ruby-006.md), not here, so a Rails controller line is not reported twice.

## Why this matters

Fields the form never offers are still accepted: a sign-up request that adds `"role": "admin"` or an order update that sets its own price succeeds.

## What gets flagged

```javascript
const p = await Product.create(req.body);
const other = await Account.create({ ...req.body, owner: req.user.id });
```

Not flagged: explicit fields (`create({ name: req.body.name })`), bodies filtered through pick/omit or a validator, `Object.assign({}, ...)` copies, hash/HMAC `update()`, built-in constructors, comments and strings. Ruby files are left to VNX-RUBY-006.

## Remediation

Copy the allowed fields explicitly, or validate the body against a schema that strips unknown keys.

## References

- [CWE-915](https://cwe.mitre.org/data/definitions/915.html)
- [OWASP Mass Assignment Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Mass_Assignment_Cheat_Sheet.html)

## Suppressing this rule

Put a `nosec` comment on the line, or on line 1 to cover the whole file. Use the comment marker of the file's language (`#`, `//`, `--` or `;`):

```text
# nosec vnx-915
// nosec vnx-915
```

Or record an ignore rule: `vulnetix ignore add --rule vnx-915 --reason "..."`. See [Suppressing findings](/sast/guides/suppressing-findings.md).
