Skip to content

General issue: CWE-116 not reported for unescaped XML output in JavaScript/TypeScript #21022

@aniakowalewska1

Description

@aniakowalewska1

Description
CodeQL security scan did not recognise the CWE-116 (Improper Encoding or Escaping of Output) in a Sitemap.xml.ts file when unescaped values are embedded into XML output.

Example
A sitemap is generated dynamically by interpolating application-derived values
into XML elements:

function generateSitemap(entries: string[]) {
  return `<?xml version="1.0" encoding="UTF-8"?>
<urlset>
  ${entries.map(path => `
    <url>
      <loc>${BASE_URL}/${path}</loc>
    </url>
  `).join("")}
</urlset>`;
}

Values here are embedded directly into XML elements without escaping.

Question
I would like to understand whether this pattern is currently not covered by the JavaScript/TypeScript analysis, or whether the scanning logic intentionally determines that this does not constitute a CWE-116 weakness when generating XML output such as a sitemap.

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions