# VNX-585: Empty synchronized block

Reports synchronized (lock) blocks in Java and Kotlin that contain no code. Blocks with statements and synchronized methods are not reported.

| Field | Value |
|---|---|
| Rule ID | `VNX-585` |
| Severity | Low |
| SARIF level | `note` |
| Kind | `sast` |
| Languages | Java, Kotlin |
| CWE | [CWE-585](https://cwe.mitre.org/data/definitions/585.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:L/AP:RU/AL:S/IC:N/FC:LT/RP:RU/RL:S/AV:L/AS:N/IN:A/SC:A/BI:L/DI:H/EX:L/EC:N/P:L` |
| Tags | `empty-sync` `cwe-585` |
| Source | [`internal/sast/rules/vnx-585.rego`](https://github.com/Vulnesis/cli/blob/main/internal/sast/rules/vnx-585.rego) |

## Overview

VNX-585 maps to [CWE-585: Empty Synchronized Block](https://cwe.mitre.org/data/definitions/585.html). It reports a `synchronized (lock)` statement whose body is `{}` on the same line, or whose opening brace (same line or next) is followed only by blank and comment lines before the closing brace.

## Why this matters

An empty synchronized block guards nothing. It is usually a critical section whose statements were moved out by mistake, or an attempt to wait for another thread that depends on undocumented timing and does not establish the ordering the author expects.

## What gets flagged

```java
synchronized (lock) {}
synchronized (mutex) {
}
```

```kotlin
synchronized(lock) {}
```

Not flagged: `synchronized (lock) { count++; }`, `public synchronized void reset() {}`, comments and strings.

## Remediation

1. Put the statements that need the lock inside the block.
2. To wait for another thread, use `wait`/`notify`, a `CountDownLatch`, or another `java.util.concurrent` synchronizer.

## References

- [CWE-585: Empty Synchronized Block](https://cwe.mitre.org/data/definitions/585.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-585
// nosec vnx-585
```

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