File-KDBX
view release on metacpan or search on metacpan
lib/File/KDBX.pm view on Meta::CPAN
This can also be done with one call to L</remove_empty_groups>.
=head1 SECURITY
One of the biggest threats to your database security is how easily the encryption key can be brute-forced.
Strong brute-force protection depends on:
=over 4
=item *
Using unguessable passwords, passphrases and key files.
=item *
Using a brute-force resistent key derivation function.
=back
The first factor is up to you. This module does not enforce strong master keys. It is up to you to pick or
generate strong keys.
The KDBX format allows for the key derivation function to be tuned. The idea is that you want each single
brute-force attempt to be expensive (in terms of time, CPU usage or memory usage), so that making a lot of
attempts (which would be required if you have a strong master key) gets I<really> expensive.
How expensive you want to make each attempt is up to you and can depend on the application.
This and other KDBX-related security issues are covered here more in depth:
L<https://keepass.info/help/base/security.html>
Here are other security risks you should be thinking about:
=head2 Cryptography
This distribution uses the excellent L<CryptX> and L<Crypt::Argon2> packages to handle all crypto-related
functions. As such, a lot of the security depends on the quality of these dependencies. Fortunately these
modules are maintained and appear to have good track records.
The KDBX format has evolved over time to incorporate improved security practices and cryptographic functions.
This package uses the following functions for authentication, hashing, encryption and random number
generation:
=over 4
=item *
AES-128 (legacy)
=item *
AES-256
=item *
Argon2d & Argon2id
=item *
CBC block mode
=item *
HMAC-SHA256
=item *
SHA256
=item *
SHA512
=item *
Salsa20 & ChaCha20
=item *
Twofish
=back
At the time of this writing, I am not aware of any successful attacks against any of these functions. These
are among the most-analyzed and widely-adopted crypto functions available.
The KDBX format allows the body cipher and key derivation function to be configured. If a flaw is discovered
in one of these functions, you can hopefully just switch to a better function without needing to update this
software. A later software release may phase out the use of any functions which are no longer secure.
=head2 Memory Protection
It is not a good idea to keep secret information unencrypted in system memory for longer than is needed. The
address space of your program can generally be read by a user with elevated privileges on the system. If your
system is memory-constrained or goes into a hibernation mode, the contents of your address space could be
written to a disk where it might be persisted for long time.
There might be system-level things you can do to reduce your risk, like using swap encryption and limiting
system access to your program's address space while your program is running.
B<File::KDBX> helps minimize (but not eliminate) risk by keeping secrets encrypted in memory until accessed
and zeroing out memory that holds secrets after they're no longer needed, but it's not a silver bullet.
For one thing, the encryption key is stored in the same address space. If core is dumped, the encryption key
is available to be found out. But at least there is the chance that the encryption key and the encrypted
secrets won't both be paged out together while memory-constrained.
Another problem is that some perls (somewhat notoriously) copy around memory behind the scenes willy nilly,
and it's difficult know when perl makes a copy of a secret in order to be able to zero it out later. It might
be impossible. The good news is that perls with SvPV copy-on-write (enabled by default beginning with perl
5.20) are much better in this regard. With COW, it's mostly possible to know what operations will cause perl
to copy the memory of a scalar string, and the number of copies will be significantly reduced. There is a unit
test named F<t/memory-protection.t> in this distribution that can be run on POSIX systems to determine how
well B<File::KDBX> memory protection is working.
Memory protection also depends on how your application handles secrets. If your app code is handling scalar
strings with secret information, it's up to you to make sure its memory is zeroed out when no longer needed.
L<File::KDBX::Util/erase> et al. provide some tools to help accomplish this. Or if you're not too concerned
about the risks memory protection is meant to mitigate, then maybe don't worry about it. The security policy
of B<File::KDBX> is to try hard to keep secrets protected while in memory so that your app might claim a high
( run in 0.748 second using v1.01-cache-2.11-cpan-e1769b4cff6 )