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 keyCQRules:CWE-676
Adobe's rule nameDo not use potentially dangerous functions
TypeVulnerability
SeverityMajor
Since2018.4.0
Checked bySonarQube 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

PatternTypical locationBetter approach
Thread.stop() to cancel an importCustom servlet behind a 'Stop' buttonFlag checked between batches, or a Sling Job that can be stopped
Thread.stop() on timeoutWrapper around a slow HTTP callSet socket and connect timeouts on the client
Raw threads started from a componentOSGi @Activate methodSling 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

  1. Search the code base for .stop() on Thread objects (and suspend()/resume(), which are deprecated for similar reasons).
  2. Add a volatile boolean (or use Thread.interrupt() and check isInterrupted()) and make the loop exit cleanly, closing any ResourceResolver it opened.
  3. 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.
  4. 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

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.

Scan, Convert, Verify, Install

How Surge Migrate helps with a move to AEM as a Cloud Service

Surge Migrate moves a website from any CMS to any CMS, and AEM as a Cloud Service is one of the systems it writes. Pages are converted automatically, and you check the result before you install anything.

  1. 1

    Scan

    Names the system behind your site, counts pages and templates, lists the blocks to build and the work no tool does, and gives an effort range with its working.

    Scan a site →
  2. 2

    Convert

    Each page becomes an Edge Delivery document, an AEM Core Component page and import files for 7 other systems. 10 pages free; 500 or 2,000 pages in one paid run.

    Convert your pages →
  3. 3

    Verify

    A download is offered only when its own format check passes. The report lists every field not found and every component kept as plain content. Compare old and new pages side by side.

    Parity check →
  4. 4

    Install

    You import with the target system's own tool, on your own environment. Each download's README gives the command. Your system changes only when you run it.

    How each import was tested →

Content packages installed on a local AEM as a Cloud Service SDK. See the worked examples.

On AEM 6.5 code: Scan AEM 6.5 code free. The scan reads a repository zip or a Best Practices Analyzer CSV in your browser and lists Cloud Service blockers with file, fix and effort. Nothing is uploaded.