Closed Bug 1910298 (CVE-2025-5270) Opened 2 years ago Closed 1 year ago

When I successfully enabled encrypted DNS, SNI was sometimes not encrypted

Categories

(Core :: Networking: DNS, defect, P2)

Firefox 128
defect

Tracking

()

RESOLVED FIXED
139 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox-esr128 --- wontfix
firefox135 --- wontfix
firefox136 --- wontfix
firefox137 --- wontfix
firefox138 --- wontfix
firefox139 --- fixed

People

(Reporter: 15119335479, Assigned: kershaw)

References

(Blocks 1 open bug)

Details

(4 keywords, Whiteboard: [necko-triaged] [adv-main139+])

Attachments

(3 files, 2 obsolete files)

Attached file Screenshots.7z

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Edg/127.0.0.0
Firefox for Android

Steps to reproduce:

I have enabled an encrypted DNS in Firefox 128.03 and the status says Enabled, indicating that I am using encrypted DNS. Firefox was originally designed to enable DNS-over-https, start ECH, and then SNI will be encrypted, but I tried a few times and found that sometimes SNI is not encrypted.The website I used to detect if SNI was encrypted was https://crypto.cloudflare.com/cdn-cgi/trace/。Another thing is that when I select the default protection in the encrypted DNS, the SNI must be in the plaintext state, but I set the encrypted DNS at the Windows system level, and I can detect that the SNI is encrypted in the Edge, but Firefox with the default protection enabled cannot encrypt the SNI. Isn't Firefox supposed to use the DNS in the system when the default protection is turned on, and why can't SNI be encrypted?

Actual results:

The actual result is that the SNI is in plaintext

Expected results:

The normal situation is that the SNI is encrypted, and then occasionally the SNI is not encrypted, which should be a bug that happens by chance。Attached are some screenshots

Group: firefox-core-security → core-security
Component: Untriaged → Networking: DNS
Product: Firefox → Core
Group: core-security → network-core-security
Severity: -- → S2
Priority: -- → P2
Whiteboard: [necko-triaged][necko-priority-new]

Hi reporter,

