Skip to content

Fix for secure storage in Chrome #412

@mtravnicek

Description

@mtravnicek

This is followup to #384, sorry for taking too long... i hope/dont know if it is still relevant with latest browser updates. I was trying this about an half year ago, but my version of extension is 5.3.2

In Chrome there is (and should be still) problem with storing anything in local storage,
there is "transaction log" 000003.log with everything what was written and even overwritten/deleted! It is described in detail here: https://blog.bitwarden.com/chrome-extension-version-1-24-security-fix-1ce700aeccf6

So issue is when enabling encryption in your extension if there were some unencrypted entries before, it will stay in the file! Chrome may cleanup this file some time in future or fix this or who knows... Workaround fix is when saving delete everything that was stored before, all these values are somehow in memory already so nothing is lost only old is erased... I dont know if this is feature of your code or Chrome storage api, but please refactor so it is clear what methods do....

I somehow hacked it but this JS is hacky on its own, i dont even know what it is exactly doing as of now. Try for yourself and refactor! PS I am not sure if my approach does not erase the whole user storage, but it should be limited to this extension as of storageAPI.
There is much duplicity and crossing of concerns in what methods do like set/remove.... add/update/set there is two classes in one file and methods with 100 lines are not good.
While dissecting EntryStorage and BrowserStorage to distinct classess/files try to introduce for example polymorphic separation (2 classes with common interface) for "local" storage and "sync" storage and get rid of those if statements on every other line...

https://refactoring.guru/replace-conditional-with-polymorphism
Also relevant is SingleResponsiblity, so for example BrowserStorage getStorageLocation should not check wheter browser is Edge or whatever... that belongs to some other (extracted) function

Here:storage.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingchromeChrome-specific issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions