Vulnerabilities

18 via 18 paths

Dependencies

172

Source

GitHub

Find, fix and prevent vulnerabilities in your code.

Severity
  • 13
  • 5
Status
  • 18
  • 0
  • 0

high severity
new

Insufficiently Protected Credentials

  • Vulnerable module: @modelcontextprotocol/sdk
  • Introduced through: @modelcontextprotocol/sdk@1.29.0

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › @modelcontextprotocol/sdk@1.29.0
    Remediation: Upgrade to @modelcontextprotocol/sdk@1.31.0.

Overview

@modelcontextprotocol/sdk is a Model Context Protocol implementation for TypeScript

Affected versions of this package are vulnerable to Insufficiently Protected Credentials via the fetchToken and discardIfIssuerMismatch functions in the OAuth client authentication flow, where the SEP-2352 issuer check is not applied consistently. An attacker controlling a malicious authorization server can cause the client to send OAuth client credentials (client information) to an unintended server, because the issuer stamp on stored credentials is not validated before the token request is dispatched. This allows an attacker to harvest client credentials by redirecting token requests to a server whose issuer does not match the one the credentials were originally registered with.

Remediation

Upgrade @modelcontextprotocol/sdk to version 1.31.0 or higher.

References

high severity

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: js-yaml
  • Introduced through: js-yaml@4.2.0

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › js-yaml@4.2.0
    Remediation: Upgrade to js-yaml@4.3.2.

Overview

js-yaml is a human-friendly data serialization language.

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling in the merge key (<<) handling of the loader, where the maxTotalMergeKeys budget does not count empty mappings against its limit. An attacker can consume significant CPU, on the order of O(N*K) for N empty mappings merged K times, with a relatively small document by repeatedly merging a large sequence of empty mappings so the budget counter never increments.

Note: This requires YAML merge processing to be enabled for untrusted YAML, which is the default behavior in versions 3 and 4, but is not the default in version 5.

Remediation

Upgrade js-yaml to version 3.15.2, 4.3.2 or higher.

References

high severity

Inefficient Algorithmic Complexity

  • Vulnerable module: js-yaml
  • Introduced through: js-yaml@4.2.0

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › js-yaml@4.2.0
    Remediation: Upgrade to js-yaml@4.3.0.

Overview

js-yaml is a human-friendly data serialization language.

Affected versions of this package are vulnerable to Inefficient Algorithmic Complexity in merge key (<<) handling during YAML parsing, where each mapping in a chain re-enumerates the keys inherited from the previous mapping. An attacker can exhaust CPU and cause denial of service by supplying a document with N chained merge mappings, which forces roughly O(N^2) work for O(N) input. Exploitation requires the application to parse untrusted YAML with the default or YAML11 schema, under which merge keys are resolved.

Remediation

Upgrade js-yaml to version 3.15.0, 4.3.0 or higher.

References

high severity

Inefficient Algorithmic Complexity

  • Vulnerable module: js-yaml
  • Introduced through: js-yaml@4.2.0

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › js-yaml@4.2.0
    Remediation: Upgrade to js-yaml@4.3.1.

Overview

js-yaml is a human-friendly data serialization language.

Affected versions of this package are vulnerable to Inefficient Algorithmic Complexity through the yaml.load process. An attacker can cause excessive CPU consumption and block the event loop by providing a specially crafted YAML document containing a large !!omap sequence.

Remediation

Upgrade js-yaml to version 3.15.1, 4.3.1 or higher.

References

high severity
new

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: zod
  • Introduced through: zod@4.4.3

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › zod@4.4.3
    Remediation: Upgrade to zod@4.6.6.

Overview

zod is a TypeScript-first schema declaration and validation library with static type inference

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via the handleArrayResult parse logic in $ZodArray, which accumulates every validation issue for each failing element in a large array with no cap or early termination. An attacker can submit a large array to an application using an array schema without a length constraint, causing the process to allocate excessive issue objects and crash due to out-of-memory conditions.

Remediation

Upgrade zod to version 4.6.6 or higher.

References

high severity
new

Prototype Pollution

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Prototype Pollution via insufficient hardening of runtime option handling across multiple request-processing helpers (lib/helpers/resolveConfig.js, lib/helpers/toFormData.js, lib/adapters/fetch.js, and related files). An attacker can supply a manipulated configuration object that overrides internally owned fetch options (such as body, headers, method, signal) or bypasses the default formSerializer.maxDepth limit, leading to integrity violations in outgoing requests or a crash causing denial of service.

