I have deployed my application on JBoss 6.x EAP. After enabling security manager, deployment fails with following exception.
Caused by: java.security.AccessControlException: access denied ("org.jboss.vfs.VirtualFilePermission" "/E:/Servers/jboss-eap-6.4.0/jboss-eap-6.4/standalone/deployments/eQubeMI.war/WEB-INF/lib/spring-web-4.1.9.RELEASE.jar/org/springframework/web/context/ContextLoader.properties" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472) [rt.jar:1.8.0_101]
at java.security.AccessController.checkPermission(AccessController.java:884) [rt.jar:1.8.0_101]
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549) [rt.jar:1.8.0_101]
at org.jboss.vfs.VirtualFile.openStream(VirtualFile.java:248) [jboss-vfs-3.2.9.Final-redhat-1.jar:3.2.9.Final-redhat-1]
at org.jboss.as.server.deployment.module.VFSResourceLoader$VFSEntryResource.openStream(VFSResourceLoader.java:329)
at org.jboss.modules.Module.getResourceAsStream(Module.java:637) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ModuleClassLoader.findResourceAsStream(ModuleClassLoader.java:587) [jboss-modules.jar:1.3.6.Final-redhat-1]
at org.jboss.modules.ConcurrentClassLoader.getResourceAsStream(ConcurrentClassLoader.java:362) [jboss-modules.jar:1.3.6.Final-redhat-1]
at java.lang.Class.getResourceAsStream(Class.java:2223) [rt.jar:1.8.0_101]
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:163) [spring-core-4.1.9.RELEASE.jar:4.1.9.RELEASE]
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:132) [spring-core-4.1.9.RELEASE.jar:4.1.9.RELEASE]
at org.springframework.core.io.support.PropertiesLoaderUtils.loadProperties(PropertiesLoaderUtils.java:121) [spring-core-4.1.9.RELEASE.jar:4.1.9.RELEASE]
at org.springframework.web.context.ContextLoader.<clinit>(ContextLoader.java:176) [spring-web-4.1.9.RELEASE.jar:4.1.9.RELEASE]
I have followed steps mentioned in security guide: https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6.4/html/Security_Guide/Run_JBoss_Enterprise_Application_Platform_Within_the_Java_Security_Manager.html
I have attached standalone.conf.bat and server.policy file for reference.
Standalone.conf.bat
if not "x%JAVA_OPTS%" == "x" (
echo "JAVA_OPTS already set in environment; overriding default settings with values: %JAVA_OPTS%"
goto JAVA_OPTS_SET
)
rem # JVM memory allocation pool parameters - modify as appropriate.
set "JAVA_OPTS=%JAVA_OPTS% -Xms1G -Xmx3G -XX:MaxPermSize=512M"
rem # Prefer IPv4
set "JAVA_OPTS=%JAVA_OPTS% -Djava.net.preferIPv4Stack=true"
rem # Set the jboss.modules.policy-permissions property to true by default.
set "JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.policy-permissions=true "
rem # Make Byteman classes visible in all module loaders
rem # This is necessary to inject Byteman rules into AS7 deployments
set "JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.system.pkgs=org.jboss.byteman"
rem # Sample JPDA settings for remote socket debugging
set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n"
rem # Sample JPDA settings for shared memory debugging
rem set "JAVA_OPTS=%JAVA_OPTS% -agentlib:jdwp=transport=dt_shmem,address=jboss,server=y,suspend=n"
rem # Use JBoss Modules lockless mode
rem set "JAVA_OPTS=%JAVA_OPTS% -Djboss.modules.lockless=true"
rem # Uncomment this to run with a security manager enabled
set "SECMGR=true"
set "JAVA_OPTS=%JAVA_OPTS% -Djboss.home.dir=%JBOSS_HOME% -Djava.security.policy==%JBOSS_HOME%/bin/server.policy -Djava.security.debug=failure"
echo %JAVA_OPTS%
:JAVA_OPTS_SET
server.policy
/* AUTOMATICALLY GENERATED ON Mon Jul 17 18:54:06 IST 2017*/
/* DO NOT EDIT */
grant codeBase "file:E:/Servers/jboss-eap-6.4.0/jboss-eap-6.4/standalone/deployments/eQubeMI.war/lib/-" {
permission java.security.AllPermission;
permission java.io.FilePermission "<<ALL FILES>>", "read";
permission java.io.FilePermission "<<ALL FILES>>", "write";
permission org.jboss.vfs.VirtualFilePermission "*", "read";
permission org.jboss.vfs.VirtualFilePermission "*", "write";
};
grant codeBase "file:E:/Servers/jboss-eap-6.4.0/jboss-eap-6.4/standalone/deployments/eQubeMI.war/-" {
permission java.security.AllPermission;
permission java.io.FilePermission "<<ALL FILES>>", "read";
permission java.io.FilePermission "<<ALL FILES>>", "write";
permission org.jboss.vfs.VirtualFilePermission "*", "read";
permission org.jboss.vfs.VirtualFilePermission "*", "write";
};
Please let me know if I have missed any steps or is it server issue.
Thanks in advance..
You need to grant to codeBase other than the two in your server.policy, use "-Djava.security.debug=access,failure,policy" to find what are the other codeBases, search for "Active CodeSource" in the log file. See for example https://developer.jboss.org/wiki/JBossAS7SecurityRunningUnderAJavaSecurityManager