---
title: "Google Chrome 69 地址欄隱藏子域名後暴露的安全問題"
description: "這裡是說多功能框（地址欄），會自動隱藏和不重要的子域名。而這些部分在編輯地址欄的時候會重新出現。"
slug: "google-chrome-69-url-hidden-www-security-issue"
date: 2018-09-07T03:48:03.125Z
url: https://calpa.me/blog/google-chrome-69-url-hidden-www-security-issue/
tags: ["GoogleChrome", "地址欄", "安全", "Mac"]
---

> ⚠️ **時效警告**：本文發佈於 2018 年，記錄的是 Chrome 69 當時的行為（Google 其後已回滾，改回顯示完整網址，文中 `chrome://flags` 的開關也已被移除）。內容保留作為歷史紀錄，最新做法請參考官方文件。

## 瀏覽器隱藏域名

> In the Omnibox, hide the scheme and **trivial** subdomains from steady state displayed URLs. Hidden portions are restored during editing. For Mac, this flag will have no effect unless MacViews is enabled. - Mac, Windows, Linux, Chrome OS, Android

這裡是說多功能框（地址欄），會自動隱藏 `scheme` 和不重要的子域名。而這些部分在編輯地址欄的時候會重新出現。

## 問題

然而，瀏覽器隱藏 `https://www` 這個字時，不完整的 url 讓我們無法識別一些網站的正確性，比如說以下的這些例子：

| 網站             | 正確                        | 錯誤                | 顯示             |
| ---------------- | --------------------------- | ------------------- | ---------------- |
| NTP Pool Project | http://www.pool.ntp.org     | pool.ntppool.org    | pool.ntppool.org |
| citibank         | https://www.citibank.com.sg | citibank.com.sg     | citibank.com.sg  |
| tumblr           | https://www.tumblr.com/     | https://web.archive.org/web/20230321051506/https://m.tumblr.com/ | tumblr.com       |

![tumblr.com](/images/blog/google-chrome-69-url-hidden-www-security-issue/unsplash-c5249f4df085-qNfNkxV.jpg)

可能你會覺得用戶會很小心地輸入域名，所以隱藏子域名不會構成問題，那麼下面這個例子就是一個很大的問題了：

`http://www.example.www.example.com/` 會被縮寫為 `example.example.com`

![example.com](/images/blog/google-chrome-69-url-hidden-www-security-issue/unsplash-c5249f4df085-xIc1KVo.jpg)

頂部的地址欄會把`www`前面的都刪去，只顯示後面的字，無論是怎麼說，兩個 url 根本不一樣的。

## 解決方法

1. 手動在地址欄輸入`chrome://flags/#omnibox-ui-hide-steady-state-url-scheme-and-subdomains` 禁止 `Omnibox UI Hide Steady-State URL Scheme and Trivial Subdomains`

![chrome://flags/#omnibox-ui-hide-steady-state-url-scheme-and-subdomains](/images/blog/google-chrome-69-url-hidden-www-security-issue/unsplash-c5249f4df085-TrZNfdQ.jpg)

2. 加入討論，改變 Chrome 的默認做法

## 後記

Google Chrome 還是蠻多人用的，一更新就有很多人馬上更新了。我也不例外，雖然是看到地址欄的時候感覺怪怪的，但是沒有做過邊際測試的話，還是沒有發現這個問題的。

如果你有什麼想法的話，可以到 Hacker News 裡面留言，或者在下方留言。

## 參考資料

1. [Incorrect transforms when stripping subdomains - Issue 881410](https://bugs.chromium.org/p/chromium/issues/detail?id=881410)
2. [Chrome 69: “www.” subdomain missing from URL - Hacker News](https://news.ycombinator.com/item?id=17927972)
