# 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](https://cwe.mitre.org/data/definitions/1285.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: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`](https://github.com/Vulnesis/cli/blob/main/internal/sast/rules/vnx-1285.rego) |

## Overview

VNX-1285 maps to [CWE-1285: Improper Validation of Specified Index, Position, or Offset in Input](https://cwe.mitre.org/data/definitions/1285.html).

## 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

```python
idx = int(request.args.get("index", 0))
return SLIDES[idx]

job = JOBS[int(request.GET["pos"])]
```

```javascript
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

1. Check `0 <= index < len(items)` (or `index >= 0 && index < items.length`) before indexing, and return 400/404 otherwise.
2. Prefer looking records up by an identifier rather than by position.

## References

- [CWE-1285: Improper Validation of Specified Index, Position, or Offset in Input](https://cwe.mitre.org/data/definitions/1285.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-1285
// nosec vnx-1285
```

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