Skip to content

Tidy up: prevent path traversal via schema ID in the JTD-to-ESM CLI (JtdToEsmCli.java) #201

Open

Description

@simbo1905

Sub-issue 22 of 26 from the 2026-11-21 bot-review-comment audit. Parent issue: #179 (Bot review comment tidy up).
Audited origin/main HEAD: 2e5cf37. Audit date: 2026-11-21.

== Finding 22 (verbatim from the audit findings file) ==

  1. PR Port jtd-esm-codegen onto the incubator main #169 — CLI can write generated validators outside the requested output directory.
    Author: chatgpt-codex-connector[bot], 2026-08-31. Comment: Port jtd-esm-codegen onto the incubator main #169 (comment)
    Source: jtd-esm-codegen/src/main/java/io/github/simbo1905/json/jtd/codegen/JtdToEsmCli.java:50. Current: jtd-esm-codegen/src/main/java/io/github/simbo1905/json/jtd/codegen/JtdToEsmCli.java:49-51 (outDir.resolve(schema.id() + "-" + shaPrefix8 + ".js") then Files.writeString, no sanitization or containment check).
    Flagged: "When metadata.id begins with / or contains ../, outDir.resolve(fileName) can resolve outside the requested output directory, and the subsequent Files.writeString truncates an existing file at that location... restrict the ID to a safe filename component and verify the normalized result remains under outDir".
    Still applies: unchanged; untrusted schema IDs can overwrite arbitrary process-writable files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions