# VNX-224: Obscured Security-relevant Information by Alternate Name

A log call writes a credential (password, secret, token, API key) base64-encoded, inline or through a variable, in JavaScript.

| Field | Value |
|---|---|
| Rule ID | `VNX-224` |
| Severity | Medium |
| SARIF level | `warning` |
| Kind | `sast` |
| Languages | JavaScript / TypeScript, Python |
| CWE | [CWE-224](https://cwe.mitre.org/data/definitions/224.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 | `obscured-security-info` `cwe-224` `logging` `base64` |
| Source | [`internal/sast/rules/vnx-224.rego`](https://github.com/Vulnesis/cli/blob/main/internal/sast/rules/vnx-224.rego) |

## Overview

VNX-224 maps to [CWE-224: Obscured Security-relevant Information by Alternate Name](https://cwe.mitre.org/data/definitions/224.html). It reports a log call (`console.*`, `logger.*`, `log.*`, `logging.*`, winston, pino) whose argument is `btoa()`, `Buffer.from(x).toString('base64')` or `base64.b64encode()` (and the urlsafe, standard, b32, b16 and `encodebytes` forms) of a value named as a secret, either inline or through a variable assigned from such an encoding in the six lines above.

## Why this matters

Encoding a credential before logging it looks like masking, but anyone who reads the log decodes it in one step. The log then holds the secret itself under a different spelling, which also defeats log scanners that look for the plain value.

A log call broken over several lines is judged as the whole call. The secret word has to end the name, so `passwordPolicy`, `tokenizer_output` and `apiKeyId` are not credentials.

Not reported: base64 of values not named as secrets, the `.length`/`len()` of an encoded value, an encoded credential that is built but not logged (a Basic auth header), hashed values (hashlib, sha256, createHash, digest, bcrypt), the pattern inside a plain string literal or a comment, and test code. The wider CWE-224 sense (recording an entity under a non-canonical name) is not decidable line by line and is not judged.

## What gets flagged

```javascript
console.log("login attempt", username, btoa(password));
logger.info(`issued ${Buffer.from(accessToken).toString("base64")} to ${user.id}`);
```

```python
logger.info("auth %s %s", username, base64.b64encode(password.encode()))

masked = base64.b64encode(api_key.encode()).decode()
log.warning("connecting with key %s", masked)
```

## Remediation

1. Do not log credentials in any encoding.
2. When a log line must identify a key, log a non-reversible identifier: a key id, or a short prefix of a hash of the value.

## References

- [CWE-224: Obscured Security-relevant Information by Alternate Name](https://cwe.mitre.org/data/definitions/224.html)
- [CWE-532: Insertion of Sensitive Information into Log File](https://cwe.mitre.org/data/definitions/532.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-224
// nosec vnx-224
```

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