projectdiscovery/nuclei · error

invalid dns type

Error message

invalid dns type

What it means

Thrown by the 'resolve' DSL helper function in nuclei when its optional second argument (the DNS record type) does not match a supported keyword. The switch accepts 4/a, 6/aaaa, cname, ns, txt, srv, ptr, mx, soa, and caa (case-insensitive after ToLower); any other string aborts before a DNS client is even created. The first argument is the host to resolve; the second selects the record type.

Source

Thrown at pkg/operators/common/dsl/dsl.go:61

			dnsType = dns.TypeAAAA
		case "cname":
			dnsType = dns.TypeCNAME
		case "ns":
			dnsType = dns.TypeNS
		case "txt":
			dnsType = dns.TypeTXT
		case "srv":
			dnsType = dns.TypeSRV
		case "ptr":
			dnsType = dns.TypePTR
		case "mx":
			dnsType = dns.TypeMX
		case "soa":
			dnsType = dns.TypeSOA
		case "caa":
			dnsType = dns.TypeCAA
		default:
			return nil, fmt.Errorf("invalid dns type")
		}

		options := &types.Options{}
		err := dnsclientpool.Init(options)
		if err != nil {
			return nil, err
		}
		dnsClient, err := dnsclientpool.Get(options, &dnsclientpool.Configuration{})
		if err != nil {
			return nil, err
		}

		// query
		rawResp, err := dnsClient.Query(types.ToString(args[0]), dnsType)
		if err != nil {
			return nil, err
		}

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Use one of the supported keywords: 4, 6, a, aaaa, cname, ns, txt, srv, ptr, mx, soa, caa
  2. Check the argument order: resolve(host, format), e.g. resolve('example.com', 'mx')
  3. Upgrade nuclei if you need additional record types added in later releases

Example fix

# before (template DSL)
{{ resolve('example.com', 'axfr') }}

# after
{{ resolve('example.com', 'a') }}
Defensive patterns

Strategy: validation

Validate before calling

const dnsTypes = new Set(['4','6','a','aaaa','cname','ns','txt','srv','ptr','mx','soa','caa']);
const t = String(recordType).toLowerCase();
if (dnsTypes.has(t)) { /* safe to use in resolve(host, t) */ }

Type guard

function isValidDnsType(t) { return ['4','6','a','aaaa','cname','ns','txt','srv','ptr','mx','soa','caa'].includes(String(t).toLowerCase()); }

Prevention

When it happens

Trigger: Using resolve('example.com', 'txt ') with trailing whitespace, 'TXT ' uppercase variants that survive trimming issues, or unsupported types like 'axfr', 'any', or 'naptr' in a template expression; passing the arguments in the wrong order (format first, host second) so a hostname lands in the format slot.

Common situations: Template authors assuming every miekg/dns type string is supported; typos in matchers/extractors using resolve(); copying examples that use record types added in newer nuclei versions while running an older binary.

Related errors


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/82be828da15e82c3. Report an issue: GitHub.