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

Semgrep rules javascript express vm2 misses real vuln. code #3350

Open
OrenGitHub opened this issue Apr 10, 2024 · 1 comment
Open

Semgrep rules javascript express vm2 misses real vuln. code #3350

OrenGitHub opened this issue Apr 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@OrenGitHub
Copy link

javascript express vm2 vulnerability scanner: here misses real vulnerable code.
The vulnerable file is here, and it is a part of completely reproducible docker image
vulnerable to CVE-2023-37466.

It seems that not all syntactic cases were handled.
Here is a minimal poc that demonstrates the cause:

$ diff original.js slightly_different_syntax.js
2c2
< const { VM } = require('vm2');
---
> const vm = require("vm2");
13c13
<   new VM({ timeout: 40 * 1000, sandbox }).run(code);
---
>   new vm.VM({ timeout: 40 * 1000, sandbox }).run(code);

when I run semgrep scan, only the original version is found, although
the slightly modified version is vulnerable too ...

$ semgrep --config=rules.yaml # <--- only 1 code finding ...
┌────────────────┐
│ 1 Code Finding │
└────────────────┘

    original.js
    ❯❱ express-vm2-injection
          Make sure that unverified user data can not reach `vm2`.

           13┆ new VM({ timeout: 40 * 1000, sandbox }).run(code);
@ievans ievans added the bug Something isn't working label Apr 10, 2024
@ievans ievans transferred this issue from semgrep/semgrep Apr 10, 2024
@ievans
Copy link
Member

ievans commented Apr 10, 2024

moved to semgrep-rules; @LewisArdern

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants