{"id":"GHSA-pffg-92cg-xf5c","aliases":["GHSA-pffg-92cg-xf5c","GO-2023-2101"],"related":[],"kind":"vulnerability","state":"published","title":"gnark-crypto's exponentiation in the pairing target group GT using GLV can give incorrect results","summary":"### Impact\nWhen the exponent is bigger than `r`, the group order of the pairing target group `GT`, the exponentiation à la GLV (`ExpGLV`) can *sometimes* give incorrect results compared to normal exponentiation (`Exp`). \n\nThe issue impacts all users using `ExpGLV` for exponentiations in `GT`. This does not impact `Exp` and `ExpCyclotomic` which are sound. Also note that GLV methods in G1 and G2 are sound and _not_ impacted.\n\n### Patches\nFix has been implemented in pull request https://github.com/Consensys/gnark-crypto/pull/451 and merged in commit https://github.com/Consensys/gnark-crypto/commit/ec6be1a037f7c496d595c541a8a8d31c47bcfa3d to master branch.\n\nThe fix increased the bounds of the sub-scalars by 1. In fact, since https://github.com/Consensys/gnark-crypto/pull/213, we use a fast scalar decomposition that tradeoffs divisions (needed in the Babai rounding) by right-shifts. We precompute `b=2^m*v/d (m > log2(d))` and then at runtime compute `scalar*b/2^m` (`v` is a lattice vector and `d` the lattice determinant). This increases the bounds on sub-scalars by 1 which we check at runtime before increasing the loop size (we don't target constant-timeness). `m` is chosen to be a machine word twice big than `log2(d)` so that we rarely need to increase the loop size. Hence why the issue happens only *sometimes* if we omit to increase the bounds. This bounds increase was implemented in G1 and G2 but forgot in GT.\n\n### Workarounds\nUpdating to `v0.12.1+`. Alternatively, use `Exp` or `ExpCyclotomic` instead. We are not aware of any users using `ExpGLV` anyway.\n\n### References\n- Fix PR: https://github.com/Consensys/gnark-crypto/pull/451 \n- Fast scalar decomposition PR: https://github.com/Consensys/gnark-crypto/pull/213\n- https://eprint.iacr.org/2015/565 Sec.4.2\n\n### Acknowledgement\nThe vulnerability was reported by [Antonio Sanso](https://github.com/asanso) @ [EF](https://crypto.ethereum.org/).","summaryFormat":"markdown","summarySource":"ghsa","descriptions":[{"lang":"en","text":"### Impact\nWhen the exponent is bigger than `r`, the group order of the pairing target group `GT`, the exponentiation à la GLV (`ExpGLV`) can *sometimes* give incorrect results compared to normal exponentiation (`Exp`). \n\nThe issue impacts all users using `ExpGLV` for exponentiations in `GT`. This does not impact `Exp` and `ExpCyclotomic` which are sound. Also note that GLV methods in G1 and G2 are sound and _not_ impacted.\n\n### Patches\nFix has been implemented in pull request https://github.com/Consensys/gnark-crypto/pull/451 and merged in commit https://github.com/Consensys/gnark-crypto/commit/ec6be1a037f7c496d595c541a8a8d31c47bcfa3d to master branch.\n\nThe fix increased the bounds of the sub-scalars by 1. In fact, since https://github.com/Consensys/gnark-crypto/pull/213, we use a fast scalar decomposition that tradeoffs divisions (needed in the Babai rounding) by right-shifts. We precompute `b=2^m*v/d (m > log2(d))` and then at runtime compute `scalar*b/2^m` (`v` is a lattice vector and `d` the lattice determinant). This increases the bounds on sub-scalars by 1 which we check at runtime before increasing the loop size (we don't target constant-timeness). `m` is chosen to be a machine word twice big than `log2(d)` so that we rarely need to increase the loop size. Hence why the issue happens only *sometimes* if we omit to increase the bounds. This bounds increase was implemented in G1 and G2 but forgot in GT.\n\n### Workarounds\nUpdating to `v0.12.1+`. Alternatively, use `Exp` or `ExpCyclotomic` instead. We are not aware of any users using `ExpGLV` anyway.\n\n### References\n- Fix PR: https://github.com/Consensys/gnark-crypto/pull/451 \n- Fast scalar decomposition PR: https://github.com/Consensys/gnark-crypto/pull/213\n- https://eprint.iacr.org/2015/565 Sec.4.2\n\n### Acknowledgement\nThe vulnerability was reported by [Antonio Sanso](https://github.com/asanso) @ [EF](https://crypto.ethereum.org/).","format":"markdown","source":"ghsa"},{"lang":"en","text":"Incorrect exponentiation results in github.com/consensys/gnark-crypto","format":"markdown","source":"go"}],"published":"2023-10-05T20:57:20.000Z","modified":"2024-05-20T21:55:42.000Z","severity":{"scorer":"GitHub","scheme":"rating","rating":"LOW"},"severities":[{"scorer":"GitHub","scheme":"rating","rating":"LOW"}],"cwes":[],"affected":[{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.12.1"}],"ecosystem":"Go","package":"github.com/consensys/gnark-crypto","purl":"pkg:golang/github.com/consensys/gnark-crypto","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.12.1"}],"ecosystem":"Go","package":"github.com/consensys/gnark-crypto","purl":"pkg:golang/github.com/consensys/gnark-crypto","source":"go"}],"references":[{"url":"https://github.com/Consensys/gnark-crypto/security/advisories/GHSA-pffg-92cg-xf5c","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/Consensys/gnark-crypto/pull/213","tags":["fix","web"],"sources":["ghsa","go"]},{"url":"https://github.com/Consensys/gnark-crypto/pull/451","tags":["fix","web"],"sources":["ghsa","go"]},{"url":"https://github.com/Consensys/gnark-crypto/commit/ec6be1a037f7c496d595c541a8a8d31c47bcfa3d","tags":["fix","web"],"sources":["ghsa","go"]},{"url":"https://eprint.iacr.org/2015/565","tags":["web"],"sources":["ghsa","go"]},{"url":"https://github.com/Consensys/gnark-crypto","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/advisories/GHSA-pffg-92cg-xf5c","tags":["advisory"],"sources":["go"]}],"credits":["@asanso"],"sources":[{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-pffg-92cg-xf5c","url":"https://github.com/advisories/GHSA-pffg-92cg-xf5c","licence":"CC-BY-4.0","modified":"2024-05-20T21:55:42.000Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2023-2101","url":"https://pkg.go.dev/vuln/GO-2023-2101","licence":"CC-BY-4.0","modified":"2024-05-20T16:03:47.000Z"}],"updatedAt":"2026-11-25T22:56:23.573Z"}