could you try to record a http log for this?
In about:logging, please select logging to file and send the file to necko@mozilla.com (the log file may contain PII, so please don't upload it to bugzilla).

Thanks.

Flags: needinfo?(15119335479)

Logs have been sent in the past

Flags: needinfo?(15119335479)

Thanks for the log.
It shows that Firefox did set ECH to the socket, so it's still not clear why ECH was not working.

2024-07-30 16:02:39.967000 UTC - [Parent 7252: Socket Thread]: D/nsSocketTransport creating nsSocketTransport @1e6f1303a00
2024-07-30 16:02:39.967000 UTC - [Parent 7252: Socket Thread]: E/nsSocketTransport nsSocketTransport::Init [this=1e6f1303a00 host=crypto.cloudflare.com:443 origin=crypto.cloudflare.com:443 proxy=:0]
2024-07-30 16:02:39.967000 UTC - [Parent 7252: Socket Thread]: D/nsHostResolver Resolving host [crypto.cloudflare.com]<^partitionKey=%28https%2Ccloudflare.com%29> type 0. [this=1e6e8bb44c0]
2024-07-30 16:02:39.967000 UTC - [Parent 7252: Socket Thread]: D/nsHostResolver   Offline request for host [crypto.cloudflare.com]; ignoring.
2024-07-30 16:02:39.967000 UTC - [Parent 7252: Socket Thread]: V/nsHttp Setting Socket to use IP hint address
2024-07-30 16:02:39.967000 UTC - [Parent 7252: Socket Thread]: D/nsSocketTransport nsSocketTransport::SetConnectionFlags 1e6f1303a00 flags=73760
2024-07-30 16:02:39.967000 UTC - [Parent 7252: Socket Thread]: D/nsSocketTransport Reset callbacks for tlsSocketInfo=0 callbacks=1e6e8bca7f0
2024-07-30 16:02:39.967000 UTC - [Parent 7252: Socket Thread]: V/nsHttp Setting ECH

Are you able to reproduce this with a clean profile? If yes, could you set the log modules to timestamp,sync,nsHttp:5,nsSocketTransport:5,nsHostResolver:5,pipnss:5 and try to record a log again?
Also, could you open a new tab and type this about:telemetry#histograms-tab_search=ech in address bar and let me know what's the result of SSL_HANDSHAKE_RESULT_ECH?

Thanks.

Flags: needinfo?(15119335479)

I copied those contents into the address bar and hit enter, which is equivalent to searching for them. But it's a pity that I can't send a screenshot here to show you

Flags: needinfo?(15119335479)

I typed about:telemetry#histograms-tab_search=ech into the address bar, and I got some results, but how do I show you the screenshot and send it to my previous email address?

The log file has been sent to the mailbox again

(In reply to xiulou from comment #5)

I typed about:telemetry#histograms-tab_search=ech into the address bar, and I got some results, but how do I show you the screenshot and send it to my previous email address?

The telemetry results do show that ECH was used successfully, so I am not sure why crypto.cloudflare.com indicates that SNI is not encrypted. I'll forward the screenshot to my colleagues and ask them to take a look.

In crypto.cloudflare.com this website, it sometimes shows that the SNI is encrypted, sometimes it shows that it is not encrypted, and about 50% of the time it shows that the SNI is not encrypted

(In reply to xiulou from comment #8)

In crypto.cloudflare.com this website, it sometimes shows that the SNI is encrypted, sometimes it shows that it is not encrypted, and about 50% of the time it shows that the SNI is not encrypted

Unfortunately, the logs you sent suggest that ECH was used successfully. It would be very helpful if you could capture a log that shows ECH not working. If you do capture it, please send the log to necko@mozilla.com again. Thanks.

Flags: needinfo?(15119335479)

It's a bit difficult, I've tried several times when I was capturing the logs, and found that the SNI sometimes encrypts successfully and sometimes doesn't, and then just sends the logs over. It stands to reason that there should be a record of SNI and no encryption in the log. You guys can try the DNS I use
https://freedns.controld.com/x-1hosts-pro

Flags: needinfo?(15119335479)

(In reply to xiulou from comment #10)

It's a bit difficult, I've tried several times when I was capturing the logs, and found that the SNI sometimes encrypts successfully and sometimes doesn't, and then just sends the logs over. It stands to reason that there should be a record of SNI and no encryption in the log. You guys can try the DNS I use
https://freedns.controld.com/x-1hosts-pro

Unfortunately, I still can't reproduce this issue. Since you mentioned there's about a 50% chance of reproducing it, could you start logging immediately after Firefox starts and then stop logging when you notice the SNI is not encrypted?

Thanks.

Severity: S2 → S3
Flags: needinfo?(15119335479)

I'll just try one last time

Flags: needinfo?(15119335479)

I've sent the log file to your mailbox

Flags: needinfo?(kershaw)
Blocks: ech
Whiteboard: [necko-triaged][necko-priority-new] → [necko-triaged][necko-priority-review]

I think this might be related to speculative connection.

Could you try to open about:config and set network.http.speculative-parallel-limit to 0 and see if you can still reproduce this?
Thanks.

Flags: needinfo?(kershaw) → needinfo?(15119335479)

I did as you said, and there is still a slight probability that SNI is not encrypted

Flags: needinfo?(15119335479)

(In reply to xiulou from comment #15)

I did as you said, and there is still a slight probability that SNI is not encrypted

It'd be very helpful if you could capture a http log again.
Could you help?
Thanks.

Flags: needinfo?(15119335479)
Assignee: nobody → kershaw
Whiteboard: [necko-triaged][necko-priority-review] → [necko-triaged][necko-priority-queue]

I've sent the log file to your email. You check it out

Flags: needinfo?(15119335479)

By including ECH as part of the connection hash key, we ensure that connections with ECH are not mixed with others.

Sorry for the delay.

I wasn’t 100% convinced that we needed this patch until I encountered bug 1947968. While reproducing the bug, I discovered a scenario where Firefox could not use ECH. This issue occurs when we receive an Alt-svc header and create a speculative connection to verify it.

2025-02-13 12:50:10.435071 UTC - [Parent 15999: Main Thread]: D/nsHttp AltSvcMapping ctor 11027c100 https://encryptedsni.com:443 to :443
2025-02-13 12:50:10.435076 UTC - [Parent 15999: Main Thread]: D/nsHttp AltSvcCache::LookupMapping 111254280 https:encryptedsni.com:443:.:^partitionKey=%28https%2Cencryptedsni.com%29:3
2025-02-13 12:50:10.435079 UTC - [Parent 15999: Main Thread]: D/nsHttp AltSvcCache::LookupMapping 111254280 MISS
2025-02-13 12:50:10.435081 UTC - [Parent 15999: Main Thread]: D/nsHttp AltSvcCache::UpdateAltServiceMapping 111254280 map 11027c100 existing 0 encryptedsni.com validated=0
2025-02-13 12:50:10.435092 UTC - [Parent 15999: Main Thread]: V/nsHttp Init nsHttpConnectionInfo @1613f13f0
2025-02-13 12:50:10.435098 UTC - [Parent 15999: Main Thread]: D/nsHttp AltSvcCache::UpdateAltServiceMapping 111254280 validation via speculative connect started
2025-02-13 12:50:10.435101 UTC - [Parent 15999: Main Thread]: D/nsHttp AltSvcMappingValidator ctor 10e947040 map 11027c100 [encryptedsni.com -> encryptedsni.com]

In AltSvcTransaction, we directly attempt to create an HTTP/3 connection without first performing a lookup for an HTTPS record, which results in the new connection not using ECH.

2025-02-13 12:50:10.436107 UTC - [Parent 15999: Socket Thread]: I/nsHttp Http3Session::Init origin=encryptedsni.com, alpn=h3, selfAddr=0.0.0.0, peerAddr=104.22.73.170, qpack table size=65536, max blocked streams=20 webtransport=0 [this=15d4aab00]
2025-02-13 12:50:10.436228 UTC - [Parent 15999: Socket Thread]: V/nsHttp Http3Session::DoSetEchConfig 15d4aab00 of length 0

I believe it would still be worthwhile to include ECH as part of the connection hash key. This way, whenever ECH changes, we’ll always create a new connection.

Pushed by kjang@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/ebe2678e73a4 Make EchConfig a part of the connection hash key, r=necko-reviewers,valentin
Group: network-core-security → core-security-release
Status: UNCONFIRMED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 137 Branch

:kershaw could you add uplift requests for esr128 and beta?

Attachment #9467046 - Flags: approval-mozilla-esr128?

esr128 Uplift Approval Request

  • User impact if declined: In some rare cases, ECH might not be used for connections.
  • Code covered by automated testing: yes
  • Fix verified in Nightly: yes
  • Needs manual QE test: no
  • Steps to reproduce for manual QE testing: N/A
  • Risk associated with taking this patch: Low
  • Explanation of risk level: Low risk, since this patch is straightforward.
  • String changes made/needed: N/A
  • Is Android affected?: yes

I’m only requesting an ESR128 uplift since I believe this patch fixes only some corner cases, not common ones. It should be fine to let this patch ride the train to release.

Flags: needinfo?(kershaw)

The patch landed in nightly and beta is affected.
:kershaw, is this bug important enough to require an uplift?

  • If yes, please nominate the patch for beta approval.
  • If no, please set status-firefox136 to wontfix.

For more information, please visit BugBot documentation.

Flags: needinfo?(kershaw)
Flags: needinfo?(kershaw)
QA Whiteboard: [post-critsmash-triage]
Attachment #9467046 - Attachment is obsolete: true
Attachment #9467046 - Flags: approval-mozilla-esr128?

Is this ready for ESR128 uplift now?

Flags: needinfo?(kershaw)

(In reply to Ryan VanderMeulen [:RyanVM] from comment #27)

Is this ready for ESR128 uplift now?

No. Apparently this patch caused a regression, so we plan to revert this change.
We'll try a different approach and put this behind a pref to mitigate the risk.

Flags: needinfo?(kershaw)
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: FIXED → ---
Target Milestone: 137 Branch → ---
Whiteboard: [necko-triaged][necko-priority-queue] → [necko-triaged]

The ECH issue mentioned in comment #0 should be resolved by bug 1953078, so I think we can close this bug.

The patch that landed (and was later reverted) attempted to include the ECH key as part of the connection info hash. However, it introduced a regression in the ECH success rate.

Since the main issue is already addressed, I suggest we close this bug and file a new one to investigate the ECH success rate regression.

Status: REOPENED → RESOLVED
Closed: 1 year ago1 year ago
Resolution: --- → FIXED
Depends on: 1953078
Target Milestone: --- → 139 Branch
QA Whiteboard: [post-critsmash-triage] → [post-critsmash-triage] [qa-triage-done-c140/b139]
Whiteboard: [necko-triaged] → [necko-triaged] [adv-main139+]
Attached file advisory.txt (obsolete) —
Attached file advisory.txt
Attachment #9490204 - Attachment is obsolete: true
Group: core-security-release
Alias: CVE-2025-5270
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: