{"id":"CVE-2026-32322","aliases":["CVE-2026-32322","GHSA-x2hw-px52-wp4m"],"related":[],"kind":"vulnerability","state":"published","title":"soroban-sdk: `Fr` scalar field equality comparison bypasses modular reduction","summary":"soroban-sdk is a Rust SDK for Soroban contracts. Prior to 22.0.11, 23.5.3, and 25.3.0, The Fr (scalar field) types for BN254 and BLS12-381 in soroban-sdk compared values using their raw U256 representation without first reducing modulo the field modulus r. This caused mathematically equal field elements to compare as not-equal when one or both values were unreduced (i.e., >= r). The vulnerability requires an attacker to supply crafted Fr values through contract inputs, and compare them directly without going through host-side arithmetic operations. Smart contracts that rely on Fr equality checks for security-critical logic could produce incorrect results. The impact depends on how the affected contract uses Fr equality comparisons, but can result in incorrect authorization decisions or validation bypasses in contracts that perform equality checks on user-supplied scalar values. This vulnerability is fixed in 22.0.11, 23.5.3, and 25.3.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"soroban-sdk is a Rust SDK for Soroban contracts. Prior to 22.0.11, 23.5.3, and 25.3.0, The Fr (scalar field) types for BN254 and BLS12-381 in soroban-sdk compared values using their raw U256 representation without first reducing modulo the field modulus r. This caused mathematically equal field elements to compare as not-equal when one or both values were unreduced (i.e., >= r). The vulnerability requires an attacker to supply crafted Fr values through contract inputs, and compare them directly without going through host-side arithmetic operations. Smart contracts that rely on Fr equality checks for security-critical logic could produce incorrect results. The impact depends on how the affected contract uses Fr equality comparisons, but can result in incorrect authorization decisions or validation bypasses in contracts that perform equality checks on user-supplied scalar values. This vulnerability is fixed in 22.0.11, 23.5.3, and 25.3.0.","source":"cvelist"},{"lang":"en","text":"# Security Advisory: Incorrect Equality for Fr Scalar Field Types (BN254, BLS12-381)\n\n## Summary\n\nMissing modular reduction in `Fr` causes incorrect equality comparisons for BN254 and BLS12-381 types in soroban-sdk.\n\n## Impact\n\nThe `Fr` (scalar field) types for BN254 and BLS12-381 in `soroban-sdk` compared values using their raw `U256` representation without first reducing modulo the field modulus `r`. This caused mathematically equal field elements to compare as not-equal when one or both values were unreduced (i.e., >= `r`). \n\nThe vulnerability requires an attacker to supply crafted `Fr` values through contract inputs, and compare them directly without going through host-side arithmetic operations.\n\nSmart contracts that rely on `Fr` equality checks for security-critical logic could produce incorrect results. The impact depends on how the affected contract uses Fr equality comparisons, but can result in incorrect authorization decisions or validation bypasses in contracts that perform equality checks on user-supplied scalar values.\n\n## Details\n\n`Fr` types for both curves are wrappers around `U256`. The `PartialEq` implementation compared the raw `U256` values directly. However, the constructors (`from_u256`, `from_bytes`, `From<U256>`) accepted arbitrary `U256` values without reducing them modulo `r`. This meant two `Fr` values representing the same field element (e.g., `1` and `r + 1`) could have different internal representations and compare as not-equal.\n\nThis issue was compounded by an asymmetry: all host-side arithmetic operations (`fr_add`, `fr_sub`, `fr_mul`, `fr_pow`, `fr_inv`) always return canonically reduced results in `[0, r)`, while user-constructed `Fr` values could hold unreduced representations. Comparing a user-supplied `Fr` against a host-computed `Fr` would therefore produce incorrect results even when the underlying field elements were identical.\n\n### Example\n\n```rust\nlet r = /* BN254 scalar field modulus */;\nlet a = Fr::from_u256(r + 1); // unreduced, stores r+1\nlet b = Fr::from_u256(1);     // reduced, stores 1\n\n// a and b represent the same field element (1), but compared as NOT equal\nassert_eq!(a, b); // FAILED before the fix\n```\n\n## Patches\n\nAll `Fr` construction paths now reduce the input modulo `r`, ensuring a canonical representation in `[0, r)`. This guarantees that equal field elements always have identical internal representations, making the existing `PartialEq` comparison correct.\n\nAdditionally, `Fp` and `Fp2` base field types for both curves now validate that values are strictly less than the field modulus on construction, rejecting out-of-range inputs.\n\n## Workarounds\n\nIf upgrading is not immediately possible:\n- Manually reduce the underlying `U256` via `rem_euclid` by the field modulus `r` before constructing `Fr`, or round-trip through host `Fr` arithmetic (e.g., `fr_add(val, zero)`) which always returns reduced results. Note: BN254 does not expose dedicated `Fr` host functions, so `rem_euclid` is the only option there.\n\n## Recommendations\n\n- Upgrade to the patched version of `soroban-sdk`.\n- Review any deployed contracts that accept `Fr` values as input, and compare those values using `==`, `!=`, or `assert_eq!`. These contracts may be vulnerable if an attacker can supply unreduced scalar values to bypass equality checks.","format":"markdown","source":"ghsa"},{"lang":"es","text":"soroban-sdk es un SDK de Rust para contratos Soroban. Antes de 22.0.11, 23.5.3 y 25.3.0, los tipos Fr (campo escalar) para BN254 y BLS12-381 en soroban-sdk comparaban valores usando su representación U256 cruda sin reducir primero el módulo del módulo de campo r. Esto causó que elementos de campo matemáticamente iguales se compararan como no-iguales cuando uno o ambos valores no estaban reducidos (es decir, &gt;= r). La vulnerabilidad requiere que un atacante suministre valores Fr manipulados a través de entradas de contrato, y los compare directamente sin pasar por operaciones aritméticas del lado del host. Los contratos inteligentes que dependen de comprobaciones de igualdad de Fr para lógica de seguridad crítica podrían producir resultados incorrectos. El impacto depende de cómo el contrato afectado utiliza las comparaciones de igualdad de Fr, pero puede resultar en decisiones de autorización incorrectas o elusión de validaciones en contratos que realizan comprobaciones de igualdad en valores escalares suministrados por el usuario. Esta vulnerabilidad está corregida en 22.0.11, 23.5.3 y 25.3.0.","source":"nvd"}],"published":"2026-03-12T21:39:38.022Z","modified":"2026-06-17T10:35:33.707Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"}],"cwes":["CWE-697"],"affected":[{"ranges":[{"version":">= 25.0.0, < 25.3.0","status":"affected"},{"version":">= 23.0.0, < 23.5.3","status":"affected"},{"version":"< 22.0.11","status":"affected"}],"vendor":"stellar","product":"rs-soroban-sdk","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"25.0.0","status":"affected","fixed":"25.3.0"}],"ecosystem":"crates.io","package":"soroban-sdk","purl":"pkg:cargo/soroban-sdk","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"23.0.0","status":"affected","fixed":"23.5.3"}],"ecosystem":"crates.io","package":"soroban-sdk","purl":"pkg:cargo/soroban-sdk","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"22.0.11"}],"ecosystem":"crates.io","package":"soroban-sdk","purl":"pkg:cargo/soroban-sdk","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"22.0.11"},{"status":"affected","introduced":"23.0.0","fixed":"23.5.3"},{"status":"affected","introduced":"25.0.0","fixed":"25.3.0"}],"vendor":"stellar","product":"rs-soroban-sdk","cpe":"cpe:2.3:a:stellar:rs-soroban-sdk:*:*:*:*:*:rust:*:*","source":"nvd"}],"references":[{"url":"https://github.com/stellar/rs-soroban-sdk/security/advisories/GHSA-x2hw-px52-wp4m","tags":["mitigation","patch","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-32322","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/stellar/rs-soroban-sdk/pull/1750","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/stellar/rs-soroban-sdk/commit/082424b30bf22ea7fb8c79f16ccd135e0ae9f3db","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/stellar/rs-soroban-sdk","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/stellar/rs-soroban-sdk/releases/tag/v22.0.11","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/stellar/rs-soroban-sdk/releases/tag/v23.5.3","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/stellar/rs-soroban-sdk/releases/tag/v25.3.0","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-03-13T14:59:43.183Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-32322","url":"https://www.cve.org/CVERecord?id=CVE-2026-32322","licence":"CVE Terms of Use","modified":"2026-03-13T15:00:09.804Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-x2hw-px52-wp4m","url":"https://github.com/advisories/GHSA-x2hw-px52-wp4m","licence":"CC-BY-4.0","modified":"2026-03-16T17:16:39.585Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-32322","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-32322","licence":"Public domain","modified":"2026-06-17T10:35:33.707Z"}],"updatedAt":"2026-11-25T22:59:15.893Z","epss":{"score":0.00378,"percentile":0.23645,"date":"2026-11-30T12:00:22.000Z"}}