|3 via 8 paths|
Find, fix and prevent vulnerabilities in your code.
- Vulnerable module: ajv
- Introduced through: firstname.lastname@example.org and email@example.com
Introduced through: firstname.lastname@example.org › email@example.com › firstname.lastname@example.org › email@example.com
Introduced through: firstname.lastname@example.org › email@example.com › firstname.lastname@example.org › email@example.com
ajv is an Another JSON Schema Validator
Affected versions of this package are vulnerable to Prototype Pollution. A carefully crafted JSON schema could be provided that allows execution of other code by prototype pollution. (While untrusted schemas are recommended against, the worst case of an untrusted schema should be a denial of service, not execution of code.)
There are two main ways in which the pollution of prototypes occurs:
- Property definition by path
Unsafe Object recursive merge
The logic of a vulnerable recursive merge function follows the following high-level model:
merge (target, source) foreach property of source if property exists and is an object on both the target and the source merge(target[property], source[property]) else target[property] = source[property]
When the source object contains a property named
_proto_ defined with
Object.defineProperty() , the condition that checks if the property exists and is an object on both the target and the source passes and the merge recurses with the target, being the prototype of
Object and the source of
Object as defined by the attacker. Properties are then copied on the
Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object:
Hoek are examples of libraries susceptible to recursive merge attacks.
Property definition by path
theFunction(object, path, value)
If the attacker can control the value of “path”, they can set this value to
myValue is then assigned to the prototype of the class of the object.
Types of attacks
There are a few methods by which Prototype Pollution can be manipulated:
|Denial of service (DoS)||Client||This is the most likely attack.
DoS occurs when
The attacker pollutes
For example: if an attacker pollutes
|Remote Code Execution||Client||Remote code execution is generally only possible in cases where the codebase evaluates a specific attribute of an object, and then executes that evaluation.
|Property Injection||Client||The attacker pollutes properties that the codebase relies on for their informative value, including security properties such as cookies or tokens.
For example: if a codebase checks privileges for
The following environments are susceptible to a Prototype Pollution attack:
- Application server
- Web server
How to prevent
- Freeze the prototype— use
- Require schema validation of JSON input.
- Avoid using unsafe recursive merge functions.
- Consider using objects without prototypes (for example,
Object.create(null)), breaking the prototype chain and preventing pollution.
- As a best practice use
For more information on this vulnerability type:
ajv to version 6.12.3 or higher.
- Vulnerable module: graphql-playground-html
- Introduced through: firstname.lastname@example.org
Introduced through: email@example.comRemediation: Upgrade to firstname.lastname@example.org.
graphql-playground-html is a GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).
Affected versions of this package are vulnerable to Cross-site Scripting (XSS) via the
A cross-site scripting attack occurs when the attacker tricks a legitimate web-based application or site to accept a request as originating from a trusted source.
Injecting malicious code is the most prevalent manner by which XSS is exploited; for this reason, escaping characters in order to prevent this manipulation is the top method for securing code against this vulnerability.
Escaping means that the application is coded to mark key characters, and particularly key characters included in user input, to prevent those characters from being interpreted in a dangerous context. For example, in HTML,
< can be coded as
> can be coded as
> in order to be interpreted and displayed as themselves in text, while within the code itself, they are used for HTML tags. If malicious content is injected into an application that escapes special characters and that malicious content uses
> as HTML tags, those characters are nonetheless not interpreted as HTML tags by the browser if they’ve been correctly escaped in the application code and in this way the attempted attack is diverted.
The most prominent use of XSS is to steal cookies (source: OWASP HttpOnly) and hijack user sessions, but XSS exploits have been used to expose sensitive information, enable access to privileged services and functionality and deliver malware.
Types of attacks
There are a few methods by which XSS can be manipulated:
|Stored||Server||The malicious code is inserted in the application (usually as a link) by the attacker. The code is activated every time a user clicks the link.|
|Reflected||Server||The attacker delivers a malicious link externally from the vulnerable web site application to a user. When clicked, malicious code is sent to the vulnerable web site, which reflects the attack back to the user’s browser.|
|DOM-based||Client||The attacker forces the user’s browser to render a malicious page. The data in the page itself delivers the cross-site scripting data.|
|Mutated||The attacker injects code that appears safe, but is then rewritten and modified by the browser, while parsing the markup. An example is rebalancing unclosed quotation marks or even adding quotation marks to unquoted parameters.|
The following environments are susceptible to an XSS attack:
- Web servers
- Application servers
- Web application environments
How to prevent
This section describes the top best practices designed to specifically protect your code:
- Sanitize data input in an HTTP request before reflecting it back, ensuring all data is validated, filtered or escaped before echoing anything back to the user, such as the values of query parameters during searches.
- Convert special characters such as
>and spaces to their respective HTML or URL encoded equivalents.
- Give users the option to disable client-side scripts.
- Redirect invalid requests.
- Detect simultaneous logins, including those from two separate IP addresses, and invalidate those sessions.
- Use and enforce a Content Security Policy (source: Wikipedia) to disable any features that might be manipulated for an XSS attack.
- Read the documentation for any of the libraries referenced in your code to understand which elements allow for embedded HTML.
graphql-playground-html to version 1.6.22 or higher.
- Vulnerable module: node-fetch
- Introduced through: email@example.com, firstname.lastname@example.org and others
Introduced through: email@example.com › firstname.lastname@example.org › email@example.com › firstname.lastname@example.org › email@example.comRemediation: Upgrade to firstname.lastname@example.org.
Introduced through: email@example.com › firstname.lastname@example.org › email@example.com › firstname.lastname@example.org › email@example.com › firstname.lastname@example.org
Introduced through: email@example.com › firstname.lastname@example.org › email@example.com › firstname.lastname@example.org › email@example.com › firstname.lastname@example.org
Introduced through: email@example.com › firstname.lastname@example.org › email@example.com › firstname.lastname@example.org › email@example.com
Introduced through: firstname.lastname@example.org › email@example.com › firstname.lastname@example.org › email@example.com › firstname.lastname@example.org
node-fetch is an A light-weight module that brings window.fetch to node.js
Affected versions of this package are vulnerable to Denial of Service. Node Fetch did not honor the
size option after following a redirect, which means that when a content size was over the limit, a FetchError would never get thrown and the process would end without failure.
node-fetch to version 2.6.1, 3.0.0-beta.9 or higher.