Skip to content

feat: add filename validation for windows #50

Closed

Description

The vue-inspector by @webfansplz contains code that prevents some filenames from being opened with a shell command

https://github.com/webfansplz/vite-plugin-vue-inspector/blob/main/src/launch-editor.ts#L336-L357

This is to prevent possible attacks where a crafted filename could be used to execute malicious commands.

Currently launch-editor does not have a check like this. It's hard to exploit because there is an fs.existsSync check but for defense in depth it would be better to not let these kinds of filenames through

The regex here https://github.com/webfansplz/vite-plugin-vue-inspector/blob/main/src/launch-editor.ts#L108-L112 looks longish, maybe a smaller list of forbidden chars does the trick too

Activity

  1. haoqunjiang commented on Oct 7, 2023

    @haoqunjiang
    Member

    These are basically backports of react/create-react-app#4866 and react/create-react-app#5431
    As Unicode character class escape has been supported since Node.js 101, I think we can use the uncompiled version here.

    The only remaining problem is that this RegExp can't be parsed with our current ESLint setup.
    I'll try to fix this issue when I have the time to move away from eslint-plugin-vue-libs and bump the ESLint major version in this repository.

    Footnotes

    1. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape ↩

  2. added
    enhancement
    on Jun 18, 2024
  3. haoqunjiang commented on Jul 15, 2024

    @haoqunjiang
    Member

    After reading https://stackoverflow.com/q/4094699/2302258, I believe it's not exploitable.
    Let me think this validation logic over. It might be better to escape than validate.

  4. oneezy commented on Aug 24, 2024

    @oneezy

    this should be re-opened. we're still getting issues on Win11

    Reference

    issue: sveltejs/vite-plugin-svelte#943 (comment)

  5. Loizzus commented on Oct 8, 2024

    @Loizzus

    Can confirm, issue has not been fixed at all for Svelte 4.
    image

    Also does not work at all in Svelte 5.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions