Skip to content

[Bug] checkpoint-manager.ts path traversal - writes outside workspace #1148

Description

@akramcodez

Description

Snapshot files are written at path.join(checkpointDir, relativePath) without checking if relativePath escapes the workspace (e.g., if a model wrote an absolute path or a path containing ..). The snapshot read could thus write outside the checkpoints directory.

Environment

  • OS: Any
  • Node version: v22.20.0
  • Nanocoder version: 1.30.0
  • Provider: N/A
  • Model: N/A

Steps to Reproduce

  1. Modify metadata.filesChanged or trick the model into creating a path containing ...
  2. Trigger the checkpoint manager to save.

Expected Behavior

The path should be strictly validated and normalized to ensure it stays within the intended directory sandbox.

Actual Behavior

A path traversal vulnerability exists, allowing files to be written out of bounds.

Additional Context

  • I have searched existing issues to ensure this is not a duplicate
  • I can reproduce this issue consistently
  • This issue occurs with the latest version of nanocoder

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions