VNX-1285: Improper Validation of Specified Index, Position, or Offset in Input
A position the client chose is used to index a list or array with no bounds check, so a negative value silently selects from the end (Python).
| Field | Value |
|---|---|
| Rule ID | VNX-1285 |
| Severity | Medium |
| SARIF level | warning |
| Kind | sast |
| Languages | JavaScript / TypeScript, Python |
| CWE | CWE-1285 |
| CAPEC | CAPEC-66 |
| ATT&CK | T1190 |
| CWSS vector | CWSS:1.0/TI:M/AP:RU/AL:S/IC:N/FC:LT/RP:RU/RL:S/AV:L/AS:N/IN:A/SC:A/BI:M/DI:H/EX:M/EC:N/P:C |
| Tags | improper-validation-of-specified-index bounds cwe-1285 |
| Source | internal/sast/rules/vnx-1285.rego |
Overview
VNX-1285 maps to CWE-1285: Improper Validation of Specified Index, Position, or Offset in Input.
Why this matters
A position from the request used directly as a list index lets the client pick any element. In Python a negative index silently counts from the end. An out-of-range index raises an error or yields undefined, and .pop()/.splice() can remove an element the client was never offered.
What gets flagged
idx = int(request.args.get("index", 0))
return SLIDES[idx]
job = JOBS[int(request.GET["pos"])]
const i = parseInt(req.params.index, 10);
res.json(items[i]);
tracks.splice(+req.body.position, 1);
Not flagged: an index checked against 0 and len()/.length before use, slices (rows[offset:offset + 20], .slice()), lookups keyed by a string (users[req.params.id]).
Remediation
- Check
0 <= index < len(items)(orindex >= 0 && index < items.length) before indexing, and return 400/404 otherwise. - Prefer looking records up by an identifier rather than by position.
References
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 ;):
# nosec vnx-1285
// nosec vnx-1285
Or record an ignore rule: vulnetix ignore add --rule vnx-1285 --reason "...". See Suppressing findings.