
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
electron-clear-data
Advanced tools
Securely clears user data for your Electron application.
Electron applications are web applications running in the Chromium engine. The Chromium engine uses leveldb under the hood to store IndexedDB, localStorage, and Session Storage data. Each one of these is stored in a database. A database is represented by a set of files stored in a directory. Below is an example of a leveldb
database:
Local Storage/
└── leveldb
├── 000003.log
├── CURRENT
├── LOCK
├── LOG
└── MANIFEST-000001
Our main interests here are the Log files and Sorted tables. These files, which contain a log of updates made to localStorage and IndexedDB, including key/values in plaintext, are not deleted when localStorage or IndexedDB is cleared. This may expose private information from previous sessions, which is a security hazard.
In addition, even deleting records from IndexedDB does not remove those records from the log file. Please see this open issue on the leveldb repo for more.
The only sure-fire way to clear sensitive data that was once written to localStorage or IndexedDB is to delete the underlying files manually, and restart the application so that these files are recreated. This is precisely what this package does.
The core code involved in this package is not difficult to write yourself. However, it can be difficult to do safely, and to ascertain the correctness of your code. For this reason we've created this package to be as safe and reliable as possible. We've composed tests that ensure this functionality always works as you would expect and does not regress. The code is written in TypeScript to maximize compile-time safety. We'll also keep this package up to date with other Electron data-related vulnerabilities as and when they are discovered.
Each database is represented by a set of files stored in a directory. There are several different types of files as documented below (all of which will be deleted by electron-clear-data
):
A log file (*.log) stores a sequence of recent updates. Each update is appended to the current log file. When the log file reaches a pre-determined size (approximately 4MB by default), it is converted to a sorted table and a new log file is created for future updates.
A sorted table (*.ldb) stores a sequence of entries sorted by key. Each entry is either a value for the key or a deletion marker for the key. (Deletion markers are kept around to hide obsolete values present in older sorted tables).
A MANIFEST file lists the set of sorted tables that make up each level, the corresponding key ranges, and other important metadata. A new MANIFEST file (with a new number embedded in the file name) is created whenever the database is reopened. The MANIFEST file is formatted as a log, and changes made to the serving state (as files are added or removed) are appended to this log.
CURRENT is a simple text file that contains the name of the latest MANIFEST file.
Informational messages are printed to files named LOG and LOG.old.
See leveldb implementation for a more detailed implementation document.
To install, run:
yarn add electron-clear-data
Or:
npm install electron-clear-data
import { clearSensitiveDirectories } from 'electron-clear-data';
...
clearSensitiveDirectories();
import { clearAllUserData } from 'electron-clear-data';
...
clearAllUserData();
git checkout -b feat/my-feature
git add .
git commit -am 'feat: my feature'
git push origin feat/my-feature
See the LICENSE file for license rights and limitations (MIT).
FAQs
Securely clears user data for your Electron application.
The npm package electron-clear-data receives a total of 53 weekly downloads. As such, electron-clear-data popularity was classified as not popular.
We found that electron-clear-data demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.