CVE-2026-26267: The rs-soroban-sdk #[contractimpl] macro calls inherent function instead of trait function when names collide
(updated )
The #[contractimpl] macro contains a bug in how it wires up function calls.
In Rust, you can define functions on a type in two ways:
- Directly on the type as an inherent function:
impl MyContract {
fn value() { ... }
}
- Through a trait
impl Trait for MyContract {
fn value() { ... }
}
These are two separate functions that happen to share the same name. Rust has rules for which one gets called. When you write MyContract::value(), Rust always picks the one defined directly on the type, not the trait version.
The bug is that #[contractimpl] generates code that uses MyContract::value() style calls even when it’s processing the trait version. This means if an inherent function is also defined with the same name, the inherent function gets called instead of the trait function.
This means the Wasm-exported entry point silently calls the wrong function when two conditions are met simultaneously:
- A
impl Trait for MyContractblock is defined with one or more functions, with#[contractimpl]applied. - A
impl MyContractblock is defined with one or more identically named functions, without#[contractimpl]applied.
If the trait version contains important security checks, such as verifying the caller is authorized, that the inherent version does not, those checks are bypassed. Anyone interacting with the contract through its public interface will call the wrong function.
For example:
References
- github.com/advisories/GHSA-4chv-4c6w-w254
- github.com/stellar/rs-soroban-sdk
- github.com/stellar/rs-soroban-sdk/commit/e92a3933e5f92dc09da3c740cf6a360d55709a2b
- github.com/stellar/rs-soroban-sdk/pull/1729
- github.com/stellar/rs-soroban-sdk/pull/1730
- github.com/stellar/rs-soroban-sdk/pull/1731
- github.com/stellar/rs-soroban-sdk/security/advisories/GHSA-4chv-4c6w-w254
- nvd.nist.gov/vuln/detail/CVE-2026-26267
Code Behaviors & Features
Detect and mitigate CVE-2026-26267 with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →