Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using in the browser #5

Open
andreialecu opened this issue Dec 4, 2019 · 7 comments
Open

Using in the browser #5

andreialecu opened this issue Dec 4, 2019 · 7 comments

Comments

@andreialecu
Copy link

andreialecu commented Dec 4, 2019

I'm thinking of using this in the browser, as I've read in the documentation that it should be supported.

Basically I need to store some sensitive user data, but don't want the hassle of having to deal with the security side of it. It would be better just not having access or storing the unencrypted data at all in our backend/databases.

So I'm thinking of letting the user enter a key into the web app, then use client side javascript to deal with decryption of data. The key would be stored probably in localStorage, and on every new browser they connect from, they'd need to re-enter the key in order to be able to decrypt or update the sensitive data.

Does this sound feasible to implement using ciphersweet?

@paragonie-security
Copy link
Contributor

It's feasible, but you're probably better off using the AWS JavaScript Encryption SDK.

At the very least, you're going to want to use KMS to manage your keys.

@andreialecu
Copy link
Author

andreialecu commented Mar 25, 2020

The purpose behind using ciphersweet for this was for searchable encryption. I'm not sure AWS encryption can help with that.

@paragonie-security
Copy link
Contributor

The purpose behind CipherSweet is also symmetric-key encryption, and you'd be giving out your encryption key via JavaScript to anyone who accessed the page.

You can use CipherSweet only for the indexing purposes, and then use something else (e.g. the AWS Encryption SDK, backed by KMS) for record encryption. Or you could use something like SodiumPlus for crypto_box_seal() on the data encryption, against a static public key.

@andreialecu
Copy link
Author

andreialecu commented Mar 26, 2020

Thank you for the insight. The purpose is to not have access to the Customer data at all from the service provider side.

From what I understand encrypting via KMS does not ensure that. The owner of the AWS account can still decrypt data. That is what we're trying to avoid.

Regarding giving out the encryption key, yes. I am aware of that. But the Encrypted data would still be secured by regular permissions on the user account, only an authorized account (by checking a JWT, for example) could retrieve the encrypted blob and then decrypt it locally.

So it would be an additional layer over a classic permission/ACL layer.

Does this still sound terribly wrong? :)

@tbelch-at-eHealth-Tec
Copy link

tbelch-at-eHealth-Tec commented Aug 11, 2021

Hi @paragonie-security! I have been trying to use this in the browser and failed so far, due to dependencies that couldn't be resolved. I tried a very simple example and got errors regarding the dependency fs and others. I tried mocking them with webpack, I tried using ployfills. Nothing seemed to work.

Does this actually work in the browser? And if so, is there and example implemantion somewhere you could point me to?

Any help would be really appreciated!

Best,
Tobias

Example Code

import {
  BlindIndex,
  CipherSweet,
  EncryptedField,
  FIPSCrypto,
  StringProvider,
} from "ciphersweet-js";

export async function foo() {
  const cipherSweet = new CipherSweet(
    new StringProvider(
      "4e1c44f87b4cdf21808762970b356891db180a9dd9850e7baf2a79ff3ab8a2fc"
    ),
    new FIPSCrypto()
  );

  let ssn = new EncryptedField(cipherSweet, "contacts", "rezeptTyp")
    // Add a blind index for the "last 4 of SSN":
    .addBlindIndex(
      new BlindIndex(
        // Name (used in key splitting):
        "rezeptTyp",
        // List of Transforms:
        [],
        // Bloom filter size (bits)
        16
      )
    );

  // Some example parameters:
  let contactInfo = {
    name: "John Smith",
    ssn: "123-45-6789",
    email: "foo@example.com",
  };

  const result = await ssn.prepareForStorage(contactInfo["ssn"]);

  return result;
}

Error Messages

image-20210721-210527

@34r7h
Copy link

34r7h commented Sep 13, 2021

I'm interested in a browser-based install, as well. I think most of the reqs are available in browser, such as browserFS and buffer but ofc these need to be thoughtfully included for security concerns.

@liflovs
Copy link

liflovs commented Mar 21, 2023

@paragonie-security coming here with similar concern. Does what @andreialecu says seem terrible?

Btw, @andreialecu I wonder, did you end up with the way you suggested?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants