Am I affected?

type your gleam.run/gleam version to check

Description

Path traversal vulnerability in Gleam's handling of custom documentation pages allows arbitrary file read and file write outside the intended documentation output directory.

The documentation.pages entries from gleam.toml are incorporated into filesystem paths without sufficient validation or confinement to the intended project and documentation output directories. The documentation.pages[].path field can be used to write generated documentation files outside the intended build/dev/docs/<package>/ output directory. The documentation.pages[].source field can be used to read files outside the project directory and embed their contents into generated documentation output.

An attacker who can convince a victim to run gleam docs build on an untrusted project, or with untrusted gleam.toml content, can cause local files readable by the victim to be included in generated documentation artifacts, and can cause generated documentation files to be written outside the intended docs output directory.

This issue affects Gleam from 1.16.0 until 1.17.0.

Weaknesses & attack patterns

Weakness

CWE-22 · Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal') in catalog → MITRE ↗

Attack patterns

CAPEC-139 · Relative Path Traversal MITRE ↗
CAPEC-597 · Absolute Path Traversal MITRE ↗

Affected — Gleam

1.16.0 < 1.17.0 affected
every other version: unaffected
cpe cpe:2.3:a:gleam-lang:gleam:*:*:*:*:*:*:*:*
modules · source files · routines
modules compiler-core · compiler-cli
source files compiler-core/src/config.rs · compiler-core/src/docs.rs · compiler-cli/src/docs.rs · compiler-cli/src/fs.rs
routines compiler_cli::docs::build_project · compiler_core::docs::generate_html

Affected — GitHub / gleam-lang/gleam Repository ↗

1.16.0 < 1.17.0 affected
61ed8de < 8157061 affected
every other version: unaffected
cpe cpe:2.3:a:gleam-lang:gleam:*:*:*:*:*:*:*:*
modules · source files · routines
modules compiler-core · compiler-cli
source files compiler-core/src/config.rs · compiler-core/src/docs.rs · compiler-cli/src/docs.rs · compiler-cli/src/fs.rs
routines compiler_cli::docs::build_project · compiler_core::docs::generate_html

Affected — ghcr.io / gleam-lang/gleam Container registry ↗

v1.16.0-elixir < v1.17.0-elixir affected
v1.16.0-erlang < v1.17.0-erlang affected
v1.16.0-node < v1.17.0-node affected
v1.16.0-node-slim < v1.17.0-node-slim affected
v1.16.0-elixir-slim < v1.17.0-elixir-slim affected
v1.16.0-erlang-slim < v1.17.0-erlang-slim affected
v1.16.0-erlang-alpine < v1.17.0-erlang-alpine affected
v1.16.0-elixir-alpine < v1.17.0-elixir-alpine affected
v1.16.0-node-alpine < v1.17.0-node-alpine affected
v1.16.0-scratch < v1.17.0-scratch affected
every other version: unaffected
cpe cpe:2.3:a:gleam-lang:gleam:*:*:*:*:*:*:*:*
modules · source files · routines
modules compiler-core · compiler-cli
source files compiler-core/src/config.rs · compiler-core/src/docs.rs · compiler-cli/src/docs.rs · compiler-cli/src/fs.rs
routines compiler_cli::docs::build_project · compiler_core::docs::generate_html

Workarounds

  • Avoid running gleam docs build on untrusted projects
  • Review documentation.pages entries in gleam.toml before generating documentation
  • Run documentation generation in a restricted or isolated environment (e.g. containers)

Configurations

The project must use custom documentation pages via documentation.pages in gleam.toml, and the victim must run gleam docs build on an untrusted project or with untrusted gleam.toml content. Projects that do not use custom documentation pages are not affected.

References

Credits

evipepota Finder Remediation developer
Louis Pilfold Remediation reviewer
Jonatan Männchen / EEF Analyst

CVSS breakdown

CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N
« All CVEs