javascript.playwright.security.audit.playwright-setcontent-injection.playwright-setcontent-injection
semgrep
Author
3,078
Download Count*
License
If unverified user data can reach the setContent
method it can result in Server-Side Request Forgery vulnerabilities
Run Locally
Run in CI
Defintion
rules:
- id: playwright-setcontent-injection
message: If unverified user data can reach the `setContent` method it can result
in Server-Side Request Forgery vulnerabilities
metadata:
owasp:
- A10:2021 - Server-Side Request Forgery (SSRF)
cwe:
- "CWE-918: Server-Side Request Forgery (SSRF)"
category: security
technology:
- playwright
cwe2022-top25: true
cwe2021-top25: true
subcategory:
- audit
likelihood: LOW
impact: LOW
confidence: LOW
references:
- https://owasp.org/Top10/A10_2021-Server-Side_Request_Forgery_%28SSRF%29
license: Commons Clause License Condition v1.0[LGPL-2.1-only]
vulnerability_class:
- Server-Side Request Forgery (SSRF)
languages:
- javascript
- typescript
severity: WARNING
patterns:
- pattern-inside: |
require('playwright');
...
- pattern-not-inside: |
require('playwright');
...
var $INPUT = "...";
...
$PAGE.setContent($INPUT,...)
- pattern: $PAGE.setContent($INPUT,...)
- pattern-not: $PAGE.setContent("...",...)
Examples
playwright-setcontent-injection.js
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
// ok
await page.setContent('<html></html>');
// ruleid:playwright-setcontent-injection
await page.setContent(unverifiedInput());
await page.screenshot({path: 'example.png'});
await browser.close();
})();
Short Link: https://sg.run/8yEQ