Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid ambiguous "extract a source map comment" algorithms #138

Open
nicolo-ribaudo opened this issue Oct 15, 2024 · 0 comments
Open

Avoid ambiguous "extract a source map comment" algorithms #138

nicolo-ribaudo opened this issue Oct 15, 2024 · 0 comments

Comments

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Oct 15, 2024

During the October 2024 TC39 plenary meeting, it was raised that providing multiple methods of extracting a source map comment that yield different results can cause a security/privacy problem.

This is because on some platforms it can be used as a way to track whether the user is trying to debug the code, or to grab the user's IP thanks to the devtool trying to fetch the source map fro a remote server. Users on those platforms that want to prevent this from happening can pre-scan their code to know if it contains a source map comment or not. However, having two methods of doing so that yield different results can cause these tools to miss some of the comments.

We still got approval from TC39 for submitting our final draft to Ecma, but it was conditional on us:

This issue is to track the solution. I propose that there can be two "success outcomes"

  1. the two algorithms are refined so that they always lead to the same result
  2. the regexp-based algorithm is refined so that it can find a subset of the comments found by the parsing-based algorithm, rather than being two sets that simply intersect.

From the discussion during plenary, we concluded that one of the first steps should be to early-exit from the regexp-based algorithm whenever there is a comment that contains one of `, ", ', */. This would avoid ambiguity in cases like

let a = `
//#sourceMapURL=...
//`

This solution is probably not complete though, and this issue is to keep track of it.

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

No branches or pull requests

1 participant