Note: This is only exploitable when the caller does not explicitly set formSerializer.maxDepth, allowing a prototype-level or caller-supplied value to override the expected default.

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • 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 Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. 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:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
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.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
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 someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Olivier. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade axios to version 0.34.0, 1.20.0 or higher.

References

high severity
new

Allocation of Resources Without Limits or Throttling

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Allocation of Resources Without Limits or Throttling via unsafe runtime option handling in the fetch and HTTP adapters, where user-supplied fetchOptions are merged into the resolved request options without sanitization. An attacker who can influence request configuration can trigger uncontrolled resource consumption, crashing the process.

Note: This is only exploitable when requests follow redirects (i.e., maxRedirects is not set to 0), unless application code manually follows the malicious redirect and re-enters axios.

Remediation

Upgrade axios to version 1.20.0 or higher.

References

high severity
new

Improper Validation of Specified Quantity in Input

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Improper Validation of Specified Quantity in Input via unsafe runtime option handling in the fetch and HTTP adapters, where user-supplied fetchOptions are merged into the resolved request options without sanitization or allowlist enforcement. An attacker who can influence request configuration can supply option values that override Axios-owned fields (such as signal, method, headers, or body) or inject unexpected fetch option keys, causing the request pipeline to crash and producing a denial of service.

Remediation

Upgrade axios to version 1.20.0 or higher.

References

high severity
new

Improper Validation of Specified Quantity in Input

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Improper Validation of Specified Quantity in Input via unsafe runtime option handling in the fetch and HTTP adapters, where user-supplied fetchOptions are merged into the resolved request options without sanitization or allowlist enforcement. An attacker who can influence request configuration can supply option values that override Axios-owned fields (such as signal, method, headers, or body) or inject unexpected fetch option keys, causing the request pipeline to crash and producing a denial of service.

Remediation

Upgrade axios to version 1.20.0 or higher.

References

high severity
new

Regular Expression Denial of Service (ReDoS)

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Regular Expression Denial of Service (ReDoS) via improper validation of runtime options in resolveConfig and related helpers, where an attacker-controlled or malformed configuration value can trigger a crash in the request processing pipeline. The hardening of option handling across fetch.js, http.js, dispatchRequest.js, and supporting helpers indicates that unsanitized option objects could be passed through to the underlying fetch or HTTP adapter in a way that causes an unhandled runtime error, crashing the process and denying service to other users.

Details

Denial of Service (DoS) describes a family of attacks, all aimed at making a system inaccessible to its original and legitimate users. There are many types of DoS attacks, ranging from trying to clog the network pipes to the system by generating a large volume of traffic from many machines (a Distributed Denial of Service - DDoS - attack) to sending crafted requests that cause a system to crash or take a disproportional amount of time to process.

The Regular expression Denial of Service (ReDoS) is a type of Denial of Service attack. Regular expressions are incredibly powerful, but they aren't very intuitive and can ultimately end up making it easy for attackers to take your site down.

Let’s take the following regular expression as an example:

regex = /A(B|C+)+D/

This regular expression accomplishes the following:

  • A The string must start with the letter 'A'
  • (B|C+)+ The string must then follow the letter A with either the letter 'B' or some number of occurrences of the letter 'C' (the + matches one or more times). The + at the end of this section states that we can look for one or more matches of this section.
  • D Finally, we ensure this section of the string ends with a 'D'

The expression would match inputs such as ABBD, ABCCCCD, ABCBCCCD and ACCCCCD

It most cases, it doesn't take very long for a regex engine to find a match:

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCD")'
0.04s user 0.01s system 95% cpu 0.052 total

$ time node -e '/A(B|C+)+D/.test("ACCCCCCCCCCCCCCCCCCCCCCCCCCCCX")'
1.79s user 0.02s system 99% cpu 1.812 total

The entire process of testing it against a 30 characters long string takes around ~52ms. But when given an invalid string, it takes nearly two seconds to complete the test, over ten times as long as it took to test a valid string. The dramatic difference is due to the way regular expressions get evaluated.

Most Regex engines will work very similarly (with minor differences). The engine will match the first possible way to accept the current character and proceed to the next one. If it then fails to match the next one, it will backtrack and see if there was another way to digest the previous character. If it goes too far down the rabbit hole only to find out the string doesn’t match in the end, and if many characters have multiple valid regex paths, the number of backtracking steps can become very large, resulting in what is known as catastrophic backtracking.

