Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: removed 2nd NCCE/CS, added applicability

...

Code Block
bgColor#ccccff
langjava
if (accessControlContext == null) {
  throw new SecurityException("Missing AccessControlContext");
}
AccessController.doPrivileged(new PrivilegedAction<Void>() {
  public Void run() {
    // ...
  }
}, accessControlContext);

Noncompliant Code Example

This noncompliant code example ...

Code Block
bgColor#ffcccc
langjava
 System.setSecurityManager(null);

Compliant Solution 

This compliant solution ...

Code Block
bgColor#ccccff
langjava
System.setSecurityManager(new SecurityManager());

...

Applicability

Security-sensitive methods must be thoroughly understood and their parameters validated (to prevent null arguments for instance) in order to prevent corner cases with unexpected argument values. If unexpected argument values are passed to security-sensitive methods, arbitrary code execution becomes possible and privilege escalation becomes likely.

Bibliography

...