CVE-2021-43568: Ecdsa elixir Ecdsa-elixir Fails To Check Signatures, Vulnerability
CRITICALCVE-2021-43568 is a CRITICAL (CVSS 9.8) ecdsa-elixir fails to check signatures, vulnerability (CWE-347: Improper Verification of Cryptographic Signature) affecting Ecdsa elixir libraries in the Hex ecosystem. The issue involves ecdsa-elixir fails to check signatures, vulnerable to message forging. Remediation is available by upgrading affected packages to version 1.0.1.
CVE-2021-43568 at a Glance
Security Impact
CVSS: 9.8
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).
How to Fix CVE-2021-43568
To remediate this vulnerability, upgrade all affected Ecdsa elixir dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade ecdsa-elixir to 1.0.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for ecdsa-elixir
How to Check if You Are Affected
To determine whether your application is affected by CVE-2021-43568, inspect your project dependencies for Ecdsa elixir:
inspect dependencies for ecdsa-elixir
Analyze the terminal output to locate any version of Ecdsa elixir in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.1), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-347: Improper Verification of Cryptographic Signature, where the product does not verify, or incorrectly verifies, the cryptographic signature for data. In Ecdsa elixir, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-43568 Affected Ecdsa elixir Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
ecdsa-elixir
|
Hex |
≥ 1.0.0
< 1.0.1
All 1 versions
1.0.0
|
1.0.1
|
References
Frequently Asked Questions
What is CVE-2021-43568?
Which Ecdsa elixir versions are affected?
What version fixes CVE-2021-43568?
Is ecdsa-elixir affected?
What is the CVSS score of CVE-2021-43568?
What CWE is associated with CVE-2021-43568?
How can I check Hex dependencies for CVE-2021-43568?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-xx36-6rv4-gj8r",
"modified" : "2023-09-27T21:49:47Z",
"published" : "2022-05-24T19:20:12Z",
"aliases" : [ "CVE-2021-43568" ],
"summary" : "ecdsa-elixir fails to check signatures, vulnerable to message forging",
"details" : "### Summary\nStark Bank is a financial technology company that provides services to simplify and automate digital banking, by providing APIs to perform operations such as payments and transfers. In addition, Stark Bank maintains a number of cryptographic libraries to perform cryptographic signing and verification. These popular libraries are meant to be used to integrate with the Stark Bank ecosystem, but are also accessible on popular package manager platforms in order to be used by other projects. The node package manager reports around 16k weekly downloads for the [ecdsa-node](https://www.npmjs.com/package/starkbank-ecdsa ) implementation while the Python implementation boasts over [7.3M downloads in the last 90 days on PyPI](https://package.wiki/starkbank-ecdsa). A number of these libraries suffer from a vulnerability in the signature verification functions, allowing attackers to forge signatures for arbitrary messages which successfully verify with any public key.\n\n### Impact\nAn attacker can forge signatures on arbitrary messages that will verify for any public key. This may allow attackers to authenticate as any user within the Stark Bank platform, and bypass signature verification needed to perform operations on the platform, such as send payments and transfer funds. Additionally, the ability for attackers to forge signatures may impact other users and projects using these libraries in different and unforeseen ways.\n\n### Details\nThe (slightly simplified) ECDSA verification of a signature _**(r, s)**_ on a hashed message _**z**_ with public key _**Q**_ and curve order _**n**_ works as follows:\n\nThe (slightly simplified) ECDSA verification of a signature _**(r, s)**_ on a hashed message _**z**_ with public key _**Q**_ and curve order _**n**_ works as follows:\n\n- Check that _**r**_ and _**s**_ are integers in the _**[1, n-1]**_ range, return Invalid if not.\n- Compute _**u<sub>1</sub> = zs<sup>-1</sup> mod n**_ and _**u<sub>2</sub> = rs<sup>-1</sup> mod n**_.\n- Compute the elliptic curve point _**(x, y) = u<sub>1</sub>G + u<sub>2</sub>Q**_, return Invalid if _**(x, y)**_ is the point at infinity.\n- Return Valid if _**r ≡ x mod n**_, Invalid otherwise.\n\nThe ECDSA signature verification functions in the libraries listed above fail to perform the first check, ensuring that the r and s components of the signatures are in the correct range. Specifically, the libraries are not checking that the components of the signature are non-zero, which is an important check mandated by the standard, see X9.62:2005, Section 7.4.1/a:\n\n> 1. If _**r’**_ is not an integer in the interval _**[1, n-1]**_, then reject the signature.\n> 2. If _**s’**_ is not an integer in the interval _**[1, n-1]**_, then reject the signature.\n\nFor example, consider the following excerpt of the verify function from the [ecdsa-python implementation](https://github.com/starkbank/ecdsa-python/blob/v2.0.0/ellipticcurve/ecdsa.py#L34-L41).\n\n```python\ndef verify(cls, message, signature, publicKey, hashfunc=sha256):\n byteMessage = hashfunc(toBytes(message)).digest()\n numberMessage = numberFromByteString(byteMessage)\n curve = publicKey.curve\n r = signature.r\n s = signature.s\n inv = Math.inv(s, curve.N)\n u1 = Math.multiply(curve.G, n=(numberMessage * inv) % curve.N, N=curve.N, A=curve.A, P=curve.P)\n u2 = Math.multiply(publicKey.point, n=(r * inv) % curve.N, N=curve.N, A=curve.A, P=curve.P)\n add = Math.add(u1, u2, A=curve.A, P=curve.P)\n modX = add.x % curve.N\n return r == modX\n```\n\nIn that code snippet, the values `r` and `s` are extracted from the signature without any range check. An attacker supplying a signature equal to `(r, s) = (0, 0)` will not see their signature rejected. Proceeding with the verification, this function computes the inverse of the `s` component. Note that the `Math.inv()` function returns zero when supplied with a zero input (even though 0 does not admit an inverse). The code then computes the values `u1 = inv * numberMessage * G` and `u2 = inv * r * Q`, but since `inv` is zero, `u1` and `u2` will both be zero, i.e., the point at infinity, regardless of the value of numberMessage (the message hash, which we called _**z**_ above) and _**Q**_ (the public key). Subsequently, the implementation computes the intermediary curve point add by adding up the two previously computed points, which again results in the point at infinity. The final line checks that the r-component of the signature is equal to the x-coordinate of the curve point, essentially checking that `0 == 0` for all any message and any public key. Therefore, a signature `(r, s) = (0, 0)` is deemed valid by the code for any message, and under any public key.\n\n### Recommendation\nUsers of the different Stark Bank ECDSA libraries should update to the latest versions. Specifically, versions larger or at least equal to the following should be used.\n\n- ecdsa-python: v2.0.1\n- ecdsa-java: v1.0.1\n- ecdsa-dotnet: v1.3.2\n- ecdsa-elixir v1.0.1\n- ecdsa-node v1.1.3",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "Hex",
"name" : "ecdsa-elixir"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "1.0.0"
}, {
"fixed" : "1.0.1"
} ]
} ],
"versions" : [ "1.0.0" ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43568"
}, {
"type" : "WEB",
"url" : "https://github.com/starkbank/ecdsa-elixir/commit/4b960e26768bb698f449eb7686b5664936b70b61"
}, {
"type" : "WEB",
"url" : "https://github.com/starkbank/ecdsa-elixir/commit/a5168f6d9cfbe0a0a62d92e2e9b1a97235d90343"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/starkbank/ecdsa-elixir"
}, {
"type" : "WEB",
"url" : "https://github.com/starkbank/ecdsa-elixir/releases/tag/v1.0.1"
}, {
"type" : "WEB",
"url" : "https://research.nccgroup.com/2021/11/08/technical-advisory-arbitrary-signature-forgery-in-stark-bank-ecdsa-libraries"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-347" ],
"severity" : "CRITICAL",
"github_reviewed" : true,
"github_reviewed_at" : "2022-07-01T17:15:25Z",
"nvd_published_at" : "2021-11-09T22:15:00Z"
}
}