# CVE-2024-28121: Reflex arbitrary method call in stimulus_reflex

> Attackers can invoke unintended methods on Reflex instances via websockets, potentially leading to code execution or privilege escalation in Rails applications.

- **Severity:** High 8.8 (`CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 12 Mar 2024
- **Updated:** 13 Feb 2025
- **Also known as:** GHSA-f78j-4w3g-4q65

## What is CVE-2024-28121?

CVE-2024-28121 is a high-severity code injection vulnerability in stimulusreflex stimulus_reflex, published on 12 Mar 2024. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

stimulus_reflex is a system to extend the capabilities of both Rails and Stimulus by intercepting user interactions and passing them to Rails over real-time websockets. In affected versions more methods than expected can be called on reflex instances. Being able to call some of them has security implications. To invoke a reflex a websocket message of the following shape is sent: `\"target\":\"[class_name]#[method_name]\",\"args\":[]`. The server will proceed to instantiate `reflex` using the provided `class_name` as long as it extends `StimulusReflex::Reflex`. It then attempts to call `method_name` on the instance with the provided arguments. This is problematic as `reflex.method method_name` can be more methods that those explicitly specified by the developer in their reflex class. A good example is the instance_variable_set method. This vulnerability has been patched in versions 3.4.2 and 3.5.0.rc4. Users unable to upgrade should: see the backing GHSA advisory for mitigation advice.

Weakness: CWE-470 (Use of Externally-Controlled Input to Select Classes or Code)

## Which versions are affected by CVE-2024-28121?

8 open source packages ship an affected version, including stimulus_reflex. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `stimulus_reflex` | RubyGems | All versions | 3.4.2 |
| `stimulus_reflex` | RubyGems | All versions | 3.4.2 |
| `stimulus_reflex` | RubyGems | From 3.5.0.pre0 | 3.5.0.rc4 |
| `stimulus_reflex` | RubyGems | From 3.5.0.pre0 | 3.5.0.rc4 |
| `stimulus_reflex` | npm | All versions | 3.4.2 |
| `stimulus_reflex` | npm | All versions | 3.4.2 |
| `stimulus_reflex` | npm | From 3.5.0-pre0 | 3.5.0-rc4 |
| `stimulus_reflex` | npm | From 3.5.0-pre0 | 3.5.0-rc4 |

Products: Stimulusreflex Stimulusrelfex.

## How do I fix CVE-2024-28121?

Upgrade stimulus_reflex to a fixed version for your release line: 3.4.2, 3.5.0.rc4 or 3.5.0-rc4.

## Is CVE-2024-28121 being exploited?

There is no known exploitation of CVE-2024-28121 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2024-28121 and fix it if it is affected.

What it is: CVE-2024-28121 is a high-severity code injection vulnerability in stimulusreflex stimulus_reflex, published on 12 Mar 2024. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2024-28121 in the wild and no public exploit code.

Affected packages and fixed versions:
- stimulus_reflex (RubyGems): affected all versions; fixed in 3.4.2
- stimulus_reflex (RubyGems): affected all versions; fixed in 3.4.2
- stimulus_reflex (RubyGems): affected from 3.5.0.pre0; fixed in 3.5.0.rc4
- stimulus_reflex (RubyGems): affected from 3.5.0.pre0; fixed in 3.5.0.rc4
- stimulus_reflex (npm): affected all versions; fixed in 3.4.2
- stimulus_reflex (npm): affected all versions; fixed in 3.4.2
- stimulus_reflex (npm): affected from 3.5.0-pre0; fixed in 3.5.0-rc4
- stimulus_reflex (npm): affected from 3.5.0-pre0; fixed in 3.5.0-rc4

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2024-28121/ (Markdown: https://insights.sbomify.com/CVE-2024-28121/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2024-28121
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2024-28121
- OSV: https://osv.dev/vulnerability/CVE-2024-28121

---
From sbomify Insights: https://insights.sbomify.com/CVE-2024-28121/
Summaries are generated and may contain mistakes; the official description above is the record.
