In Java SE 6 and Java SE 7, privileged code must either use the AccessController
mechanism or be signed by an owner (or provider) whom the user trusts. Attackers could link privileged code with malicious code if the privileged code directly or indirectly invokes code from another package. Trusted JAR files often contain code that lacks direct privileges requires no elevated privileges itself, but that depends on privileged code; such code is known as security-sensitive code. If an attacker can link security-sensitive code with malicious code, he or she can indirectly cause incorrect behavior with sensitive data. This is called a mix-and-match attack.
Execution of untrusted code causes loss of privileges. When trusted code calls untrusted code that attempts to perform some action requiring permissions withheld by the security policy, the that action is not allowed. However, privileged code may use a class that exists in an untrusted container and performs only unprivileged operations. If the attacker were to replace the class in the trusted container with a malicious implementation, the trusted code might retrieve incorrect results and cause the privileged code to misbehave at the attack's discretion.
...
An attacker can provide an implementation of class RetValue
so that the privileged code uses an incorrect return value. Even though class MixMatch
consists only of trusted, signed code, an attacker can still cause this behavior by maliciously deploying a legally valid signed JAR file containing the untrusted RetValue
class.
This example comes close to violating almost violates rule SEC01-J. Do not allow tainted variables in privileged blocks but does not do so. It instead allows potentially tainted code in its doPrivileged()
block, which is a similar issue.
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="ee87ba017ba2aa76-c4e3cc9b-49f94d60-928e8d27-d6ec39894f0b5ee61cb73b05"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] |
| ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="36bc1f254b2fcb5b-510c3c16-4f7049b3-80779741-e1ca03e81c7fd8eec6f42b91"><ac:plain-text-body><![CDATA[ | [[McGraw 1999 | AA. Bibliography#Ware 99]] | Rule 7, If you must sign your code, put it all in one archive file | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="a7653aaca01bada2-eb0d2553-412e4cf8-a8a6b1dd-f89c78ec18faf5cc5753f368"><ac:plain-text-body><![CDATA[ | [[Ware 2008 | AA. Bibliography#Ware 08]] |
| ]]></ac:plain-text-body></ac:structured-macro> |
...