Skip to main content
Menu
Advisories

Remote code execution via unallowlisted markdown extension names in TechDocs Zensical builds

GHSA-232C-9PXF-2GP6Published Updated GitHub

Description

The sanitizeMkdocsYml function in @backstage/plugin-techdocs-node enforces a name allowlist for MkDocs plugins, but for markdown_extensions it only removed colon-form configuration entries and passed plain extension names through without checking them against an allowlist. The Zensical build image (ghcr.io/backstage/techdocs-zensical) ships extensions that load code or files during documentation generation, including zensical.extensions.macros, which executes a main.py file from the documentation input directory.

Details

When the experimental Zensical engine (@backstage/plugin-techdocs-backend-module-zensical) is enabled for an entity — via the backstage.io/techdocs-engine annotation or techdocs.generator.defaultEngine — a mkdocs.yml that lists such an extension under markdown_extensions passes sanitization unchanged. During the build, the extension executes attacker-supplied Python code from the documentation input directory as root inside the build container. The build completes normally and the execution is not visible in the build output.

This requires the attacker to be able to supply the mkdocs.yml for a TechDocs-enabled entity, for example by registering a catalog entity or committing documentation changes. The Zensical engine is opt-in and experimental; deployments that have not enabled it are not affected through this path.

This is the same boundary as previously addressed in GHSA-6jr7-99pf-8vgf, GHSA-928r-fm4v-mvrw, and GHSA-4488-j8vj-vqqv; those fixes closed plugin names and extension configuration forms, while plain extension names were not checked against an allowlist.

Impact

An authenticated user who can supply a mkdocs.yml for an entity built with the Zensical engine can achieve arbitrary code execution in the TechDocs build container, with access to data and credentials reachable from the build environment.

Provisional CVSS 3.1 score: 7.7 (AV:N/AC:H/PR:L/UI:N/S:C/C:H/I:L/A:L).

Patches

Patched in @backstage/plugin-techdocs-node 2.2.1 and @backstage/plugin-techdocs-backend-module-zensical 0.1.1 (both provisional until published). Only extension names on a known-safe allowlist are kept in markdown_extensions during sanitization, for both the MkDocs and Zensical engines. The standard Python-Markdown built-in extensions, the pymdownx.* family, and the rendering extensions shipped in the official build images are allowed. Additional extensions, for example for custom build images, can be allowed with the new techdocs.generator.mkdocs.dangerouslyAllowAdditionalExtensions configuration, or the --dangerouslyAllowAdditionalExtensions flag when using the TechDocs CLI.

Workarounds

  • Disable the Zensical engine for entities (remove the backstage.io/techdocs-engine: zensical annotation and do not set techdocs.generator.defaultEngine: zensical), or do not install @backstage/plugin-techdocs-backend-module-zensical.
  • Restrict who can register catalog entities with TechDocs annotations or commit documentation changes.
  • Audit existing repositories' mkdocs.yml files for unallowlisted markdown_extensions entries, in particular zensical.extensions.macros.

References

  • GHSA-6jr7-99pf-8vgf
  • GHSA-928r-fm4v-mvrw
  • GHSA-4488-j8vj-vqqv

Affected versions

References

GitHub · backstage/backstage