This document provides recommendations for coding style and conventions to ensure consistent and maintainable Java code.
- Limit the lifetime of sensitive data.
- Do not store unencrypted sensitive information on the client side.
- Provide sensitive mutable classes with unmodifiable wrappers.
- Ensure that security-sensitive methods are called with validated arguments.
- Prevent arbitrary file upload.
- Properly encode or escape output.
- Prevent code injection.
- Prevent XPath injection.
- Prevent LDAP injection.
- Do not use the
clone()method to copy untrusted method parameters. - Do not use
Object.equals()to compare cryptographic keys. - Do not use insecure or weak cryptographic algorithms.
- Store passwords using a hash function.
- Ensure that
SecureRandomis properly seeded. - Do not rely on methods that can be overridden by untrusted code.
- Avoid granting excess privileges.
- Minimize privileged code.
- Do not expose methods that use reduced-security checks to untrusted code.
- Define custom security permissions for fine-grained security.
- Create a secure sandbox using a security manager.
- Do not let untrusted code misuse privileges of callback methods.