# GHSA-VGM3-VQCV-4HV6: DNSSEC: RSA keys with very large exponents make validation expensive

- Database: GitHub
- Severity: CVSS 6.5 (Medium)
- Published: 2026-11-21
- Modified: 2026-11-22

## Affected versions

- github.com/0xERR0R/blocky (Go): from v0.36.1-0.20261116211950-5e98c7a9f88e, fixed in v0.37.0

## Description

### Summary

Development builds containing the large-exponent RSA verifier could spend excessive CPU time validating DNSSEC responses, reducing availability. That verifier accepted RSA public exponents of up to 4096 bits, with which one signature check takes about 200 times as long as with the usual 65537, and Blocky tried every signature attached to a record set, without a limit. One response from a zone that publishes such a key could cost seconds of CPU. Blocky v0.37.0 limits both.

### Impact

No position on the network is needed: the attacker needs a DNSSEC-signed zone of their own with a valid chain of trust, and a client of Blocky that looks up a name in it. Each such lookup costs CPU time, as estimated in the Details; no data is forged or disclosed.

### Affected deployments

This issue concerns deployments using Blocky’s built-in DNSSEC validator (`dnssec.validate: true`). Development builds only, including development images built from the affected revisions. No tagged release was affected. The affected revisions run from commit [`5e98c7a`](https://github.com/0xERR0R/blocky/commit/5e98c7a9f88e82fb7e36420853762773395dc9f7) of 16 November 2026, which added the verifier ([#2386](https://github.com/0xERR0R/blocky/pull/2386)), to commit [`8088f1a`](https://github.com/0xERR0R/blocky/commit/8088f1aaca9c595a08e075606ec36793b0493831), the last one before the fix.

### Remediation

Upgrade to [Blocky v0.37.0](https://github.com/0xERR0R/blocky/releases/tag/v0.37.0) or later. If you used a development image, redeploy using the fixed release image. The fix bounds RSA exponent size and the verification work performed per query. It is commit [`1c4c01b`](https://github.com/0xERR0R/blocky/commit/1c4c01b35ecbc26df7fb09f015f4912e8c6a7bbb).

### Details

RSA signature verification computes `signature^e mod n`, so its cost grows with the length of the public exponent `e`. Two things combined:

1. **Exponent size.** `parseRSAKey` in `resolver/dnssec/rsa_verify.go` accepted exponents up to the limit of [RFC 3110 §2](https://www.rfc-editor.org/rfc/rfc3110#section-2), [`rsaExponentMaxBytes`](https://github.com/0xERR0R/blocky/blob/ba40f8b16fef3210eb7e723a208d154959d20987/resolver/dnssec/rsa_verify.go#L26):

   ```go
   rsaExponentMaxBytes = 512 // RFC 3110 §2: the exponent is limited to 4096 bits
   ```

   Go’s `crypto/rsa` stops at 2^31-1. The zones that the verifier was written for ([#2364](https://github.com/0xERR0R/blocky/issues/2364)) use 2^32+1, and BIND accepts nothing above that since 9.20.26 (`lib/dns/opensslrsa_link.c`).
2. **Signature checks per record set.** [`validateSingleRRset`](https://github.com/0xERR0R/blocky/blob/ba40f8b16fef3210eb7e723a208d154959d20987/resolver/dnssec/validator.go#L476-L546) tried every RRSIG of a record set until one verified, and a signature that fails costs as much as one that verifies. Records whose owner names differed only in letter case counted as separate record sets, each with all the signatures. The DNSKEY and DS paths already stopped after 8 checks (`maxZoneKeyVerifications`, the limit against KeyTrap, CVE-2023-50387), and Unbound 1.26.2 has a similar limit per record set (`MAX_VALIDATE_RRSIGS` in `validator/val_sigcrypt.c`).

The two multiply. With a 4096-bit exponent and a 2048-bit modulus one check took about 12 ms in the run below, against 0.06 ms with 65537. An RRSIG of such a key takes about 300 bytes, so 13 fit into a 4096-byte UDP response and more than 200 into a 64 KiB TCP response: about 0.15 s and more than 2 s of CPU for one record set. The loop is older than the verifier and is in the releases too, from v0.28.2 on; that every spelling of one owner name is checked against all the signatures came with [#2363](https://github.com/0xERR0R/blocky/pull/2363) after v0.36.0 and is in no release. In the development builds between #2363 (9 November 2026) and #2386 the checks multiply with the spellings, 27 for nine signatures and three spellings on commits `16fba60` and `3123665`, but not with the exponent: those builds do not verify with an exponent above 2^31-1.

### Proof of concept

The test shows both cases on a synthetic zone `test.` with RSA/SHA-256 keys, and its benchmark times one signature check with the exponent 65537 and with a random 4096-bit one.

To reproduce, save the test file below as `resolver/dnssec/ghsa_vgm3_vqcv_4hv6_poc_test.go` in a checkout of the version to test and run:

```sh
go test -run TestGHSAvgm3VerificationBounds -v ./resolver/dnssec/
go test -run '^$' -bench BenchmarkGHSAvgm3VerifyRRSIG ./resolver/dnssec/
```

No tag shows this: the verifier was merged after `v0.36.0` and bounded before `v0.37.0`. On commit `8088f1a`, the last one before the fix, the first command exits with status 1. Its output follows, condensed to one line per test case (the number in brackets is the case in the Details, and a line without one is a control), with the result lines of the benchmark:

```text
RSA exponents above 2^32+1 are not accepted for verification:
       PASS  control: e=2^32+1
  [1]  FAIL  e=2^32+3
             verifyRRSIG of a valid signature: error <nil>, want accepted false
  [1]  FAIL  random 4096-bit e
             verifyRRSIG of a valid signature: error <nil>, want accepted false

at most maxZoneKeyVerifications signature checks per RRset:
       PASS  control: 7 failing RRSIGs, then the valid one
  [2]  FAIL  8 failing RRSIGs, then the valid one
             9 signature checks, result Secure
             9 signature checks, want at most 8
  [2]  FAIL  8 failing RRSIGs, then the valid one, owner spelt three ways
             27 signature checks, result Secure
             27 signature checks, want at most 8

BenchmarkGHSAvgm3VerifyRRSIG/e=65537-3         	   21818	     57077 ns/op
BenchmarkGHSAvgm3VerifyRRSIG/random_4096-bit_e-3         	     100	  11602118 ns/op
```

On `v0.36.0` the line with one spelling fails as well, with 9 checks. The line with three spellings is Bogus there, because the other two spellings get no signature, and it prints 9 checks or none, depending on which spelling is validated first, so it fails in some runs and passes in others. The control of case 1 fails because that release cannot verify with an exponent of 2^32+1 at all.

On `v0.37.0` both commands exit with status 0: all 6 test cases pass, and the benchmark shows that the 4096-bit exponent is refused without the long computation:

```text
BenchmarkGHSAvgm3VerifyRRSIG/e=65537-3         	   18717	     63105 ns/op
BenchmarkGHSAvgm3VerifyRRSIG/random_4096-bit_e-3         	  342420	      4023 ns/op
```

<details>
<summary><code>ghsa_vgm3_vqcv_4hv6_poc_test.go</code></summary>

```go
package dnssec

// GHSA-vgm3-vqcv-4hv6: cost bounds of RRSIG verification.
//
// RFC 3110 §2 allows RSA public exponents up to 4096 bits, and the time to verify a signature
// grows with the exponent's length. The keys in use need at most 2^32+1 (issue #2364), so larger
// exponents are not accepted for verification. Each RRSIG of an RRset costs one verification, so
// one RRset gets at most maxZoneKeyVerifications of them, the bound of the zone-key paths (KeyTrap,
// CVE-2023-50387). Owner names compare case-insensitively (RFC 4343), so records whose owner is
// spelt in several cases are one RRset and share that bound.
//
// go test -run TestGHSAvgm3VerificationBounds -v ./resolver/dnssec/
// go test -run '^$' -bench BenchmarkGHSAvgm3VerifyRRSIG ./resolver/dnssec/

import (
	"bytes"
	"context"
	"crypto"
	"crypto/rand"
	"encoding/base64"
	"io"
	"math/big"
	"net"
	"strings"
	"testing"
	"time"

	"github.com/0xERR0R/blocky/log"
	"github.com/0xERR0R/blocky/model"
	"github.com/miekg/dns"
	"github.com/sirupsen/logrus"
)

func TestGHSAvgm3VerificationBounds(t *testing.T) {
	ctx := t.Context()
	a := pocVgm3A()

	t.Run("RSA exponents above 2^32+1 are not accepted for verification", func(t *testing.T) {
		logger, _ := log.NewMockEntry()
		v := NewValidator(ctx, nil, logger, nil, 1, 10, 150, 30, 3600) // verifyRRSIG needs no anchor or upstream

		for _, c := range []struct {
			name   string
			e      *big.Int
			accept bool
		}{
			{"control: e=2^32+1", new(big.Int).SetUint64(1<<32 + 1), true},
			{"e=2^32+3", new(big.Int).SetUint64(1<<32 + 3), false},
			{"random 4096-bit e", pocVgm3E4096(t), false},
		} {
			t.Run(c.name, func(t *testing.T) {
				key := newPocVgm3Key(t, c.e)
				if err := v.verifyRRSIG([]dns.RR{a}, key.sign(t, a), key.key, nil, ""); (err == nil) != c.accept {
					t.Errorf("verifyRRSIG of a valid signature: error %v, want accepted %t", err, c.accept)
				}
			})
		}
	})

	t.Run("at most maxZoneKeyVerifications signature checks per RRset", func(t *testing.T) {
		key := newPocVgm3Key(t, big.NewInt(65537))
		anchors, err := NewTrustAnchorStore([]string{key.key.String()})
		if err != nil {
			t.Fatal(err)
		}

		dnskey, valid := []dns.RR{key.key, key.sign(t, key.key)}, key.sign(t, a)

		for _, c := range []struct {
			name    string
			failing int
			owners  []string
		}{
			{"control: 7 failing RRSIGs, then the valid one", 7, []string{"www.test."}},
			{"8 failing RRSIGs, then the valid one", 8, []string{"www.test."}},
			{"8 failing RRSIGs, then the valid one, owner spelt three ways", 8, []string{"www.test.", "WWW.test.", "Www.test."}},
		} {
			t.Run(c.name, func(t *testing.T) {
				response := new(dns.Msg)
				for _, owner := range c.owners {
					rr := dns.Copy(a)
					rr.Header().Name = owner
					response.Answer = append(response.Answer, rr)
				}

				for i := range c.failing {
					failing := dns.Copy(valid).(*dns.RRSIG)
					failing.Inception -= uint32(i + 1) // no longer the signed data, so it does not verify
					response.Answer = append(response.Answer, failing)
				}

				response.Answer = append(response.Answer, valid)

				logger, hook := log.NewMockEntry()
				v := NewValidator(ctx, anchors, logger, &mockResolver{
					ResolveFn: func(_ context.Context, _ *model.Request) (*model.Response, error) {
						return &model.Response{Res: &dns.Msg{Answer: dnskey}}, nil // the only query is test. DNSKEY
					},
				}, 1, 10, 150, 30, 3600)
				got := v.ValidateResponse(ctx, response, dns.Question{Name: a.Hdr.Name, Qtype: dns.TypeA, Qclass: dns.ClassINET})

				checks := 0 // verifyWithSignerKeys logs every signature check of an answer RRSIG
				for _, msg := range hook.Messages {
					if strings.HasPrefix(msg, "RRSIG verification failed for") ||
						strings.HasPrefix(msg, "Successfully verified RRset for") {
						checks++
					}
				}

				t.Logf("%d signature checks, result %s", checks, got)

				if checks > maxZoneKeyVerifications {
					t.Errorf("%d signature checks, want at most %d", checks, maxZoneKeyVerifications)
				}

				if c.failing < maxZoneKeyVerifications && got != ValidationResultSecure { // the valid RRSIG is in reach
					t.Errorf("got %s, want Secure", got)
				}
			})
		}
	})
}

// BenchmarkGHSAvgm3VerifyRRSIG times one verifyRRSIG call of a 2048-bit RSA/SHA-256 key with
// e=65537 and with a random 4096-bit exponent, whether the key is accepted or not.
func BenchmarkGHSAvgm3VerifyRRSIG(b *testing.B) {
	v := NewValidator(b.Context(), nil, logrus.NewEntry(logrus.New()), nil, 1, 10, 150, 30, 3600)
	a := pocVgm3A()

	for _, c := range []struct {
		name string
		e    *big.Int
	}{{"e=65537", big.NewInt(65537)}, {"random 4096-bit e", pocVgm3E4096(b)}} {
		key := newPocVgm3Key(b, c.e)
		sig := key.sign(b, a)

		b.Run(c.name, func(b *testing.B) {
			for b.Loop() {
				_ = v.verifyRRSIG([]dns.RR{a}, sig, key.key, nil, "")
			}
		})
	}
}

type pocVgm3Key struct {
	key  *dns.DNSKEY
	priv crypto.Signer
}

// newPocVgm3Key returns an RSA/SHA-256 DNSKEY (RFC 3110) of test. with a 2048-bit modulus and
// public exponent e. crypto/rsa refuses exponents above 2^31-1, so the key is made, and signs,
// with math/big.
func newPocVgm3Key(tb testing.TB, e *big.Int) pocVgm3Key {
	tb.Helper()

	for {
		p, err := rand.Prime(rand.Reader, 1024)
		if err != nil {
			tb.Fatal(err)
		}

		q, err := rand.Prime(rand.Reader, 1024)
		if err != nil {
			tb.Fatal(err)
		}

		one, n, exp := big.NewInt(1), new(big.Int).Mul(p, q), e.Bytes()
		d := new(big.Int).ModInverse(e, new(big.Int).Mul(new(big.Int).Sub(p, one), new(big.Int).Sub(q, one)))

		pub := []byte{byte(len(exp))}
		if len(exp) > 255 { // RFC 3110 §2: a zero octet, then the exponent length in two octets
			pub = []byte{0, byte(len(exp) >> 8), byte(len(exp))}
		}

		pub = append(append(pub, exp...), n.Bytes()...)
		key := &dns.DNSKEY{
			Hdr:   dns.RR_Header{Name: "test.", Rrtype: dns.TypeDNSKEY, Class: dns.ClassINET, Ttl: 3600},
			Flags: 257, Protocol: 3, Algorithm: dns.RSASHA256, PublicKey: base64.StdEncoding.EncodeToString(pub),
		}

		if d != nil && key.KeyTag() != 0 { // e must be invertible; RRSIG.Sign refuses key tag 0
			return pocVgm3Key{key, pocVgm3Signer{n, d}}
		}
	}
}

// sign returns the RRSIG over rrset made by k with RRSIG.Sign.
func (k pocVgm3Key) sign(tb testing.TB, rrset ...dns.RR) *dns.RRSIG {
	tb.Helper()

	sig := &dns.RRSIG{
		Algorithm: k.key.Algorithm, KeyTag: k.key.KeyTag(), SignerName: k.key.Hdr.Name,
		Inception: uint32(time.Now().Add(-time.Hour).Unix()), Expiration: uint32(time.Now().Add(time.Hour).Unix()),
	}
	if err := sig.Sign(k.priv, rrset); err != nil {
		tb.Fatal(err)
	}

	return sig
}

// pocVgm3Signer makes RSASSA-PKCS1-v1_5 SHA-256 signatures (RFC 8017 §8.2.1) with math/big.
type pocVgm3Signer struct{ n, d *big.Int }

func (s pocVgm3Signer) Public() crypto.PublicKey { return nil } // RRSIG.Sign does not use it

func (s pocVgm3Signer) Sign(_ io.Reader, digest []byte, _ crypto.SignerOpts) ([]byte, error) {
	digestInfo := "\x30\x31\x30\x0d\x06\x09\x60\x86\x48\x01\x65\x03\x04\x02\x01\x05\x00\x04\x20" + string(digest)
	k := (s.n.BitLen() + 7) / 8
	em := bytes.Repeat([]byte{0xff}, k) // EM = 0x00 || 0x01 || PS (0xff octets) || 0x00 || DigestInfo
	em[0], em[1], em[k-len(digestInfo)-1] = 0, 1, 0
	copy(em[k-len(digestInfo):], digestInfo)

	return new(big.Int).Exp(new(big.Int).SetBytes(em), s.d, s.n).FillBytes(make([]byte, k)), nil
}

// pocVgm3E4096 returns a random odd public exponent of 4096 bits.
func pocVgm3E4096(tb testing.TB) *big.Int {
	e, err := rand.Int(rand.Reader, new(big.Int).Lsh(big.NewInt(1), 4095))
	if err != nil {
		tb.Fatal(err)
	}

	return e.SetBit(e, 4095, 1).SetBit(e, 0, 1)
}

func pocVgm3A() *dns.A {
	hdr := dns.RR_Header{Name: "www.test.", Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: 300}

	return &dns.A{Hdr: hdr, A: net.IPv4(192, 0, 2, 1)}
}
```

</details>

### References

- RFC 3110 [§2](https://www.rfc-editor.org/rfc/rfc3110#section-2); CVE-2023-50387 (KeyTrap)
- Fix: [Blocky v0.37.0](https://github.com/0xERR0R/blocky/releases/tag/v0.37.0), commit [`1c4c01b`](https://github.com/0xERR0R/blocky/commit/1c4c01b35ecbc26df7fb09f015f4912e8c6a7bbb)
- Related advisories from the same review:
  - [GHSA-rfc7-q64c-hj2f](https://github.com/0xERR0R/blocky/security/advisories/GHSA-rfc7-q64c-hj2f): DNSSEC: DS and DNSKEY lookups that fail, are unsigned or are for another zone are trusted
  - [GHSA-8mfq-h5hh-mqf2](https://github.com/0xERR0R/blocky/security/advisories/GHSA-8mfq-h5hh-mqf2): DNSSEC: a response's status doesn't account for all of its parts, its question or its rcode
  - [GHSA-mv8x-2h8p-g3wh](https://github.com/0xERR0R/blocky/security/advisories/GHSA-mv8x-2h8p-g3wh): DNSSEC: incomplete denial-of-existence proofs (wildcards, NSEC NXDOMAIN, CNAME bit, name order)
  - [GHSA-6fgw-qmpq-vwxp](https://github.com/0xERR0R/blocky/security/advisories/GHSA-6fgw-qmpq-vwxp): DNSSEC: NSEC and NSEC3 denials are accepted from zones not authoritative for the queried name
  - [GHSA-g35c-mff8-4w2w](https://github.com/0xERR0R/blocky/security/advisories/GHSA-g35c-mff8-4w2w): DNSSEC: a failed signature by a large-exponent RSA key gives Insecure instead of Bogus
  - [GHSA-583r-m4vv-q43p](https://github.com/0xERR0R/blocky/security/advisories/GHSA-583r-m4vv-q43p): DNSSEC: NSEC3 Opt-Out proof can downgrade a signed zone to Insecure

### Credits

Reported by @kevinpark1217.

## References

- https://github.com/0xERR0R/blocky/security/advisories/GHSA-vgm3-vqcv-4hv6

Page: https://cve.now/GHSA-VGM3-VQCV-4HV6

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
