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

There's a code injection vulnerability of us.codecraft.webmagic.downloader.PhantomJSDownloader #1122

Open
LetianYuan opened this issue Jul 19, 2023 · 0 comments

Comments

@LetianYuan
Copy link

Affected Version
The latest version 0.9.0 and below.

Describe the vulnerability
there is a method, us.codecraft.webmagic.downloader.PhantomJSDownloader.download(Request, Task), designed to download a page from a request. However, passing an unchecked argument to PhantomJSDownloader constructor can lead to the execution of arbitrary commands. For instance, on Windows, new PhantomJSDownloader("cmd /c "for /l %i in (1, 1, 10) do calc"", "") would open ten calculators.

PhantomJSDownloader downloader = new PhantomJSDownloader("cmd /c \"for /l %i in (1, 1, 10) do calc\"", "");
Request request = new Request();
downloader.download(request, null);

To Reproduce
Just execute above codes would reproduce it.

Fix Suggestion
First, I strongly recommend that you can simply remove PhantomJSDownloader.java and all codes related to it in the project, because PhantomJS is no longer maintained 5 years ago, namely since Mar 4, 2018 (See ariya/phantomjs#15344). Or, you can check parameter phantomJsCommand strictly. For example, you can write codes to check whether phantomJsCommand is a phantomjs executable.

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