VNX-572: Call to Thread run() instead of start()
Reports a Java or Kotlin Thread whose run() is called directly, so the work runs synchronously on the calling thread instead of on a new one.
| Field | Value |
|---|---|
| Rule ID | VNX-572 |
| Severity | Low |
| SARIF level | note |
| Kind | sast |
| Languages | Java, Kotlin |
| CWE | CWE-572 |
| CAPEC | CAPEC-66 |
| ATT&CK | 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 | no-invocation thread concurrency cwe-572 |
| Source | internal/sast/rules/vnx-572.rego |
Overview
VNX-572 maps to CWE-572: Call to Thread run() instead of start(). Thread.run() is an ordinary method call: it executes the thread’s work on the current thread and returns when it finishes. No new thread is created. The caller blocks, and whatever the thread was meant to provide (concurrency, a watchdog, isolation of a slow or hostile task) is lost.
What Gets Flagged
new Thread(task, "report").run();
Thread worker = new Thread(task);
worker.run();
new Thread(() -> {
for (String k : keys) {
cache.load(k);
}
}).run();
val t = Thread(work, "indexer")
t.run()
Thread { rebuild() }.run()
The receiver must be declared in the same file as a Thread (field, local, parameter, var t = new Thread(...), Thread.ofVirtual().unstarted(...), val t = Thread(...)) or as a class of the file that extends Thread.
What Is Not Flagged
start().run()on aRunnableor any other type.super.run()inside arun()override.- Kotlin’s
run { }scope function. - The call in comments or string literals.
Remediation
- Call
start()to run the work on the new thread, andjoin()if the caller must wait. - If the work should run on the current thread, call the
Runnabledirectly and drop theThread. - Prefer an
ExecutorServicefor pooled background work.
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-572
// nosec vnx-572
Or record an ignore rule: vulnetix ignore add --rule vnx-572 --reason "...". See Suppressing findings.