DNS over HTTPS JSON TXT records not properly escaped

Please include test result URL when you create a post in the community forum. Paste the results from → 1.1.1.1 — One of the Internet’s Fastest, Privacy-First DNS Resolver

What is the issue you’re encountering

When using the DNS over HTTPS JSON endpoints, TXT records with a quotation mark inside are not properly escaped

What are the steps to reproduce the issue?

As an example I’ve created the following TXT record

theindra.nl.            300     IN      TXT     "test" "test" "test with \" quote"

When making a request to https://cloudflare-dns.com/dns-query?name=theindra.nl&type=TXT the following answer is returned

{
	"name": "theindra.nl",
	"type": 16,
	"TTL": 300,
	"data": "\"test\"\"test\"\"test with \" quote\""
},

Or simply

"test""test""test with " quote"

The quotation mark inside the third character strings is not properly escaped with a backslash.

As an example of it being correctly escaped, when making the same request to Quid9 the answer is as follow

{
	"name": "theindra.nl.",
	"type": 16,
	"TTL": 300,
	"Expires": "Tue, 14 Jan 2025 00:13:34 UTC",
	"data": "\"test\" \"test\" \"test with \\\" quote\""
},

The quotation mark is correctly escaped with a backslash.

4 Likes

Thanks TheIndra for this report. We will take a look.

4 Likes

Hi, we’ve updated our logic to properly escape the TXT records:

{
  "name": "theindra.nl",
  "type": 16,
  "TTL": 297,
  "data": "\"test\" \"test\" \"test with \\\" quote\""
}

Thanks for reporting this!

5 Likes

Hi Sebastiaan,

We’ve run into an issue that might be related to the recent TXT record escaping changes you implemented.
Could your team please take a look at this related community post?link

Thanks!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.

As this change has caused issues for some users, we have decided to start rolling back this change until at least March 31 2025. Starting April 2025 we will re-release this change, as it closer aligns with the expected behavior of TXT records.

4 Likes