Liferay Issues

  • Log In Access more options
    • Online Help
    • GreenHopper Help
    • Agile Answers
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What’s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • Agile Access more options (Alt+g)
  • Test Sessions Access more options
    • Getting Started
PUBLIC - Liferay Portal Community Edition
  • PUBLIC - Liferay Portal Community Edition
  • LPS-30766

PACL, issue with SecurityManager

  • Agile Board
  • More Actions
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 6.1.1 CE GA2, 6.1.20 EE GA2
  • Fix Version/s: 6.1.X EE, 6.2.0 CE M4
  • Component/s: Security, Security > PACL
  • Labels:
    • QA-R
  • Branch Version/s:
    6.1.x
  • Backported to Branch:
    Committed
  • Similar Issues:
    Show 5 results 

    LPS-26321PACL
    LPS-33058PACL - Rename PACLClassLoaderUtil to ClassLoaderUtil to begin uncluttering the portal of PACL naming
    LPS-3090Custom SecurityManager for debugging purposes
    LPS-32200As a Liferay Marketplace Developer, it should be less time consuming and less error prone to identify and declare necessary PACL declarations
    LPS-35534solr-web fails to deploy if a PACL-enabled plugin had been deployed before it

Description

I faced a problem with SecurityChecker and PACL.
In my plugin I have the code:
Mac mac = Mac.getInstance("HMACSHA1");

If security manager is enabled it throws the exception:
java.lang.SecurityException: Attempted to putProviderProperty.SUN on
at com.liferay.portal.security.pacl.checker.BaseChecker.throwSecurityException(BaseChecker.java:259)
at com.liferay.portal.security.pacl.checker.SecurityChecker.checkPermission(SecurityChecker.java:52)
at com.liferay.portal.security.pacl.ActivePACLPolicy.checkPermission(ActivePACLPolicy.java:55)
at com.liferay.portal.security.lang.PortalSecurityManager.checkPermission(PortalSecurityManager.java:103)
at com.liferay.portal.security.lang.PortalSecurityManager.checkPermission(PortalSecurityManager.java:74)
at java.lang.SecurityManager.checkSecurityAccess(SecurityManager.java:1698)
at java.security.Provider.check(Provider.java:386)
at java.security.Provider.putAll(Provider.java:224)
at sun.security.action.PutAllAction.run(PutAllAction.java:35)
at java.security.AccessController.doPrivileged(Native Method)
at sun.security.provider.Sun.<init>(Sun.java:254)
at sun.security.util.ManifestEntryVerifier.setEntry(ManifestEntryVerifier.java:110)

I looked into the code of SecurityChecker and found out that it can handle only permissions for getPolicy and setPolicy. In other cases it ALWAYS throws the security exception:
public void checkPermission(Permission permission) {
String name = permission.getName();

if (name.equals(SECURITY_PERMISSION_GET_POLICY)) {
if (!hasGetPolicy())

{ throwSecurityException(_log, "Attempted to get the policy"); }

}
else if (name.equals(SECURITY_PERMISSION_SET_POLICY)) {
if (!hasSetPolicy())

{ throwSecurityException(_log, "Attempted to set the policy"); }

}
else {
if (_log.isDebugEnabled())

{ Thread.dumpStack(); }

throwSecurityException(
_log,
"Attempted to " + permission.getName() + " on " +
permission.getActions());
}
}

So, it looks like there is no way to run such "tivial" code with enabled Security Manager in LR. Did I miss anything?

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Text File
    log.txt
    07/Nov/12 4:49 AM
    37 kB
    Dzmitry Shaparau
  2. Hide
    File
    sample-auth-hook-hook-6.1.1.1.war
    07/Nov/12 4:49 AM
    4 kB
    Dzmitry Shaparau
    1. File
      WEB-INF/classes/portal.properties 0.0 kB
    2. File
      WEB-INF/.../SampleAuthenticator.class 2 kB
    3. XML File
      WEB-INF/liferay-hook.xml 0.2 kB
    4. File
      WEB-INF/liferay-plugin-package.properties 0.4 kB
    5. File
      WEB-INF/src/portal.properties 0.0 kB
    6. Java Source File
      WEB-INF/src/.../SampleAuthenticator.java 2 kB
    Download Zip
    Show
    File
    sample-auth-hook-hook-6.1.1.1.war
    07/Nov/12 4:49 AM
    4 kB
    Dzmitry Shaparau

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
  • Transitions Summary
  • Commits
