# VNX-760: Password hash or KDF uses a constant or predictable salt

Reports a password hash or KDF salted with a literal constant, a salt-named constant that reaches the hash call, a fixed bcrypt salt.

| Field | Value |
|---|---|
| Rule ID | `VNX-760` |
| Severity | High |
| SARIF level | `error` |
| Kind | `sast` |
| Languages | Go, Java, JavaScript / TypeScript, Python |
| CWE | [CWE-760](https://cwe.mitre.org/data/definitions/760.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:RU/AL:S/IC:N/FC:LT/RP:RU/RL:S/AV:L/AS:N/IN:A/SC:A/BI:H/DI:H/EX:H/EC:N/P:H` |
| Tags | `password-hash` `predictable-salt` `cwe-760` |
| Source | [`internal/sast/rules/vnx-760.rego`](https://github.com/Vulnesis/cli/blob/main/internal/sast/rules/vnx-760.rego) |

## Overview

VNX-760 maps to [CWE-760: Use of a One-Way Hash with a Predictable Salt](https://cwe.mitre.org/data/definitions/760.html). It reports a constant written in the salt position of `hashlib.pbkdf2_hmac`, `hashlib.scrypt`, `PBKDF2HMAC`, `new PBEKeySpec`, `pbkdf2.Key`, `scrypt.Key`, `argon2.IDKey`, `crypto.pbkdf2Sync` or `crypto.scryptSync`, a literal `$2...` salt given to bcrypt, a salt-named variable assigned a constant and then used in a hash or KDF call, and a username or email used as the PBKDF2 salt.

It does not report random salts (`os.urandom`, `secrets`, `SecureRandom`, `crypto/rand`, `randomBytes`, `gensalt()`), a stored hash passed back to `hashpw` to verify, or salt constants used for something other than password hashing (itsdangerous signing namespaces, column names, lengths). Constant IVs and nonces are VNX-CRYPTO-010.

## Why this matters

A salt only helps if every password gets a different, unpredictable one. A constant salt is the same as no salt across the whole user table: one precomputed table covers every account, and identical passwords still produce identical hashes.

## What gets flagged

```python
SALT = b"s3cr3t-static-salt"                                            # flagged
return hashlib.pbkdf2_hmac('sha256', password.encode(), b'NaCl', 100000) # flagged
```

```java
private static final String SALT = "acme-2019";                         // flagged
PBEKeySpec spec = new PBEKeySpec(password, "salt".getBytes(), 65536, 128); // flagged
```

```go
return scrypt.Key([]byte(password), []byte("NaCl"), 32768, 8, 1, 32)    // flagged
```

## Remediation

1. Generate a fresh random salt of at least 16 bytes for every password (`os.urandom(16)`, `SecureRandom.nextBytes`, `crypto/rand.Read`, `crypto.randomBytes(16)`) and store it beside the hash.
2. Prefer bcrypt or Argon2 libraries that generate and embed the salt themselves.

## References

- [CWE-760: Use of a One-Way Hash with a Predictable Salt](https://cwe.mitre.org/data/definitions/760.html)
- [OWASP Password Storage Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/Password_Storage_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-760
// nosec vnx-760
```

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