Skip to content

Conversation

@Alhadis
Copy link
Contributor

@Alhadis Alhadis commented May 7, 2020

The PATH and CHROME_PATH variables are currently being used verbatim for constructing a regular expression:

{regex: new RegExp(`^${process.env.HOME}/Applications/.*Chrome.app`), weight: 50},
{regex: new RegExp(`^${process.env.HOME}/Applications/.*Chrome Canary.app`), weight: 51},

This can lead to confusing behaviour if a user's path contains RegExp metacharacters such as $ or ^. Worse still, it leaves room for a malicious actor to inject an expression guaranteed to send the process into performance hell:

export CHROME_PATH='(.*.*.*.*.*.*.*.*.*.*.*.*)*[^Bb]|$'

I also replaced stuff like `${process.env.PATH}` with simply process.env.PATH, because the former syntax will stringify an undefined value as "undefined", which probably isn't what you want (or expect).

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks very much, nice catch @Alhadis! 👍

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @Alhadis! 🎉

@patrickhulce patrickhulce merged commit 2ae5591 into GoogleChrome:master May 7, 2020
@Alhadis Alhadis deleted the finder-fixes branch May 7, 2020 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants