Advanced Phishing Attack Conceals JavaScript with Invisible Unicode Trick

Explore how a phishing attack hides JavaScript using an invisible Unicode trick to bypass security & compromise systems.

Explore how a phishing attack hides JavaScript using an invisible Unicode trick to bypass security & compromise systems.

Tuesday 25 February, 2025

Phishing Attack - Cyberware Hub
Phishing Attack - Cyberware Hub
Phishing Attack - Cyberware Hub

Phishing attacks are becoming sophisticated, and cybercriminals are coming up with new methods to conceal malicious scripts. One of those methods is using invisible Unicode characters to conceal JavaScript code so that it becomes impossible for security tools or even human auditors to detect. This sneaky tactic can overcome conventional security measures, making it a looming threat for web security.

In this blog, we will discuss how attackers utilize invisible Unicode characters in JavaScript, why this attack is risky, and how you can defend yourself against such threats.

How the Invisible Unicode Trick Works?

  1. Understanding Zero-Width Unicode Characters

Unicode includes several zero-width characters that are invisible to the human eye but still exist in text. These characters, often used for text formatting, can be exploited in phishing attacks to disguise malicious JavaScript code. Some commonly used zero-width characters include:

Zero-width space ()
Zero-width non-joiner ()
Zero-width joiner ()
Left-to-right mark ()
  1. Hiding Malicious Code

Attackers insert zero-width Unicode characters inside JavaScript keywords and function names to disguise malicious code. This makes it appear harmless while still functioning correctly when executed by a browser.

For example, consider the following phishing script:

var document = "malicious_data";
console.log(d‎ocument); // Still prints "malicious_data"

Here, the document object (which provides access to sensitive user data) is split using a zero-width space (), 
making it difficult for security scanners to detect

  1. Evading Security Tools

Many security scanners detect suspicious keywords such as:

> document
> window
> eval
> fetch

However, by inserting zero-width characters, attackers make these keywords unrecognizable to traditional scanners, allowing malicious scripts to bypass security filters.

Why This Is Dangerous?

  • Conceals Malicious Code:

    Attackers can insert phishing scripts that siphon user information (e.g., login credentials, session tokens) without triggering alarms.

  • Hard to Detect Manually:

    Not even human auditors might catch the Unicode trick unless they take a close look at the raw source code.

  • Can Be Deployed via Emails or Web Pages:

    Phishers can employ this trick in HTML emails, JavaScript code, or web page scripts to hide malicious payloads.

How to Protect Against Unicode-Based Attacks?

1. Use Unicode-Aware Security Tools

Old security scanners can miss Unicode manipulation. Make sure security tools are updated to normalize and detect invisible Unicode characters.

2. Normalize and Sanitize Code

Remove any invisible or non-ASCII Unicode characters before running or analyzing JavaScript. Clean code efficiently using Python:

python
import unicodedata
def remove_invisible_chars(text):
```
return ''.join(c for c in text if unicodedata.category(c)[0]!= 'C')

script = "d​ocument.write('Hacked!');"
clean_script = remove_invisible_chars(script)
print(clean_script)  # Outputs: document.write('Hacked!');

3. Manually Inspect Suspicious Scripts

If a script looks safe but still suspicious, translate it into a hex or Unicode representation in order to pick up on stealthy characters.

4. Inform Users of Phishing Risks

Users need to know the methods through which the attackers utilize JavaScript obfuscation within phishing attacks. 

  • Refrain from executing unknown scripts.

  • Check webpage source code when something does not look right.

  • Employ browser security plugins for spotting phishing attempts.

Conclusion:

Invisible Unicode characters in JavaScript phishing attacks are a sneaky and efficient method that evades conventional security controls. Zero-width characters are used by attackers to hide malicious code, which is more difficult for both users and automated scanners to identify.

To remain safe, always scan, normalize, and check JavaScript code prior to execution. As cyber threats keep changing, awareness and active security controls are our best line of defense.

Be Safe and Be Vigilant !!