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 key | CQRules:CWE-134 |
|---|---|
| Adobe's rule name | Do not use format strings that are externally controlled |
| Type | Vulnerability |
| Severity | Major |
| Since | 2018.4.0 |
| Checked by | SonarQube 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
| Call | Flagged? | Why |
|---|---|---|
| String.format("Hello %s", name) | No | Pattern is a constant; input is an argument |
| String.format(request.getParameter("fmt"), name) | Yes | Pattern comes from the request |
| String.format(i18n.get(key), name) | Review | Safe 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
- Find every formatter call whose first argument is not a literal or a constant.
- If callers need to pick a format, map a short key to a fixed pattern (an allow-list) instead of accepting the pattern itself.
- Encode the user value for the output context (the AEM XSSAPI encodeForHTML or encodeForJSString) before writing it.
- 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
- 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.