Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

It may also be possible to upload files with dangerous extensions such as .exe and .sh which may could cause arbitrary code execution on server-side applications.

...

The value of the parameter type maximumSize ensures that a particular Action does not cannot receive a very large file. The allowedType parameter defines the type of files that are accepted.

However, this approach does not fails to ensure that the uploaded file conforms to the security requirements as because interceptor checks can be trivially bypassed. If an attacker uses were to use a proxy tool to change the content type in the raw HTTP request in transit, the framework would not fail to prevent the file's upload. Consequently, an attacker can could upload a malicious file having an .exe extension.

This Although this code appears to violate ERR08-J. Do not catch NullPointerException or any of its ancestors. But it does not actually violate that rule, because it , it falls under the exception ERR08-EX2.

Compliant Solution 

The file upload must succeed only succeed if when the content type matches the content actually present within the file. For example, a file with an image header must contain only an image and not must lack 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. The checkMetaData() method must be called before invoking execute().

...

The AutoDetectParser selects the best available parser based on the content type of the file to be parsed.

Applicability

...