Security checks based on untrusted sources can be bypassed. The untrusted object or parameter should be defensively copied before the security check is performed. The copy operation must be a deep copy; the implementation of the clone()
method may produce a shallow copy, which can still be compromised. In addition, the implementation of the clone()
method can be provided by the attacker. See guidelines rules VOID MET08-J. Do not use the clone method to copy untrusted method parameters and OBJ14-J. Defensively copy mutable inputs and mutable internal components for more information.
...
Note that using the clone()
method instead of the openFile()
method would copy the attacker's class, which is not desirable. (Refer to guideline rule VOID MET08-J. Do not use the clone method to copy untrusted method parameters.)
...
Search for vulnerabilities resulting from the violation of this guideline rule on the CERT website.
Related Guidelines
...