Giter Club home page Giter Club logo

portable-secret's Introduction

🔐 Portable Secret

Better privacy, without special software.

TL;DR;

Portable Secret is a little hack that allows you to:

  • Send encrypted messages/images/files over insecure channels (email, messaging, ...)
  • Store sensitive information (passwords, documents) in insecure locations (web, Cloud drives, USB drives)

It's portable because: decrypting these secrets does not require special software! All you need is a browser.

I created Portable Secret to securely exchange documents via email with my mother, who can't be expected to learn PGP, age, or similar.

I also use Portable Secret to store some my most sensitive secrets (private keys, 2FA recovery codes, etc.)

Finally, I use it to store copies of important documents (like a picture of passport). These documents are accessible to me from anywhere, even if all my trusted devices have been stolen or lost.

Sounds too good to be true? Keep reading. This is for you.


Portable Secret is not a product and it is barely a project. It is just a neat trick, a hack.

The source code and creator tool are provided as a demonstration.

Update January 2023: Rocky W. took this idea and ran with it, creating a beautiful full-fledged product: PrivacyProtect.dev


How it works

A 'Portable Secret' is simply an HTML file that also contains:

Any (reasonably modern) web browser can open the file, even without an internet connection! If you know the password, you can recover the secret within.

Here's an example (the password is banana)

Notice that the file is self-contained and has no external dependencies! It can be carried on a USB drive and decrypted without an internet connection, on any device that has a web browser.

To understand how it works, go ahead and create yourself a secret. Download and inspect the generated Portable Secret.

The embedded code is straightforward:

  • Take the password and generate a key
  • Use the key to decrypt the payload
  • Display the decrypted secret

How I use Portable Secret

Private communication

Do you want to communicate privately with people, but you can't expect them to learn how to use PGP?

Send a Portable Secret. For example as email attachment.

Hey ___, attached to this email is the PDF and data you requested, but it's encrypted. Never double-click on attachments, it's dangerous! Give me a call when you get this, and I'll show you how to read it.

Whenever they call me, I tell them:

Right-click on the attachment and 'Open with...' any browser. The password is 'banana_split'. Now you can save the decrypted PDF.

Store top-level secrets

Some secrets don't belong in your password manager. Things like backup private keys, 2FS recovery keys, wallet keys, safe combinations, treasure maps, etc.

Using Portable Secret, I can keep copies of these critical keys all over the place (Cloud drives, USB drives, all my devices, etc).

Even if some of these copies end up stolen (e.g. I lose a USB stick), I am not concerned anyone will be able to recover the secrets within.

The passwords are long sequence of words that are trivial for me to remember (thanks to the hints provided), but impossible for anyone else to guess or crack.

Emergency documents on the go

Have you ever gotten stranded in a foreign country without any of your devices or documents? It's not fun.

I keep a copy of my passport encrypted on the internet. It's just an HTML file, it's easy to host. If I find myself stranded again, I can use any computer/device to retrieve it.

Here's an example of ID document safely encrypted in plain sight.


Miscellaneous

Crack me if you can

Do you think this cannot possibly be secure? Great, prove it.

This secret contains the recovery key for a Bitcoin wallet. Crack it and take my money!

Choosing a good password

Choosing a strong-enough password is key (pun intended).

Eventually I'll fill in this paragraph. For now all you get is the obligatory XKCD: correct-horse-battery-staple

On tools

Portable Secret is a tool. As such, it can be used wrong (e.g. weak password), or used to do bad things (e.g., exfiltrate intellectual property).

I cannot take responsibility for such misuse any more than a hammer manufacturer can take responsibility for me hammering my thumb, or using the hammer to attack someone.

Prior art

I came up with Portable Secret on my own, but I have since found a few projects that do something similar.

StatiCrypt

PolySafe

hscrypt

Hypervault

Encrypted HTML Vault

UltraCrypt

html-vault

Password Protect My File

Emergency Contacts

Digi-Cloak

Pretty Easy Privacy

If you are aware of other similar/related projects, please let me know and I'll link them here.

Feedback

I would love to hear what you think of this project, good, bad, or ugly.

Please use GH issue to report a problems and make suggestions. For everything else, start a GH Discussion.

You can also find my email on my homepage (linked from my GH profile).

Or discuss on HackerNews

portable-secret's People

Contributors

mprimi avatar mtlynch avatar teddybear06 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

portable-secret's Issues

Creator fails on Chrome for CORS policy

Access to fetch at 'file:///D:/Users/maggie/Google%20Drive/portable-secret/creator/secret-template.html' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, isolated-app, chrome-extension, chrome, https, chrome-untrusted.

State the encryption algorithms in the README

I understand keeping the UI clean, but the encryption even though you didn’t write the algorithm you choose the implementation details. AES and keysize with PKCS padding options should be explained in the README because THESE ARE implementation details important to users.

You’re documenting the html very clearly but I would like to see it outside of the code.

[Suggestion] Use type="password" for password input field

Some browsers automatically save and fill in the form field contents when it's not a type="password", showing the password in plain text when navigating to a previously-used secrets page.

Plain text could be a toggleable opt-in.

[Feature] Press Enter/Return in the Textbox to Decrypt

Hi,

You could add this to the end of the secret-template file, within the script tag, to allow that.

document.querySelector("#password").addEventListener("keyup", event => {
if(event.key !== "Enter") return;
decrypt()
event.preventDefault();
});

[Suggestion] Specific message for incorrect decryption password

Hi,

