Code signing was introduced in Java to provide a mechanism for granting elevated privileges to code irrespective of the security policy in effect. For example, Java applets that need to read system properties from a user's machine can escape the default sandbox restrictions when signed. When a signed applet is run, the user is prompted with a security dialog, asking whether the party that signed the code is considered trustworthy. This element of trusting the signature and the signer allows applets to escape the default security sandbox restrictions. On the other hand, with applications that use a custom security policy, explicit permissions need to be granted to the particular codebase and optionally, the signer. Both these approaches place the control with in the hands of the user who can choose to run the application either restrictively or with full permissions.
...
Code signing is designed primarily to verify authenticity of origin and integrity of the code. It relies on the a Certification Authority (CA) to duly confirm the identity of the principal signer. Naive users should not be expected to understand how certificates and the Public Key Infrastructure (PKI) work. All too often, they users associate digital signatures with safety of code execution, and trust the code to cause them no harm.
In general, there is a misconception that signed code is safe to be executed. The problem manifests itself when a vulnerability is discovered in signed code. Because many users when prompted with the security dialog, choose the option of permanently trusting the organizations that they consider trustworthy, they are not notified in the future while downloading trusted but potentially vulnerable content signed by the trusted organization. An adversary may offer them the vulnerable content with the intentions of exploiting it. Consider, for example, signed Java applets. Whenever a certificate is verified to be correct (as opposed to being self-signed or tampered), on widely used platforms the user is confronted with a security dialog that has the check box option "Always trust the content from the publisher" turned onselected by default. The dialog asks whether the signed code should be executed or not. Unfortunately, by default this setting overrides any future warning dialogs if the user chooses to execute the code with the check box selected. An adversary may take advantage of this mechanism by supplying vulnerable code signed by the trusted organization. In this case, the code executes will execute without the user's permission and may be freely exploited.
An organization that signs its code must not vouch for code acquired from a third party without carefully auditing it. While When signing privileged code make sure it exists in , ensure that the code is confined to the same package (ENV04-J. Place all privileged code in a single package and seal the package). Likewise, any code that is called from the privileged code must also exist be bundled in the same package. Non-privileged code can be left unsigned, restricting it to the sandbox. Additionally, any code that is incomprehensible or unaudited must not be signed (SEC32-J. Create and sign a SignedObject before creating a SealedObject).
...