Cloud Manager code quality · Java code rules (SonarQube) · updated
CQRules:CWE-676: Do not use potentially dangerous functions
CQRules:CWE-676 fires when AEM Java code calls a function that is unsafe by design, and Adobe's example is Thread.stop(). The fix is to let the thread finish on its own: set a volatile flag that the thread's run() loop checks, and return when it flips.
| Rule key | CQRules:CWE-676 |
|---|---|
| Adobe's rule name | Do not use potentially dangerous functions |
| Type | Vulnerability |
| Severity | Major |
| Since | 2018.4.0 |
| Checked by | SonarQube analysis of your Java code |
Why Cloud Manager flags it
The rule is named after CWE-676, the MITRE weakness entry for 'use of potentially dangerous function'. Thread.stop() is the classic case: it throws ThreadDeath at whatever line the target thread happens to be on, releases every monitor the thread holds and can leave shared objects half-updated. In AEM that thread might be in the middle of writing to a JCR session, an asset rendition or a cache, so the damage shows up later as corrupt state rather than as an error at the call site. The JDK has marked Thread.stop() deprecated since Java 1.2 for exactly this reason.
Because Adobe classes the rule as a Major vulnerability, a single hit is enough to fail the Security Rating gate. Teams moving from AEM 6.5 often find it in old import jobs or custom 'kill switch' servlets written to cancel a long-running task from the console.
Where it usually hides in AEM 6.5 code
| Pattern | Typical location | Better approach |
|---|---|---|
| Thread.stop() to cancel an import | Custom servlet behind a 'Stop' button | Flag checked between batches, or a Sling Job that can be stopped |
| Thread.stop() on timeout | Wrapper around a slow HTTP call | Set socket and connect timeouts on the client |
| Raw threads started from a component | OSGi @Activate method | Sling Jobs or a managed executor closed in @Deactivate |
Example
Non-compliant (pattern from Adobe's example)
public void stopWorker() {
worker.stop(); // Thread.stop(): CQRules:CWE-676
}Compliant: a flag the worker checks
private volatile boolean keepGoing = true;
public void run() {
while (keepGoing) {
processNextBatch();
}
}
public void stopWorker() {
keepGoing = false;
}How to fix it
- Search the code base for .stop() on Thread objects (and suspend()/resume(), which are deprecated for similar reasons).
- Add a volatile boolean (or use Thread.interrupt() and check isInterrupted()) and make the loop exit cleanly, closing any ResourceResolver it opened.
- If the work is long-running, move it to a Sling Job so it survives restarts and can be retried, which matters on Cloud Service where pods are replaced at any time.
- Re-run the Cloud Manager code quality step and confirm the Security Rating is back to A.
Does it stop the pipeline?
As a major vulnerability it drops the Security Rating below B. Adobe's gate treats a Security Rating below B as a critical failure, so the pipeline stops until the code is fixed.
If a finding is a genuine false positive, Adobe's code quality page lets you annotate the code with @SuppressWarnings and the rule ID. In a full-stack pipeline, important failures can be overridden by a deployment manager, project manager or business lead; in a code-quality-only pipeline they cannot.
Related pages on this site
Questions
Can I suppress CWE-676 instead of fixing it?
Adobe's page allows @SuppressWarnings with the rule ID for false positives, but a real Thread.stop() call is not a false positive. Replacing it is usually a ten-line change.
Does Thread.interrupt() satisfy the rule?
Yes. interrupt() only sets a flag and wakes blocking calls; the thread still decides when to stop, which is the point of the rule.
Will this block my Cloud Service go-live?
It blocks every pipeline run that reaches code quality, because a Major vulnerability fails the Security Rating gate. Fix it before your first production deployment.
See the Cloud Service blockers in your code before Cloud Manager shows them. The free Surge Migrate readiness scan reads a repository zip or a Best Practices Analyzer CSV in your browser and lists them with file, fix and effort. Nothing is uploaded.
Sources
- Adobe: Custom code quality rules (checked 10 Nov 2026)
- Adobe: Code quality testing in Cloud Manager (checked 10 Nov 2026)
Rule key, type, severity and version are as listed on Adobe's page, checked 10 Nov 2026. Explanations and examples are ours unless marked as Adobe's.