filestack / filestack-js

Official Javascript SDK for the Filestack API and content ingestion system.
https://www.filestack.com
MIT License
206 stars 76 forks source link

How do I update files before uploading to prevent CSV Injection? #492

Open lukejpreston opened 1 year ago

lukejpreston commented 1 year ago

We trying to sanitise CSV and Spreadsheets to prevent CSV injection, the OWASP link with details on the vulnerability is here

Our proposed solution is:

Expected Behavior

It should upload the changed file

Current Behavior

It uploads the original file, not the changed one

Possible Solution

Context

Here is the code we are using

const onFileSelected = async (file) => {
    let { originalFile } = file;
    if (isVaunerable(originalFile)) originalFile = sanitise(originalFile)
    return { ...file, originalFile };
  };

We have checked a couple of things to debug this

Your Environment

Pralish commented 4 months ago

Hey @lukejpreston , I have a similar requirement. Were you able to make this work? Thank you

lukejpreston commented 4 months ago

@Pralish We never got a satisfactory solution for this. Not all files with functions have CSV injections, and customers would upload legitimate functions and styles in their spreadsheets. Editing files would destroy the functionality. Our solution is to put a warning message up for users. This could be better, but we needed help finding libraries or virus detection tools to find CSV injections.

Some things we found which might be helpful