GitHub Advisoryadvisory · crates.io

GHSA-x57h-xx53-v53w stellar-xdr's StringM::from_str bypasses max length validation

MEDIUM Published 2026-03-05 Modified 2026-03-06 Official page ↗
Aliases
CVE-2026-29795
Ecosystem
crates.io
Packages
stellar-xdr
Severity
Moderate
CVSS vector
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N
Weaknesses
CWE-770
Reviewed
2026-03-05

Affected packages

• crates.io stellar-xdr: < 25.0.1 → fixed in 25.0.1

Description

Impact `StringM::from_str` does not validate that the input length is within the declared maximum (`MAX`). Calling `StringM::::from_str(s)` where `s` is longer than `N` bytes succeeds and returns an `Ok` value instead of `Err(Error::LengthExceedsMax)`, producing a `StringM` that violates its length invariant. This affects any code that constructs `StringM` values from string input using `FromStr` (including `str::parse`), and relies on the type's maximum length constraint being enforced. An oversized `StringM` could propagate through serialization, validation, or other logic that assumes the invariant holds. All published versions of the `stellar-xdr` crate up to and including `v25.0.0` are affected. Patches The fix is merged in #500. It replaces the direct `Ok(Self(b))` construction with `b.try_into()`, which routes through `TryFrom>` and properly validates the length — matching the pattern already used by `BytesM::from_str`. Users should upgrade to the first release containing this fix once published (the next release after `v25.0.0`). Workarounds Validate the byte length of string input before calling `StringM::from_str`, or construct `StringM` values via `StringM::try_from(s.as_bytes().to_vec())` which correctly enforces the length constraint. References • Issue: https://github.com/stellar/rs-stellar-xdr/issues/499 • Fix: https://github.com/stellar/rs-stellar-xdr/pull/500

Related

Alias · CVE (1)

  • CVE-2026-29795 stellar-xdr is a library and CLI containing types and functionality for working with Stellar XDR. vulnerability

Weakness · CWE (1)

  • CWE-770 Allocation of Resources Without Limits or Throttling weakness

References