Skip to content

Protect against maliciously crafted package.json / .npmrc #192906

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

Closed
chrmarti opened this issue Sep 12, 2023 · 4 comments
Closed

Protect against maliciously crafted package.json / .npmrc #192906

chrmarti opened this issue Sep 12, 2023 · 4 comments
Assignees
Labels
javascript JavaScript support issues security

Comments

@chrmarti
Copy link
Collaborator

chrmarti commented Sep 12, 2023

A remote code execution vulnerability exists in VS Code 1.82.0 and earlier versions that working in a maliciously crafted package.json can result in executing commands locally. This scenario would require the attacker to get the VS Code user to open the malicious project and have get the user to open and work with malformed entries in the dependencies sections of the package.json file.

VS Code uses the locally installed npm command to fetch information on package dependencies. A package dependency can be named in such a way that the npm tool runs a script instead.

Patches

The fix is available starting with VS Code 1.82.1. The fix (e7b3397) mitigates this attack by turning off the usage of npm in an untrusted workspace and by adding extra input validation when calling the npm command.

Workarounds

Do not work with the dependencies sections in the package.json file that originate from an untrusted source.

References

@chrmarti chrmarti added javascript JavaScript support issues security labels Sep 12, 2023
@chrmarti chrmarti added this to the August 2023 Recovery 1 milestone Sep 12, 2023
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this issue Sep 13, 2023
@AnrDaemon
Copy link

Can you please backport this fix to 1.70?

@tizu69
Copy link

tizu69 commented Sep 25, 2023

Can you please backport this fix to 1.70?

Can you please update your software to 1.82?

@AnrDaemon
Copy link

Can you please update your software to 1.82?

No.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
javascript JavaScript support issues security
Projects
None yet
Development

No branches or pull requests

5 participants
@aeschli @AnrDaemon @chrmarti @tizu69 and others