...
However, this approach do not ensure that the uploaded file conforms to the security requirements as interceptor checks can be trivially bypassed. If an attacker uses a proxy tool to change the content type in the raw HTTP request in transit, the framework would not prevent the file's upload.
This code does not violate ERR08-J. Do not catch NullPointerException or any of its ancestors because it falls under the exception ERR08-EX2.
Compliant Solution
The file upload must only succeed if the content type matches the content present within the file. For example, a file with an image header must only contain an image and not executable code. This compliant solution uses the Apache Tika library to detect and extract metadata and structured text content from documents using existing parser libraries [Apache Tika|http://tika.apache.org/index.html]. The checkMetaData()
method must be called before invoking execute()
.
...