Hide
Permalink
Mika Koivisto added a comment - 06/Nov/12 5:11 PM

I just tried running following code under out test-pacl-portlet that's running under security manager and it worked fine.

			javax.crypto.spec.SecretKeySpec keySpec =
				new javax.crypto.spec.SecretKeySpec(
					"test".getBytes(),
					"HmacSHA1");

			javax.crypto.Mac mac = javax.crypto.Mac.getInstance("HmacSHA1");

			mac.init(keySpec);
			mac.doFinal("Hello".getBytes());
Show
Mika Koivisto added a comment - 06/Nov/12 5:11 PM I just tried running following code under out test-pacl-portlet that's running under security manager and it worked fine. javax.crypto.spec.SecretKeySpec keySpec = new javax.crypto.spec.SecretKeySpec( "test".getBytes(), "HmacSHA1"); javax.crypto.Mac mac = javax.crypto.Mac.getInstance("HmacSHA1"); mac.init(keySpec); mac.doFinal("Hello".getBytes());
Hide
Permalink
Dzmitry Shaparau added a comment - 07/Nov/12 4:49 AM

I attached a very simple plugin which simulates the error. It provides a very simple Authenticator which just invokes Mac.getInstance
Steps to reproduce:
1. Unpack a clean copy of LR(Tomcat) 6.1.1 ga2
2. Start LR and deploy sample-auth-hook
3. Restart the server
4. Try to login with any user

Show
Dzmitry Shaparau added a comment - 07/Nov/12 4:49 AM I attached a very simple plugin which simulates the error. It provides a very simple Authenticator which just invokes Mac.getInstance Steps to reproduce: 1. Unpack a clean copy of LR(Tomcat) 6.1.1 ga2 2. Start LR and deploy sample-auth-hook 3. Restart the server 4. Try to login with any user
Hide
Permalink
Mika Koivisto added a comment - 12/Nov/12 4:17 PM

Thanks Dzmitry, your hook really helped. It seems if some other plugin without security manager already initializes the crypto classes you won't get any security exceptions in the plugin that has security manager enabled.

Show
Mika Koivisto added a comment - 12/Nov/12 4:17 PM Thanks Dzmitry, your hook really helped. It seems if some other plugin without security manager already initializes the crypto classes you won't get any security exceptions in the plugin that has security manager enabled.
Hide
Permalink
Brian Chan added a comment - 20/Nov/12 3:27 PM

See comments https://github.com/brianchandotcom/liferay-portal/pull/7743

Show
Brian Chan added a comment - 20/Nov/12 3:27 PM See comments https://github.com/brianchandotcom/liferay-portal/pull/7743
Hide
Permalink
Mika Koivisto added a comment - 03/Dec/12 10:26 AM

Added pre initialization as global startup action so that most basic operations work without declaring them explicitly.

Show
Mika Koivisto added a comment - 03/Dec/12 10:26 AM Added pre initialization as global startup action so that most basic operations work without declaring them explicitly.
Hide
Permalink
Mika Koivisto added a comment - 22/Jan/13 10:16 AM

Will submit a new pr with fix for Windows.

Show
Mika Koivisto added a comment - 22/Jan/13 10:16 AM Will submit a new pr with fix for Windows.
Hide
Permalink
Mika Koivisto added a comment - 22/Jan/13 1:31 PM

Steps to reproduce with test-pacl-portlet

