Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-486

Define security constraints for using CDI SPI

    XMLWordPrintable

Details

    • Feature Request
    • Resolution: Obsolete
    • Critical
    • 2.1 (Discussion)
    • 1.2.Final
    • None
    • None

    Description

      Currently, the specification does not require any security checks to be performed when CDI SPI is used. It is not clear how this should be implemented.

      Note that since a CDI implementation is required to support bypassing platform securiy checks (e.g. when invoking aprivate observer method), total absence of security checks on CDI SPI level could result in privilege escalation. Here's an example:

      Suppose the application server bundles a sensitive method:

      public class ApplicationServer {
      
          static boolean explode() {
              // ...
          }
      }
      

      The method is package-private and thus cannot be by an application. If the application would be to invoke this method using reflection, it would need to first obtain the Method handle for the explode method. Obtaining a Method handle requires the "accessDeclaredMembers" runtime permission which the application does not have. It can however use the CDI SPI:

      Method method = null;
      for (AnnotatedMethod<?> annotatedMethod : manager.createAnnotatedType(ApplicationServer.class).getMethods()) {
          if (annotatedMethod.getJavaMember().equals("explode")) {
              method = annotatedMethod.getJavaMember();
              break;
          }
      }
      

      Now the application has the Method handle without having the "accessDeclaredMembers" permission.

      The application still cannot invoke the method as it needs to bypass security checks on access to the method first. This cannot be done without the "suppressAccessChecks" runtime permission.

      Again, remember that CDI implementations are supposed to be capable of invoking inaccessible methods and this capability is exposed through the SPI. Therefore, the application call:

      Producer<?> producer = manager.getProducerFactory(annotatedMethod, null).createProducer(null);
      

      Now, calling producer.produce() will cause the sensitive method to be invoked even though the application was not granted "accessDeclaredMembers" neither "suppressAccessChecks" permission.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rhn-engineering-jharting Jozef Hartinger
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: