Skip to content

Avoid shell=True string-formatted subprocess call in update_docs #2691

Description

@nessita

update_docs's translation-build step runs a shell command built via %-string-formatting into subprocess.check_call(..., shell=True):

docs/management/commands/update_docs.py:

subprocess.check_call(
    "cd %s && make translations" % trans_dir, shell=True, **extra_kwargs
)

trans_dir is derived from release.version, and Release.version is a plain CharField with no format validator, so nothing at the model/admin layer restricts its contents.

It isn't exploitable in practice: only trusted release-manager staff can set Release.version, and that same group already has direct server/deploy access to the docs-build host, so there's no privilege boundary being crossed. Not treated as a security issue, but worth fixing as routine hardening, shell=True with string-formatted input is bad practice regardless of who can reach it.

Fix should be along the lines of: subprocess.check_call(["make", "translations"], cwd=trans_dir, **extra_kwargs)

Metadata

Metadata

Assignees

Labels

bugBroken functionality or unexpected behavior

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions