The security hole left with JNDI for server resources
In Java world, JNDI (Java Naming and Directory Interface) is one very common method for applications to access server resources like data sources, EJB's, JMS queues, file stores etc.
The security risk is that: Not only JNDI can be called by applications hosted in the same container, but also remotely.
In an organization, application server admins do not take care of security risks unknowingly or neglect by assuming they or on a secure LAN. This exposes the resources to grave risk as anyone within LAN can access unauthorized data without being detected and abuse the system.
So one can query the database just by knowing three things.
Provider URL is the URL of the container, also provide the port of the container.
Datasource name is little tricky to know, but assume you know it (by guessing it, by asking or by reading it from some other place), you can connect to database without knowing database username and password.
Server administrators need to set following parameters to avoid this kind of bypass
The security risk is that: Not only JNDI can be called by applications hosted in the same container, but also remotely.
In an organization, application server admins do not take care of security risks unknowingly or neglect by assuming they or on a secure LAN. This exposes the resources to grave risk as anyone within LAN can access unauthorized data without being detected and abuse the system.
ctx = null; Properties env = new Properties(); env.put(Context.INITIAL_CONTEXT_FACTORY, "CONTEXT_FACTORY"); env.put(Context.PROVIDER_URL, "CONTEXT_PROVIDER_URL"); DataSource datasource = (DataSource)initialContext.lookup("DATASOURCE_CONTEXT_NAME"); try { ctx = new InitialContext(env); Connection conn = datasource.getConnection(); //perfrom queries with the connection conn.close(); } catch (Exception e) { e.printStackTrace(); }
So one can query the database just by knowing three things.
- Context.INITIAL_CONTEXT_FACTORY : this is container object reference
- Context.PROVIDER_URL : remote url of the container
- DATASOURCE_CONTEXT_NAME : name of the datasource configured in container
Provider URL is the URL of the container, also provide the port of the container.
Datasource name is little tricky to know, but assume you know it (by guessing it, by asking or by reading it from some other place), you can connect to database without knowing database username and password.
Server administrators need to set following parameters to avoid this kind of bypass
Context.SECURITY_PRINCIPAL
Context.SECURITY_CREDENTIALS
This attack is limited in Intranet environment only.
Comments
Post a Comment