Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This library is creating temporary files and loading them up with file:/// protocol scheme https://github.com/spatie/browsershot/blob/4148f910735cf385070cb1a6ff1ac26a37eefd10/src/Browsershot.php#L707 when 'Browsershot::html' function is used. Using a file protocol scheme along with headless browser such as Chrome on a server side is not a good idea and will lead to Local file disclosure (Security Vulnerability). Other local files present on the server could be loaded when a malicious HTML is provided. Local files can be loaded either with <iframe> (e.g. <iframe src="file:///etc/passwd" width= height=>) or by setting the different document location. Also, it is unlikely for the developers to check each and every page for malicious JavaScript inputs. This vulnerability can be verified by using below snippet
I see it can be fixed either in the PHP code or in the JS code. I believe this small JS snippet can be added at https://github.com/dr4gonw4ll/browsershot/blob/4148f910735cf385070cb1a6ff1ac26a37eefd10/bin/browser.js#L171 to make it secure. Below code can be added to library which validates the file protocol scheme and use the 'page.setContent' puppeteer function which loads in 'about:blank' page and does not cause any harm even if malicious JavaScript inputs are provided.
I am not sure about the performance impact this additional code will create. Let me know your comments