[Informational] Code logic contains potential risk of full network shutdown
The report claims that object handlers in shardus-core use array access on route names without validating that the property is an own property, so a route name like 'defineGetter' could invoke a prototype method and overwrite values. The author says this could lead to a full network shutdown if the handler were written in a slightly different but equivalent way.
Originally disclosed on Immunefi
- Disclosed after under an hour
#35697 [BC-Insight] [Informational] Code logic contains potential risk of full network shutdown
Submitted on Oct 3rd 2024 at 19:27:36 UTC by @Merkle_Bonsai for Audit Comp | Shardeum: Core II
- Report ID: #35697
- Report Type: Blockchain/DLT
- Report severity: Insight
- Target: https://github.com/shardeum/shardus-core/tree/dev
- Impacts:
- informational: potential risk
Description
Immunefi guys, please, just pass it to the project. I'm OK if it will be lowered to informational with no reward. We already discussed it in #35415, and Mehdi personally told to report such things anyway for that project. https://discord.com/channels/787092485969150012/1256211020482084987/1286726883530117230
Vulnerability Details
Object handlers contain prototype values that have various risks, including non-standard properties like `defineGetter` and `defineSetter`. Properties that are not validated explicitly should not be processed with array access.
For example, one of most important handlers of shardus-core is simply lucky to be written in specific way: ``` const { route, payload } = data ... const handler = this.internalRoutes[route] if (!payload) { await handler(null, respond, header, sign) return } await handler(payload, respond, header, sign) ```
If it would be written like this (which looks legitimate and totally same), it would be presenting the vector for total network shutdown: ``` const { route, payload } = data ... await this.internalRoutes[route](payload ?? null, respond, header, sign) if (!payload) { return } ```
However, that would allow attacker to pass following data: ``` { route: "defineGetter", payload: "binary/gossip" } ```
that will be handled like this: ``` await this.internalRoutes["defineGetter"]("binary/gossip", respond, header, sign) ```
causing the value to be overwritten
Impact Details
Impact may vary, depending on location of that issue. It is better to either check if property is own (not from proto) or use ES6 Map structures for that cases.
Proof of Concept
Proof of Concept
``` routes = {gossip: () => 'hello'} // => {gossip: ƒ} routes.defineGetter('gossip', () => 'mocked') routes.gossip // => 'mocked' ```
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
The report claims a potential full network shutdown, but only if the handler were written in a different way; the current code is described as 'simply lucky' and the impact is informational.
What the attacker needed
Attacker can send crafted route data; handler written with direct bracket call
The fix
The report suggests checking that the property is an own property or using ES6 Map structures instead of plain objects.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
In JavaScript, every object inherits special properties from its prototype, such as 'defineGetter'. If code looks up a route name in an object without checking that the name belongs to the object itself, an attacker can supply a prototype property name instead of a real route. The report argues this could let an attacker call unintended functions and potentially disrupt the whole network.
What is Prototype pollution?
Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.