SSD Advisory – Apple Safari IDN URL Spoofing
Safari did not convert a particular Canadian Syllabics character (U+15AF) to Punycode in the URL bar, so a hostname containing it could be displayed looking like an ordinary Latin letter. An attacker could use this to make a phishing link appear to point at a trusted site while actually going elsewhere.
Published on ssd-disclosure.com
Bad handling by Apple Safari allows attackers to use certain look-alike characters instead of the real ones to confuse victims into thinking they are reach a certain site, while they are accessing another one.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Apple Safari renders the address bar from the URL the user navigated to, and for internationalised domain names (IDNs) it applies a set of lookalike checks before deciding whether to display the Unicode form of a host or its Punycode (xn--) form. The purpose of those checks is to stop a host that mixes scripts, or that uses characters visually confusable with Latin letters, from being shown in a form that misleads the user about where they are.
This report describes a failure of that handling in Safari: certain Unicode characters were not converted to Punycode in the URL bar, so a crafted host could be displayed with a character that looks like an ordinary Latin letter. The researcher is Dohyun Lee of SSD Labs (Korea), and the issue was published through the SSD Secure Disclosure program on 27 July 2022 under CVE-2022-32816.
Setup
The affected versions listed in the advisory are:
- iOS 15.6 or iPadOS 15.6 before
- Monterey 12.5 before
- watchOS 8.7 before
- tvOS 15.6 before
No account, role or special tooling is described. The proof of concept is a single HTML page opened in Safari, and the analysis is of the WebKit source that implements the lookalike checks.
Finding it
The specific character at issue is 0x15AF, CANADIAN SYLLABICS AIVILIK B. In Safari's URL bar it was not converted to Punycode, and the character looks similar to the lowercase English letter b. Because the URL bar showed the Unicode character rather than the encoded form, an attacker could register a domain whose host, as displayed, reads like a familiar name while actually resolving to a different site.
The advisory frames the consequence directly: bad handling lets attackers use look-alike characters instead of the real ones to confuse victims into thinking they have reached a certain site while they are accessing another one. The stated use of the flaw is phishing.
Exploitation
Step 1: serve a page that navigates to the crafted host
The proof of concept is an HTML page with a button that sends the browser to a Punycode host:
<html>
<head>
<title>Apple Safari IDN URL Spoofing Proof of Concept - SSD Labs</title>
</head>
<body>
<button onclick="trigger()">Trigger!</button>
<script>
function trigger() {
window.location = "http://xn--youtue-084a.com/";
}
</script>
</body>
</html>
The window.location assignment navigates to http://xn--youtue-084a.com/. The window.location assignment navigates to http://xn--youtue-084a.com/, a Punycode host. The advisory does not spell out which character of the decoded host is the look-alike. The victim is shown a host in Unicode form while the browser is at the attacker's domain.
Step 2: the user is deceived
Once the navigation completes, the misleading URL bar is the whole of the attack surface: the victim reads the displayed host as the site they intended to visit. The advisory does not describe any further page content, credential capture or server-side behaviour; the deception of the URL bar is the demonstrated result.
Root cause
WebKit decides whether a host is a spoofing risk through lookalike checks in Source/WTF/wtf/URLHelpers.cpp. The relevant logic is a set of per-script specialisations of isLookalikeCharacterOfScriptType, combined by isLookalikeSequence in isLookalikeCharacter. Before the fix, the default branch of isLookalikeCharacter checked Armenian and Tamil sequences but not Canadian Aboriginal ones:
return isLookalikeSequence<USCRIPT_ARMENIAN>(previousCodePoint, codePoint)
|| isLookalikeSequence<USCRIPT_TAMIL>(previousCodePoint, codePoint);
Canadian Aboriginal syllabics were not covered, so 0x15AF was not converted to Punycode in the URL bar. The advisory notes that there is no root cause code line for this vulnerability; Apple's solution was a patch that converts the character to Punycode in the URL bar.
Impact
An attacker can make Safari's URL bar display a host that reads like a legitimate site while the browser is at a different domain, which supports phishing. The advisory limits itself to that: exploitation could allow an attacker to use the vulnerability for phishing. It does not describe theft of credentials, code execution or any other outcome, and no severity or CVSS score is given.
Fix
Apple addressed the issue in iOS 15.6 and iPadOS 15.6. The patch, Subversion revision 292721, adds a Canadian Aboriginal specialisation that flags 0x15AF and wires it into the sequence check:
+template<> bool isLookalikeCharacterOfScriptType<USCRIPT_CANADIAN_ABORIGINAL>(UChar32 codePoint)
+{
+ switch (codePoint) {
+ case 0x15AF: /* CANADIAN SYLLABICS AIVILIK B */
+ return true;
+ default:
+ return false;
+ }
+}
return false;
default:
return isLookalikeSequence<USCRIPT_ARMENIAN>(previousCodePoint, codePoint)
- || isLookalikeSequence<USCRIPT_TAMIL>(previousCodePoint, codePoint);
+ || isLookalikeSequence<USCRIPT_TAMIL>(previousCodePoint, codePoint)
+ || isLookalikeSequence<USCRIPT_CANADIAN_ABORIGINAL>(previousCodePoint, codePoint);
}
The commit title reads: Punycode encode U+15AF when not in context of other Canadian aboriginal code points. The accompanying test changes add the spoofed hosts to the list of hosts expected to be Punycode encoded:
+ "xn--a-53i"_s, // U+15AF 'a'
+ "xn--a-63i"_s, // 'a' U+15AF
and add a test case for a host containing 0x15AF alongside another Canadian Aboriginal code point:
+ // Canadian aboriginal
+ EXPECT_STREQ("https://\u15AF\u1401abc/", userVisibleString(literalURL("https://\u15AF\u1401abc/")));
In short, the fix converts this Unicode character to Punycode in the URL bar.
Variants to test
- Other characters in scripts that WebKit's lookalike tables do not yet cover. A positive result is a host that Safari displays in Unicode form even though one of its characters is confusable with a Latin letter, while the same host in another browser is shown as
xn--. - Characters adjacent to
0x15AFin Canadian Aboriginal syllabics, to see whether the new specialisation is narrow to that single code point. A positive result is a look-alike host that still renders in Unicode after the fix. - Mixed-script hosts that combine a covered script with an uncovered one, to check whether the sequence logic can be bypassed by context. A positive result is a displayed host that reads as a familiar name but resolves elsewhere.
- The same navigation in browsers other than Safari, to establish whether the behaviour is specific to WebKit's URL bar handling. A positive result is a divergence in the displayed host between browsers for the same URL.
What happened, in plain words
Every website has an address, called a URL, and your browser shows that address in a bar at the top of the window. When you type or click a link, you glance at that bar to check you are where you think you are. This report is about a way to make that bar lie to you in Apple's Safari browser.
Web addresses were designed for plain English letters, digits and a few punctuation marks. To let people use addresses in other writing systems, such as Arabic, Chinese or Canadian Aboriginal syllabics, the system uses a translation called Punycode. A Punycode address starts with xn-- and is a machine-friendly encoding of the real, human-readable name. Browsers normally do the reverse translation for display: they take the xn-- form and show you the friendly characters in the address bar.
That display step is where the danger lives. Some characters from other writing systems look almost exactly like ordinary English letters. If a browser shows such a character in the address bar, you can read a familiar name while the browser is actually at a completely different site. Security people call this URL spoofing, and its usual purpose is phishing: tricking you into entering a password or payment details on a fake page.
Safari has a set of checks meant to catch these look-alike characters and refuse to show them in friendly form, falling back to the xn-- version instead. This report describes a character that slipped past those checks: 0x15AF, a Canadian Aboriginal syllabics character called CANADIAN SYLLABICS AIVILIK B, which looks like the lowercase English letter b. Safari displayed it as-is in the address bar instead of converting it to Punycode, so a crafted domain could appear to be a familiar site.
The researcher is Dohyun Lee of SSD Labs (Korea). The issue was published through the SSD Secure Disclosure program on 27 July 2022 under the identifier CVE-2022-32816. A CVE is a public catalogue number given to a known security flaw so people can track it.
Setup
The advisory lists these affected versions:
- iOS 15.6 or iPadOS 15.6 before
- Monterey 12.5 before
- watchOS 8.7 before
- tvOS 15.6 before
In plain terms, the flaw was present in Safari on iPhones, iPads and Macs running versions older than those, and on Apple Watch and Apple TV software older than the listed versions. No account, special role or extra tool is needed to reproduce it: the proof of concept is a single web page opened in Safari, and the analysis looks at the source code of WebKit, the engine inside Safari that renders pages and handles addresses.
Finding it
The character at issue is 0x15AF, CANADIAN SYLLABICS AIVILIK B. The number 0x15AF is a code point: a unique number assigned to every character in the Unicode standard, which is the universal catalogue of characters from all writing systems. In Safari's address bar this character was not converted to Punycode, and it looks similar to the lowercase English letter b.
Because the address bar showed the raw Unicode character instead of the encoded form, an attacker could register a domain whose displayed name reads like a familiar brand while actually pointing at a different server. The advisory states the consequence directly: bad handling lets attackers use look-alike characters instead of the real ones to confuse victims into thinking they have reached a certain site while they are accessing another one. The stated use of the flaw is phishing.
Exploitation
Step 1: serve a page that navigates to the crafted host
The proof of concept is a small web page containing a button. When the visitor clicks it, the browser is sent to a Punycode address:
<html>
<head>
<title>Apple Safari IDN URL Spoofing Proof of Concept - SSD Labs</title>
</head>
<body>
<button onclick="trigger()">Trigger!</button>
<script>
function trigger() {
window.location = "http://xn--youtue-084a.com/";
}
</script>
</body>
</html>
Line by line:
<html>opens the document, and<head>holds information about the page rather than visible content.<title>...</title>sets the text shown in the browser tab. Here it names the proof of concept and SSD Labs.</head>closes the head section and<body>opens the part the visitor sees.<button onclick="trigger()">Trigger!</button>draws a button labelled Trigger!. Theonclickattribute says: when this button is clicked, run the JavaScript function calledtrigger.<script>starts a block of JavaScript, the programming language browsers run inside pages.function trigger() {defines that function.window.location = "http://xn--youtue-084a.com/";is the heart of it.window.locationis the browser's current address; assigning a new value to it tells the browser to navigate there. The addresshttp://xn--youtue-084a.com/uses thexn--prefix, which marks the host as Punycode, so the browser decodes it to its Unicode form for display.- The closing braces and tags end the function, the script, the body and the document.
The address http://xn--youtue-084a.com/ uses the xn-- prefix, which marks the host as Punycode. The advisory does not spell out which character of the decoded host is the look-alike.
Step 2: the user is deceived
Once the navigation completes, the misleading address bar is the whole of the attack. The victim reads the displayed host as the site they intended to visit. The advisory does not describe any further page content, credential capture or server-side behaviour; the deception of the address bar is the demonstrated result.
Root cause
WebKit decides whether a host is a spoofing risk through look-alike checks in a source file called Source/WTF/wtf/URLHelpers.cpp. The relevant logic is a set of per-script specialisations of a function named isLookalikeCharacterOfScriptType, combined by isLookalikeSequence inside isLookalikeCharacter. A function is a named block of code that does one job; a specialisation is a version of it tailored to one writing system.
Before the fix, the default branch of isLookalikeCharacter checked Armenian and Tamil sequences but not Canadian Aboriginal ones:
return isLookalikeSequence<USCRIPT_ARMENIAN>(previousCodePoint, codePoint)
|| isLookalikeSequence<USCRIPT_TAMIL>(previousCodePoint, codePoint);
This says: treat the character as a look-alike if it forms a suspicious sequence in the Armenian script, or in the Tamil script. The || means "or". Canadian Aboriginal syllabics were not covered, so 0x15AF was not converted to Punycode in the address bar. The advisory notes that there is no root cause code line for this vulnerability; Apple's solution was a patch that converts the character to Punycode in the URL bar.
Impact
An attacker can make Safari's address bar display a host that reads like a legitimate site while the browser is at a different domain, which supports phishing. The advisory limits itself to that: exploitation could allow an attacker to use the vulnerability for phishing. It does not describe theft of credentials, code execution or any other outcome, and no severity or CVSS score is given. CVSS is a standard scoring system for rating how serious a vulnerability is.
Fix
Apple addressed the issue in iOS 15.6 and iPadOS 15.6. The patch, Subversion revision 292721, adds a Canadian Aboriginal specialisation that flags 0x15AF and wires it into the sequence check:
+template<> bool isLookalikeCharacterOfScriptType<USCRIPT_CANADIAN_ABORIGINAL>(UChar32 codePoint)
+{
+ switch (codePoint) {
+ case 0x15AF: /* CANADIAN SYLLABICS AIVILIK B */
+ return true;
+ default:
+ return false;
+ }
+}
In plain words: this adds a new version of the look-alike check for the Canadian Aboriginal script. It takes a character code and, using a switch (a list of cases), returns true when the code is 0x15AF and false for anything else. Returning true means "this is a look-alike, so do not show it in friendly form". The + signs at the start of each line are the usual notation in a code change for lines that were added.
return false;
default:
return isLookalikeSequence<USCRIPT_ARMENIAN>(previousCodePoint, codePoint)
- || isLookalikeSequence<USCRIPT_TAMIL>(previousCodePoint, codePoint);
+ || isLookalikeSequence<USCRIPT_TAMIL>(previousCodePoint, codePoint)
+ || isLookalikeSequence<USCRIPT_CANADIAN_ABORIGINAL>(previousCodePoint, codePoint);
}
Here the line ending in a minus sign is removed and the two lines starting with plus signs are added. The effect is that the check now also asks whether the character forms a suspicious sequence in the Canadian Aboriginal script, alongside the existing Armenian and Tamil checks.
The commit title reads: Punycode encode U+15AF when not in context of other Canadian aboriginal code points.
The accompanying test changes add the spoofed hosts to the list of hosts expected to be Punycode encoded:
+ "xn--a-53i"_s, // U+15AF 'a'
+ "xn--a-63i"_s, // 'a' U+15AF
These two lines add test cases to a list of hosts that the test suite expects to be encoded. The comments note that each host mixes the 0x15AF character with the letter a, in one order or the other. Tests are automated checks that run after every code change to confirm the behaviour stays correct.
and add a test case for a host containing 0x15AF alongside another Canadian Aboriginal code point:
+ // Canadian aboriginal
+ EXPECT_STREQ("https://\u15AF\u1401abc/", userVisibleString(literalURL("https://\u15AF\u1401abc/")));
This test builds an address containing 0x15AF next to another character, \u1401, and checks that the browser's display function returns it unchanged. EXPECT_STREQ is a test instruction meaning "expect these two strings to be equal".
In short, the fix converts this Unicode character to Punycode in the address bar.
Variants to test
- Other characters in scripts that WebKit's look-alike tables do not yet cover. A positive result is a host that Safari displays in Unicode form even though one of its characters is confusable with a Latin letter, while the same host in another browser is shown as
xn--. - Characters adjacent to
0x15AFin Canadian Aboriginal syllabics, to see whether the new specialisation is narrow to that single code point. A positive result is a look-alike host that still renders in Unicode after the fix. - Mixed-script hosts that combine a covered script with an uncovered one, to check whether the sequence logic can be bypassed by context. A positive result is a displayed host that reads as a familiar name but resolves elsewhere.
- The same navigation in browsers other than Safari, to establish whether the behaviour is specific to WebKit's address bar handling. A positive result is a divergence in the displayed host between browsers for the same URL.
Glossary
- URL: the address of a resource on the web, such as
http://example.com/. - Address bar: the field at the top of a browser window that shows the current URL.
- IDN (internationalised domain name): a domain name that uses characters from writing systems other than plain English letters.
- Punycode: the encoding that represents non-English characters in a domain name using only letters, digits and hyphens, always starting with
xn--. - Unicode: the universal standard that assigns a number to every character in every writing system.
- Code point: the number Unicode assigns to a character, written here in hexadecimal such as
0x15AF. - Hexadecimal: a number system with sixteen digits (0 to 9 and A to F), often used to write character codes.
- URL spoofing: making a web address look like one site while actually pointing at another.
- Phishing: tricking someone into trusting a fake page, usually to steal passwords or payment details.
- Look-alike character: a character from one writing system that closely resembles a letter from another, such as
0x15AFresemblingb. - CVE: a public catalogue number for a known security vulnerability, here CVE-2022-32816.
- CVSS: a standard scoring system for rating the severity of a vulnerability.
- WebKit: the browser engine that Safari uses to render pages and handle addresses.
- JavaScript: the programming language browsers run inside web pages.
- Function: a named block of code that performs one task and can be called by name.
- Specialisation: a version of a piece of code tailored to one particular case, here one writing system.
- Script (writing system): a set of characters used to write a language, such as Latin, Armenian, Tamil or Canadian Aboriginal syllabics.
- Sequence: two or more characters considered together rather than one at a time.
- Patch: a code change that fixes a problem.
- Subversion revision: an identifier for a saved version of a code repository.
- Commit message: the short description attached to a code change explaining what it does.
- Test: an automated check that confirms code behaves as expected.
- Proof of concept (PoC): a small demonstration that shows a vulnerability is real.