GHSA-x57h-xx53-v53w

Suggest an improvement
Source
https://github.com/advisories/GHSA-x57h-xx53-v53w
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-x57h-xx53-v53w/GHSA-x57h-xx53-v53w.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-x57h-xx53-v53w
Aliases
Published
2026-03-05T20:45:46Z
Modified
2026-03-06T23:02:40Z
Severity
  • 4.0 (Medium) CVSS_V3 - CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N CVSS Calculator
Summary
stellar-xdr's StringM::from_str bypasses max length validation
Details

Impact

StringM::from_str does not validate that the input length is within the declared maximum (MAX). Calling StringM::<N>::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<Vec<u8>> 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

Database specific
{
    "cwe_ids":  [
        "CWE-770"
    ],
    "github_reviewed":  true,
    "github_reviewed_at":  "2026-03-05T20:45:46Z",
    "nvd_published_at":  "2026-03-06T21:16:15Z",
    "severity":  "MODERATE"
}
References

Affected packages

crates.io / stellar-xdr

Package

Name
stellar-xdr
View open source insights on deps.dev
Purl
pkg:cargo/stellar-xdr

Affected ranges

Type
SEMVER
Events
Introduced
0 Unknown introduced version / All previous versions are affected
Fixed
25.0.1

Database specific

last_known_affected_version_range
"<= 25.0.0"
source
"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2026/03/GHSA-x57h-xx53-v53w/GHSA-x57h-xx53-v53w.json"