Inspiration
Every useful AI workflow today starts with the same way: pasting documents into an AI model such as ChatGPT. Often times we also find ourselves needing to send documents to our peers and colleagues. Unfortunately, sometimes these documents include sensitive information that is not censored and “leaked” to sources that should not have access to it. Documents with addresses and IP addresses are stored on language models among other documents for machine learning purposes. This imposes a major security risk that CloakFile aims to fix by helping the user retrieve a safe redacted version of their documents in seconds.
What it does
CloakFile is a website that allows users to upload a file, choose among categories of what they need redacted, and recieve a new safe file in seconds. The user uploads a file; selects categories such as people names, email addresses, IP addresses, and credit card numbers; and then is prompted if they’d like to whitelist specific exception instances of any of the categories they choose. Other custom word selection is also available if the user has a specific word they want redacted other than the available selection categories. Finally, a safe document is produced with all the information censored.
How we built it
CloakFile uses a simple web-based frontend built with HTML, CSS, and JavaScript (including React). On the backend, Node.js handles file uploades and processing. For example, in the case of PDFs libraries such as pdf-parse are used to extract text and it’s position i the document. Tesseract OCR is used to read text or image baed documents and then the detection system combines technologies such as regex, Compromise, and Luhn checks for sensitive information to identify structured sensitive information such as credit card numbers, Social Insurance numbers, email addresses, and more. Once such information is detected using these tools that also utilize context clues, a new copy file is created, the sensitvie texts are permenantly removed and replaced with a placeholder, and a new file safe file is then available for downloaded while any uploaded files from the user are destroyed on the system-end for no storing of user data.
Challenges we ran into
PDFs are not as simple as they seem. Their text is not stored as pure syntax text, rather a unique descriptive format. The elements in a PDF document also conflict with each other at times depending on when the document is accessed from upload. This required a multi check system rather than a one time sweep. Maintaining proper format with elements such as tables was also a challenge. Text would often be scattered all around, not detecting the table. This was all fixed by experimenting with the algorithm and including safety checks.
Accomplishments that we're proud of
The app is live and deployed at cloakfile.vercel.app, with strict verification that blocks downloads of unsafe files. The app supports both Canadian SIN and US SSN. The app involves a clean but smooth running UI. A privacy shaped architecture: the app never sends your documents to an external AI; rather, all your data is handled locally and then destroyed so no data is stored on our side for privacy concerns.
What we learned
We also learned how much document formats fight you: PDF is a graphics program that sometimes contains text. Building detectors is the easy half; making generators and verifiers producing the same format is the hard half. We learned how to use detection system technologies such as regex, compromise, Luhn checks, Falsify, and OCR and their limitations (i.e. one technology cannot detect all categories or work for all file types). We learnt how to mask the data so the browser does not hold sensitive data and how to delete temporary files.
What's next for CloakFile
More file type compatibility such as CSV or JSONs, supporting images or pictures in PDF documents. Improving response times, edge case fixes, and preserving original document format for complicated files. Scaling into a mobile app for reaching further outreach.
Built With
- compromise
- fastify
- react
- typescript
- vite