Nice work:
Maybe a suggestion for delivering a specific message when the entered decryption password is incorrect:
Instead of Decryption failed: OperationError: The operation failed for an operation-specific reason something like a basic Wrong password, try again!

When testing my first thought was that the failure was that of the code itself ...

[Suggestion] Plausible deniability feature?

This is a really useful and simple tool. Thank you!

In regards to usability while traveling, sometimes authorities at an authoritarian country may coerce the visitors to decrypt the files on on a USB drive. It would be nice to have a plausible deniability feature linked to a second passphrase where the second passphrase would decrypt some dummy data of the user's choosing (e.g., another PDF file). Just a thought.

DRAFT - stash of my quick brainstorming

UNFINISHED DRAFT, please do not complain it is not actionable, I will get back to it hopefully in January/February 2023

  1. press "decrypt" automatically changes the Salt and IV
  2. one can add arbitrary number of messages, files, images in the specified order!
  3. maybe: message could be replaced by "rich text" which would be simply djot to support formatting, tables, and embedded images - see #1 (comment)
  4. redo UX based on clarified use cases (some way to "amend" existing file - under the hood a full regeneration would of course happen)
  5. make it work with JsShelter's strictiest settings ever
  6. team up with USB key storage open source projects (Signet etc.)
  7. make it easy (one click!) to share the resulting file through several free hostings at the same time (if small enough, maybe store it in URL itself!)
  8. make it easier to audit the encryption web page (e.g. make a release signed by a well-known certification authority so that the browser can check it on its own)
  9. add password strength estimator visual indicator (e.g. a bar) - e.g. zxcvbn from Dropbox

Few comments

Hi, this idea seems lovely, but currently the implementation has some painful moments:

  • Encyrpting doubles file size, it will be probably super hard to avoid, if not impossible, but at least you should note that in README. I don't know if hacks like that: https://news.ycombinator.com/item?id=12262470 would make it possible to read the contents of the binary data, probably not, but that's something I remember reading, further research is needed

  • Encrypting freezes the browser. Opening a encrypted 9MB file (so 18MB HTML) freezes the browser. Chrome wants to kill the page when I try to focus input box - super bad UX here, not sure how could you embed this data within HTML without this. Encrypting could be moved to web workers, but with file:// protocol you have when you open local html file this is impossible. But you can at least have this for hosted HTML files I guess?

  • The encryption & decryption pages could use some nice UI design and UX. It's currently quite ugly and after using it once when decryptin all I care is the password box, yet most of the screen is covered with explainations, huge password hint, advertising product name and very cryptic (haha! a pun!) Details section

Proposed easy solution to UX:
Because there is no chance that all the people in the world would like my approach to decrypt page, which for me should look like that: https://dribbble.com/shots/5757939-Password-requirements (without the characters counter, and the text below input would be a password hint, OPTIONALLY I could display some text above the password field for first time users):

  • add a way to customize CSS
  • add a way to customize texts

Not sure how it'd be the best way to save my customizations so I don't have to copy/paste them each time.

Tell me what do you think about my thoughts

Call out specific cryptography choices made

While the core of Portable Secret uses the W3C Web Cryptography APIs (which is great!), the specific choices of cryptography parameters matter and can drastically affect the security of the implementation. These should be called out in the README.md so they can be more easily assessed by those with enough knowledge of cryptography primitives.

Specifically, this is what I found in the source:

  • The secret is encrypted using a derived key, not directly with the password.
  • This key is 32 bytes long and derived from the password using PBKDF2 with 1,000,000 (1 million) iterations.
  • A 16 byte salt is used.
  • The derived key is configured to be non-extractable.
  • The derived key is used for AES-GCM.
  • AES and the IV use a block size of 16 bytes.

Add date/time to saved html file

Hi,

thanks for this interesting project. While I was 'playing' with it, i noticed that every generated secret file has the same filename, thus when saving overwriting the previous saved file.

Maybe it is an idea to add a date/timestamp/uuid kind a thing so that every generated file has a unique filename by default? OR make the filename configurable and not just 'secret' for that may scare people off or does not adhere to a policy of a kind. And not everybody speaks/reads English ;-)

Thanks for your considerations!

[Suggestions] “Prior Art” ⇒ 2 suggestions

https://gitlab.com/smondet/hscrypt (Uses gpg for encryption and OpenPGP.js for decryption)

2 things that is has that are nice and could be suggestions:

  1. little shell script to generate the secret html pages from the command line
  2. the decryption attempts to grab the password from the URL selector (a.k.a. the #… part, which the browser should never send to the server), you can pass document + password, over encrypted chat like Signal or Matrix.org for instance like this https://smondet.gitlab.io/hscrypt/hscrypt-test.html#test-pass-phrase.

Warn when using non HTTPS connection

When trying to decrypt secrets on my homepage, having accessed it with http instead of https I got the rather unhelpful error:

Decryption failed: TypeError: Cannot read properties of undefined (reading 'importKey')

Only after checking your example with an incorrect password did I realise the error was not related to my password (which I was sure I had correct).

Then I realised I was using http and that might cause Crypto APIs to not work, which was indeed the problem. It might be helpful to warn users that this only works over an SSL connection.

Ethereum a storage solution

Saving encrypted data on public servers is a great idea,
but there is no assurance of data persistency ,
my suggestion is store the data on an Ethereum transaction ( using calldata args) , this way the data will be persistent in the chain forever , and the data will be replicated on thousands of servers in a decentralized manner

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.