Hackers Can Hide Security Flaws in Source Code Using New' Trojan Source' Technique

Hackers Can Hide Security Flaws in Source Code Using New’ Trojan Source’ Technique

Threat actors might use a new class of flaws to inject aesthetically misleading malware that is semantically lawful but changes the logic described by the source code, effectively exposing more first-party and supply chain risks.

The technique is nicknamed “Trojan Source attacks.” It leverages inconsistencies in text-encoding standards like Unicode to generate source code with tokens logically encoded in a different sequence than they are presented, resulting in vulnerabilities invisible to human code reviewers.

CVE-2021-42574 and CVE-2021-42694 are the tracked vulnerabilities that impact compilers for all major programming languages, including C, C++, C#, JavaScript, Java, Rust, Go, and Python.

While a compiler’s output is required to appropriately implement the source code provided, inconsistencies caused by Unicode Bidi override characters included in comments and strings might result in syntactically acceptable source code with logic that differs from the actual reasoning.

To put it another way, rather than purposely introducing logical errors, the attack targets the encoding of source code files to construct specific vulnerabilities, such as to visually reorganize tokens in source code that, although displayed legally, fools the compiler into interpreting the text differently and radically affecting the program flow — for example, making a remark look like code.

In effect, the researchers argued, we transform program A into program B. An adversary might introduce specific vulnerabilities without noticing if the logic change is small enough to go undetected in future testing.

When undetectable software vulnerabilities introduced into open-source software find their way downstream, potentially impacting all program users. Such aggressive encodings can have a significant impact on the supply chain, the researchers warn.

Far worse, if an attacker uses homoglyphs to redefine pre-existing functions in an upstream package and execute them from a victim application, Trojan Source operations can become even more severe.

Because the Trojan Source flaw affects practically all computer languages, the researchers say it’s a unique chance for a system-wide and ecologically valid cross-platform and cross-vendor comparison of remedies.

Since these tactics may be used to launch significant supply-chain attacks, it is critical for enterprises involved in the software supply chain to establish countermeasures.

About the author

CIM Team

CIM Team

CyberIntelMag is the trusted authority in cybersecurity, comprised of leading industry experts for over 20 years, dedicated to serving cybersecurity professionals. Our goal is to provide a one-stop shop for knowledge and insight needed to navigate throughout today’s emerging cybersecurity landscape through in-depth coverage of breaking news, tutorials, product reviews, videos and industry influencers.