Skip to content

Denial of Service using xpcall()

High
asiekierka published GHSA-54j4-xpgj-cq4g Apr 16, 2024

Package

OpenComputers (Minecraft Mod)

Affected versions

<= 1.8.3

Patched versions

1.8.4

Description

Summary

A user can use OpenComputers to get a Computer thread stuck in the Lua VM, which eventually blocks the Server thread, requiring the server to be forcibly shut down. This can be accomplished using any device in the mod and can be performed by anyone who can execute Lua code on them.

This occurs while using the native Lua library. LuaJ appears to not have this issue using the test function below, which instead causes the offending program/code to exit silently and not exhibit the same effect.

Details

By making endlessly recursive calls to xpcall, the built-in timeout mechanism provided by machine.lua fails to escape the offending Lua function under certain conditions. The xpcall function within the sandbox provided by machine.lua does not sufficiently protect against the message handler function causing additional timeout errors. Even errors caused by infinite recursion such as stack overflows and out of memory errors are still caught by nested xpcalls.

As the Lua VM never yields, the Computer thread running the offending program never releases a lock on the running Machine object. When the Server thread attempts to save the state of the computer, it blocks on acquiring the lock currently held by the Computer thread. The Server thread never acquires the lock and blocks indefinitely, preventing the server from continuing to function and causing data loss up to the most recent server save.

override def save(nbt: NBTTagCompound): Unit = Machine.this.synchronized(state.synchronized {

The state of the machine is never saved and will not be running when the server restarts, so a server can recover by simply restarting the server. It is still possible for other machines to restart the offending machine to then trigger the effect again on server load.

Impact

Causes a Denial of Service against servers running OpenComputers using the native Lua library.

Patches

  • OpenComputers mod releases starting from version 1.8.4 are not vulnerable.
  • The GregTech: New Horizons modpack uses its own modified version of OpenComputers. They have applied the relevant patch in version 1.10.10-GTNH.

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 v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
None
Integrity
None
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:N/I:N/A:H

CVE ID

CVE-2024-31446

Weaknesses

Credits