Let's look at how our expression runs into this problem, using a shorter string: "ACCCX". While it seems fairly straightforward, there are still four different ways that the engine could match those three C's:

  1. CCC
  2. CC+C
  3. C+CC
  4. C+C+C.

The engine has to try each of those combinations to see if any of them potentially match against the expression. When you combine that with the other steps the engine must take, we can use RegEx 101 debugger to see the engine has to take a total of 38 steps before it can determine the string doesn't match.

From there, the number of steps the engine must use to validate a string just continues to grow.

String Number of C's Number of steps
ACCCX 3 38
ACCCCX 4 71
ACCCCCX 5 136
ACCCCCCCCCCCCCCX 14 65,553

By the time the string includes 14 C's, the engine has to take over 65,000 steps just to see if the string is valid. These extreme situations can cause them to work very slowly (exponentially related to input size, as shown above), allowing an attacker to exploit this and can cause the service to excessively consume CPU, resulting in a Denial of Service.

Remediation

Upgrade axios to version 1.20.0 or higher.

References

high severity
new

Unintended Proxy or Intermediary ('Confused Deputy')

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Unintended Proxy or Intermediary ('Confused Deputy') via insufficient hardening of runtime option handling in the fetch and HTTP adapters (lib/adapters/fetch.js, lib/adapters/http.js, and related helpers). An authenticated attacker can supply malicious request options that are passed through without sanitization, allowing them to override Axios-controlled fetch properties such as body, headers, method, signal, duplex, and credentials, leading to a full compromise of request confidentiality and integrity.

Remediation

Upgrade axios to version 1.20.0 or higher.

References

high severity
new

Server-side Request Forgery (SSRF)

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Server-side Request Forgery (SSRF) via unsafe merging of user-supplied fetchOptions into the resolved request options object in lib/adapters/fetch.js. An attacker who controls request configuration can supply a fetchOptions object with prototype-polluting keys (e.g. __proto__ or constructor), which are spread directly into the options passed to the Fetch API without sanitization, allowing pollution of Object.prototype and affecting downstream system-level behaviour. The fix replaces the spread with Object.assign(Object.create(null), fetchOptions) to strip inherited properties and enforces an allowlist of safe Fetch API keys.

Note: This is only exploitable when the attacker can influence the fetchOptions configuration passed to axios requests.

Remediation

Upgrade axios to version 1.20.0 or higher.

References

high severity
new

Unintended Proxy or Intermediary ('Confused Deputy')

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Unintended Proxy or Intermediary ('Confused Deputy') via improper enforcement of maxRedirects: 0 in the fetch adapter, where user-supplied fetchOptions are merged into the resolved request options without defaulting the redirect field. When a caller sets maxRedirects: 0 to prevent redirects, the fetch adapter does not apply redirect: 'manual' unless the caller also explicitly sets fetchOptions.redirect, causing the underlying fetch runtime to silently follow a 302 redirect from the initial target and forward the request - including any credentials or sensitive headers - to the redirect destination, which may be attacker-controlled.

Note: This is only exploitable when requests are configured with maxRedirects: 0 but without fetchOptions.redirect: 'manual' or an equivalent runtime-specific redirect control.

Remediation

Upgrade axios to version 1.20.0 or higher.

References

medium severity
new

Improper Input Validation

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Improper Input Validation via insufficient hardening of runtime option handling in the fetch and HTTP adapters, where user-supplied fetchOptions are merged into the resolved request options without sanitization. An attacker who can influence request configuration can inject or override internal Axios-owned options (such as body, headers, method, signal, credentials), leading to integrity impact on the downstream system receiving the request.

Remediation

Upgrade axios to version 1.20.0 or higher.

References

medium severity
new

Improper Isolation or Compartmentalization

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Improper Isolation or Compartmentalization in lib/helpers/shouldBypassProxy.js, which matches NO_PROXY entries by exact host or IP and has no parsing for CIDR notation, so an entry such as 127.0.0.0/8 or 10.0.0.0/8 never matches and the request is routed through the configured proxy. An attacker able to observe or operate that proxy can read internal hostnames, request URLs, headers, and any credentials those requests carry, by receiving traffic the deployment intended to keep direct. This requires a Node.js deployment with HTTP_PROXY or HTTPS_PROXY set, at least one NO_PROXY entry written in CIDR form, and a proxy sitting outside the intended trust boundary, and exact host or IP entries in NO_PROXY are matched correctly.

