Skip to content

[Security] validateOutputPath symlink bypass — screenshots/PDFs can write outside safe dirs #665

Closed

Description

@wernerkasselman-au

Summary

validateOutputPath() in browse/src/meta-commands.ts:20 uses path.resolve() but never fs.realpathSync() to resolve symlinks. Unlike validateReadPath() (fixed in #595), a symlink placed under /tmp or cwd can redirect screenshot/PDF/responsive writes to arbitrary files.

Reproduction

ln -s /etc/crontab /tmp/evil.png
$B screenshot /tmp/evil.png   # overwrites /etc/crontab

Root cause

validateReadPath was hardened with realpathSync in #595 (security audit remediation), but validateOutputPath was missed. The two functions have identical intent but divergent implementations.

Fix

PR #664 adds realpathSync to validateOutputPath, matching the validateReadPath pattern including symlink resolution on safe directories themselves (macOS /tmp → /private/tmp).

Found via sqry AST-based semantic code graph analysis.

Activity

  1. added a commit that references this issue on Apr 1, 2026
    0061985
  2. garrytan commented on Apr 13, 2026

    @garrytan
    Owner

    Fixed in commits 1351cf7d + 73f5d0b7 (path-security.ts refactor). validateOutputPath now uses realpathSync on the parent directory. Additional file-level symlink check coming in the next security wave.

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