Sitemap

How to Protect Your Node.js App from Malicious .PPT Files

4 min readApr 29, 2025

--

Legacy PowerPoint (.ppt) files aren’t just binary containers full of old slides — they’re potential vehicles for embedded threats.

Malicious .PPT Files: What’s the Risk?

A compromised .ppt upload might look indistinguishable from a dozen other legitimate legacy business presentations — all while quietly carrying a macro-enabled payload under the hood. It could also contain hidden links to external resources — think malicious scripts, embedded media, or command-and-control servers — that silently trigger when the file is opened, quickly exploiting vulnerabilities in the software or system responsible for parsing the presentation.

On top of all this, it’s important to bear in mind that the binary structure of .ppt files makes them easier to weaponize, allowing obfuscated threats to be nested more deeply within the file than modern equivalents (e.g., .pptx).

Checking .PPT for Multiple Threat Types at Once

If your Node.js application has to accept legacy PowerPoint uploads for any reason, you’ll want to inspect those files rigorously before storing them in a client/user-accessible location or parsing them in memory.

To lock this down, we can integrate a file scanning API with code examples provided below. This will detect malicious macros, invalid formatting, and common document-based malware, among numerous other potential threats. The API returns a structured result that lets us decide whether to accept or reject the file — all before it reaches deeper into our stack.

We’ll start by running this npm command to install the SDK:

npm install cloudmersive-virus-api-client --save

Alternatively, if we need to manually control versions or set up dependencies without immediately installing them via CLI, we can add the below snippet to our package.json:

  "dependencies": {
"cloudmersive-virus-api-client": "^1.1.9"
}

Following that, we can import the API client, initializes authentication with an API key (we can get one for free with 800 API calls/month), configure options for file scanning, and read a file into a buffer:

var CloudmersiveVirusApiClient = require('cloudmersive-virus-api-client');
var defaultClient = CloudmersiveVirusApiClient.ApiClient.instance;

// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';



var apiInstance = new CloudmersiveVirusApiClient.ScanApi();

var inputFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // File | Input file to perform the operation on.

var opts = {
'allowExecutables': true, // Boolean | Set to false to block executable files (program code) from being allowed in the input file. Default is false (recommended).
'allowInvalidFiles': true, // Boolean | Set to false to block invalid files, such as a PDF file that is not really a valid PDF file, or a Word Document that is not a valid Word Document. Default is false (recommended).
'allowScripts': true, // Boolean | Set to false to block script files, such as a PHP files, Python scripts, and other malicious content or security threats that can be embedded in the file. Set to true to allow these file types. Default is false (recommended).
'allowPasswordProtectedFiles': true, // Boolean | Set to false to block password protected and encrypted files, such as encrypted zip and rar files, and other files that seek to circumvent scanning through passwords. Set to true to allow these file types. Default is false (recommended).
'allowMacros': true, // Boolean | Set to false to block macros and other threats embedded in document files, such as Word, Excel and PowerPoint embedded Macros, and other files that contain embedded content threats. Set to true to allow these file types. Default is false (recommended).
'allowXmlExternalEntities': true, // Boolean | Set to false to block XML External Entities and other threats embedded in XML files, and other files that contain embedded content threats. Set to true to allow these file types. Default is false (recommended).
'allowInsecureDeserialization': true, // Boolean | Set to false to block Insecure Deserialization and other threats embedded in JSON and other object serialization files, and other files that contain embedded content threats. Set to true to allow these file types. Default is false (recommended).
'allowHtml': true, // Boolean | Set to false to block HTML input in the top level file; HTML can contain XSS, scripts, local file accesses and other threats. Set to true to allow these file types. Default is false (recommended) [for API keys created prior to the release of this feature default is true for backward compatability].
'restrictFileTypes': "restrictFileTypes_example" // String | Specify a restricted set of file formats to allow as clean as a comma-separated list of file formats, such as .pdf,.docx,.png would allow only PDF, PNG and Word document files. All files must pass content verification against this list of file formats, if they do not, then the result will be returned as CleanResult=false. Set restrictFileTypes parameter to null or empty string to disable; default is disabled.
};

var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.scanFileAdvanced(inputFile, opts, callback);

We can use var opts to customize scanning options, including security settings for different file types. After we successfully call the scanFileAdvanced method, we can expect our response to follow the below structure:

{
"CleanResult": true,
"ContainsExecutable": true,
"ContainsInvalidFile": true,
"ContainsScript": true,
"ContainsPasswordProtectedFile": true,
"ContainsRestrictedFileFormat": true,
"ContainsMacros": true,
"ContainsXmlExternalEntities": true,
"ContainsInsecureDeserialization": true,
"ContainsHtml": true,
"ContainsUnsafeArchive": true,
"ContainsOleEmbeddedObject": true,
"VerifiedFileFormat": "string",
"FoundViruses": [
{
"FileName": "string",
"VirusName": "string"
}
],
"ContentInformation": {
"ContainsJSON": true,
"ContainsXML": true,
"ContainsImage": true,
"RelevantSubfileName": "string"
}
}

And that’s all there is to it! We’ve instantly improved our threat profile against myriad threats embedded in .ppt documents (and dozens of other common file types).

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet