Securely storing credentials that can't be encrypted

后端 未结 3 495
醉酒成梦
醉酒成梦 2021-01-21 14:58

I have a client that\'s running an aggregator of information from multiple accounts. The database needs to store usernames and password to other websites in a way that can be us

3条回答
  •  一整个雨季
    2021-01-21 15:45

    If you hash the information, you cannot retrieve it later. If you encrypt it, you need to store the key somewhere. There is no reliable way, except for physically restricting access to the database, to eliminate the potential for malicious use of the data.

    Hashing can prevent, in all foreseeable manners, use of the original data. However, you need to use the data. Cryptographic hashes like SHA-256 are designed so that it is computationally difficult (without making unreasonably sized lookup tables) to find m given H(m) where H is your favorite hash function.

    If you go the route of encryption, you need to store the encryption key and it can be compromised or at least used as a decryption oracle. You can make a service broker that does decryption for you and use both client and server authentication certificates to ensure safety. However, if someone compromises an authorized client, then you have a window of time between compromise and detection where accounts can be compromised. But this approach gives you the flexibility to revoke certificates and immediately deny the server access, even if you don't have access to the compromised client anymore.

    I recommend setting up a remote service that is only available by a direct connection (on the same physical switch) and which authenticates itself to the client and requires all clients to authenticate. Perhaps limiting the number of queries it can make would also help in preventing abuse if a client were to be compromised. The service will need to check for certificate revocation on every request.

    This service also needs to be connected to a remote logging facility, which will serve to audit the system independently. This logging service needs to again authenticate the client and authenticate itself with a client. The logging service receives data and appends it to a log, it never allows for modification or deletion. When it receives a log entry, it digitally signs a timestamped log entry and enters it into an auditing container.

    This is similar to how certificate authorities set up their paper trails to audit certificate issuance, in order to provide the best possible recovery model for a compromise, since preventing the compromise is actually impossible.

提交回复
热议问题