Cloud Manager code quality · Java code rules (SonarQube) · updated

CQRules:CWE-134: Do not use format strings that are externally controlled

CQRules:CWE-134 fires when a format string passed to String.format (or a similar formatter) comes from outside the code, such as a request parameter. Keep the format string a constant in your code and pass user input only as an argument.

Rule keyCQRules:CWE-134
Adobe's rule nameDo not use format strings that are externally controlled
TypeVulnerability
SeverityMajor
Since2018.4.0
Checked bySonarQube analysis of your Java code

Why Cloud Manager flags it

Adobe's example is a doPost method that reads a parameter called messageFormat and hands it straight to String.format. In Java this is not the memory-corruption bug that CWE-134 describes for C, but it still lets a caller control the output: they can read arguments you did not mean to show, force exceptions with bad conversions (a cheap way to fill error logs) or inject markup into a response that you assumed was plain text.

Adobe's rule page gives no compliant example for this rule, so the fix below is the standard one. The same reasoning applies to MessageFormat.format, Formatter.format and logger calls that use the user value as the pattern.

Quick test for your code

CallFlagged?Why
String.format("Hello %s", name)NoPattern is a constant; input is an argument
String.format(request.getParameter("fmt"), name)YesPattern comes from the request
String.format(i18n.get(key), name)ReviewSafe if the dictionary is yours and not author-editable by untrusted users

Example

Non-compliant (as in Adobe's example)

protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) {
  String messageFormat = request.getParameter("messageFormat");
  response.getWriter().write(String.format(messageFormat, name));
}

Compliant: constant pattern, allow-listed choice

private static final Map<String, String> FORMATS = Map.of(
  "short", "Hello %s",
  "long", "Hello %s, welcome back");

String fmt = FORMATS.getOrDefault(request.getParameter("style"), "Hello %s");
response.getWriter().write(String.format(fmt, xssApi.encodeForHTML(name)));

How to fix it

  1. Find every formatter call whose first argument is not a literal or a constant.
  2. If callers need to pick a format, map a short key to a fixed pattern (an allow-list) instead of accepting the pattern itself.
  3. Encode the user value for the output context (the AEM XSSAPI encodeForHTML or encodeForJSString) before writing it.
  4. Re-run code quality; a Major vulnerability fails the Security Rating gate until it is gone.

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.

Questions

Is an i18n dictionary string an external format string?

Usually not, because the dictionary ships with your code. If authors can edit it in the repository, treat it as content and review who can change it.

Does the rule cover logging calls?

The rule targets format strings that the caller controls. A logger pattern built from request data has the same problem, so fix those too even if the scanner is silent.

Why is this a Major vulnerability in Java?

Adobe rates it Major. In Java it mainly allows information disclosure and error-log flooding rather than memory corruption, but it still fails the Security Rating gate.

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.