1. Login
2. Deploy test-pacl-portlet and it's dependencies
3. Add test-pacl-portlet to a page
4. Logout
5. Restart server
6. View page with test-pacl-portlet and you should see AES Encrypt and HMacMD5 tests fail

Show
Mika Koivisto added a comment - 22/Jan/13 1:31 PM Steps to reproduce with test-pacl-portlet 1. Login 2. Deploy test-pacl-portlet and it's dependencies 3. Add test-pacl-portlet to a page 4. Logout 5. Restart server 6. View page with test-pacl-portlet and you should see AES Encrypt and HMacMD5 tests fail
Hide
Permalink
Serena Song added a comment - 29/Jan/13 1:57 AM

PASSED Manual Testing using the following steps:

  1. Strat up liferay.
  2. Navigate to ..\portlets\test-pacl-portlet\docroot.
  3. Open view.jsp file and add following code to it.
    <% Mac mac = Mac.getInstance("HMACSHA1"); %>
  4. Deploy test-pacl-portlet and it's dependencies
  5. Add test-pacl-portlet to a page
  6. Logout
  7. Restart server

Reproduced on:
Tomcat 7.0 + MySQL 5. Portal 6.1.x EE GIT ID: 9163c531df1cb05b668a98413410989f1f231d25.
Plugin 6.1.x EE GIT ID: 0ff0a9ee0a616727d2a42edb8811a3ed41a336c1.

It will throw exception.

Fixed on:
Tomcat 7.0 + MySQL 5. Portal 6.1.x EE GIT ID: e782c1ebc63271a45ab85125a0cad0e1ce0c01ef.
Plugin 6.1.x EE GIT ID: 570a3cc499c4c1fc6eeaaaf277af9d1bd2840347.
Tomcat 7.0 + MySQL 5. Portal 6.2.x EE GIT ID: f5b69feabc821668b41e3b251fb2a14674a2da56.
Plugin 6.2.x EE GIT ID: 325f0c27c7f18fea7c4132161cd9ffdaf87fd699.

There is no exception occurs.

Show
Serena Song added a comment - 29/Jan/13 1:57 AM PASSED Manual Testing using the following steps: Strat up liferay. Navigate to ..\portlets\test-pacl-portlet\docroot. Open view.jsp file and add following code to it. <% Mac mac = Mac.getInstance("HMACSHA1"); %> Deploy test-pacl-portlet and it's dependencies Add test-pacl-portlet to a page Logout Restart server Reproduced on: Tomcat 7.0 + MySQL 5. Portal 6.1.x EE GIT ID: 9163c531df1cb05b668a98413410989f1f231d25. Plugin 6.1.x EE GIT ID: 0ff0a9ee0a616727d2a42edb8811a3ed41a336c1. It will throw exception. Fixed on: Tomcat 7.0 + MySQL 5. Portal 6.1.x EE GIT ID: e782c1ebc63271a45ab85125a0cad0e1ce0c01ef. Plugin 6.1.x EE GIT ID: 570a3cc499c4c1fc6eeaaaf277af9d1bd2840347. Tomcat 7.0 + MySQL 5. Portal 6.2.x EE GIT ID: f5b69feabc821668b41e3b251fb2a14674a2da56. Plugin 6.2.x EE GIT ID: 325f0c27c7f18fea7c4132161cd9ffdaf87fd699. There is no exception occurs.

People

  • Assignee:
    Serena Song
    Reporter:
    Dzmitry Shaparau
    Participants of an Issue:
    Brian Chan, Dzmitry Shaparau, Mika Koivisto, Serena Song
Vote (1)
Watch (5)

Dates

  • Created:
    31/Oct/12 3:19 AM
    Updated:
    15/May/13 3:04 PM
    Resolved:
    22/Jan/13 5:07 PM
    Days since last comment:
    20 weeks, 1 day ago

Agile

  • View on Board
  • Atlassian JIRA (v5.2.11#854-sha1:ef00d61)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Liferay. Try JIRA - bug tracking software for your team.