Note: This is only exploitable when requests are configured with proxy: false.

Workaround

This vulnerability can be avoided by writing NO_PROXY entries for sensitive destinations as exact hosts or IP addresses rather than CIDR ranges.

Remediation

Upgrade axios to version 1.20.0 or higher.

References

medium severity
new

Prototype Pollution

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Prototype Pollution via unsafe merging of user-supplied fetchOptions in lib/adapters/fetch.js. When a caller passes a fetchOptions object, axios spreads it directly into the resolved request options without sanitizing prototype-inherited properties, allowing an attacker who controls request configuration to pollute Object.prototype and influence downstream system behavior such as request routing or security-sensitive option values.

Note: This is only exploitable when the attacker can influence the fetchOptions configuration object passed to axios requests.

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • 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 Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. 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:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
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.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
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 someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Olivier. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade axios to version 1.20.0 or higher.

References

medium severity
new

Prototype Pollution

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Prototype Pollution via insufficiently hardened runtime option handling in the fetch and HTTP adapters (lib/adapters/fetch.js, lib/adapters/http.js, and related helpers), where user-controlled or prototype-polluted properties on request configuration objects are merged into fetch/request options without sanitization. An attacker who can introduce a prototype-pollution gadget elsewhere in the application can inject arbitrary properties into the resolved fetch options, leading to integrity violations on outbound requests.

Note: This is only exploitable if an existing prototype-pollution path is present in the application.

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • 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 Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. 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:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
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.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
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 someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Olivier. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade axios to version 0.34.0, 1.20.0 or higher.

References

medium severity
new

Prototype Pollution

  • Vulnerable module: axios
  • Introduced through: axios@1.18.1

Detailed paths

  • Introduced through: kastell@kastelldev/kastell › axios@1.18.1
    Remediation: Upgrade to axios@1.20.0.

Overview

axios is a promise-based HTTP client for the browser and Node.js.

Affected versions of this package are vulnerable to Prototype Pollution via insufficient hardening of runtime option handling in the fetch and HTTP adapters (lib/adapters/fetch.js, lib/adapters/http.js, and related helpers). An attacker who can influence request configuration options passed to axios can supply unsanitized values that bypass expected constraints, resulting in unintended modification of downstream system behavior (SI:H) such as request routing or proxy bypass, while leaving the client-side response unaffected (VC:N, VI:N, VA:N).

Details

Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

  • Unsafe Object recursive merge

  • 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 Object prototype.

Clone operations are a special sub-class of unsafe recursive merges, which occur when a recursive merge is conducted on an empty object: merge({},source).

lodash and Hoek are examples of libraries susceptible to recursive merge attacks.

Property definition by path

There are a few JavaScript libraries that use an API to define property values on an object based on a given path. The function that is generally affected contains this signature: theFunction(object, path, value)

If the attacker can control the value of “path”, they can set this value to __proto__.myValue. 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:

Type Origin Short description
Denial of service (DoS) Client This is the most likely attack.
DoS occurs when Object holds generic functions that are implicitly called for various operations (for example, toString and valueOf).
The attacker pollutes Object.prototype.someattr and alters its state to an unexpected value such as Int or Object. In this case, the code fails and is likely to cause a denial of service.
For example: if an attacker pollutes Object.prototype.toString by defining it as an integer, if the codebase at any point was reliant on someobject.toString() it would fail.
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.
For example: eval(someobject.someattr). In this case, if the attacker pollutes Object.prototype.someattr they are likely to be able to leverage this in order to execute code.
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 someuser.isAdmin, then when the attacker pollutes Object.prototype.isAdmin and sets it to equal true, they can then achieve admin privileges.

Affected environments

The following environments are susceptible to a Prototype Pollution attack:

  • Application server

  • Web server

  • Web browser

How to prevent

  1. Freeze the prototype— use Object.freeze (Object.prototype).

  2. Require schema validation of JSON input.

  3. Avoid using unsafe recursive merge functions.

  4. Consider using objects without prototypes (for example, Object.create(null)), breaking the prototype chain and preventing pollution.

  5. As a best practice use Map instead of Object.

For more information on this vulnerability type:

Arteau, Olivier. “JavaScript prototype pollution attack in NodeJS application.” GitHub, 26 May 2018

Remediation

Upgrade axios to version 1.20.0 or higher.

References