Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 681690 - app-admin/keepassxc-2.4.0: cannot open database with legacy keyfile
Summary: app-admin/keepassxc-2.4.0: cannot open database with legacy keyfile
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Lars Wendler (Polynomial-C) (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-24 22:38 UTC by artbx
Modified: 2019-04-22 07:53 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge_info.txt,6.91 KB, text/plain)
2019-03-24 22:38 UTC, artbx
Details
info from keepassxc 2.4.0 (keepassxc.png,101.60 KB, image/png)
2019-03-25 11:12 UTC, artbx
Details
by hand build shows some strange info about snapshoot (keepassxc2.png,79.29 KB, image/png)
2019-03-25 11:29 UTC, artbx
Details
additional info about snapshoot (keepassxc3.png,104.30 KB, image/png)
2019-03-25 11:31 UTC, artbx
Details

Note You need to log in before you can comment on or make changes to this bug.
Description artbx 2019-03-24 22:38:02 UTC
Created attachment 570682 [details]
emerge --info

When i upgrade to app-admin/keepassxc-2.4.0 it cannot open database created be earlier versions. It shows error that databse is broken or key invalid hovever when i revert back to keepassxc-2.3.4-r1 everything is ok.
Comment 1 Jeroen Roovers (RETIRED) gentoo-dev 2019-03-24 22:40:58 UTC
Can you please post the output that you refer to, redacted if needed of course.
Comment 2 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2019-03-25 08:32:51 UTC
Where is your keepassxc database located? If it's on some external storage (USB-device, CIFS- or NFS-mount), does this error message still appear if you copy the database to your ${HOME} directory and open it from there?
Comment 3 artbx 2019-03-25 11:12:39 UTC
Created attachment 570706 [details]
info from keepassxc 2.4.0

The error presented by keepassxc 2.4.0
Comment 4 artbx 2019-03-25 11:13:23 UTC
I attached screenshoot form keepassxc 2.4.0.
Location of database is subfolder at home directory on ext4
Comment 5 artbx 2019-03-25 11:29:21 UTC
Created attachment 570708 [details]
by hand build shows some strange info about snapshoot

I took keepassxc-2.4.0.tar.gz from distfiles

usr/portage/distfiles $ ls -la keepassxc-2.4.0.tar.gz 
-rw-rw-r-- 1 portage portage 4790634 03-20 12:52 keepassxc-2.4.0.tar.gz

and build it by hand and then run.
It shows that this file keepassxc-2.4.0.tar.gz in distfiles is not release one but some snapshoot ..
Comment 6 artbx 2019-03-25 11:31:33 UTC
Created attachment 570710 [details]
additional info about snapshoot
Comment 7 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2019-03-25 11:34:07 UTC
(In reply to artbx from comment #5)
> Created attachment 570708 [details]
> by hand build shows some strange info about snapshoot
> 
> I took keepassxc-2.4.0.tar.gz from distfiles
> 
> usr/portage/distfiles $ ls -la keepassxc-2.4.0.tar.gz 
> -rw-rw-r-- 1 portage portage 4790634 03-20 12:52 keepassxc-2.4.0.tar.gz
> 
> and build it by hand and then run.
> It shows that this file keepassxc-2.4.0.tar.gz in distfiles is not release
> one but some snapshoot ..

That is just some inconvenience in the build system of keepassxc. Add

  -DOVERRIDE_VERSION="2.4.0" 

to your build flags and that warning is gone.
Comment 8 artbx 2019-03-25 11:45:16 UTC
I've checked custom release builds with clang/gcc, debug with clang, without luck, same as ebuild one.

Nothing in debug info except

./src/keepassxc
QObject::startTimer: Timers cannot have negative intervals
QWidgetWindow(0x5645473a0060, name="centralwidgetWindow") must be a top level window.
QWidgetWindow(0x5645473a0060, name="centralwidgetWindow") must be a top level window.
Comment 9 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2019-03-25 11:57:10 UTC
Are you using a keyfile?
Comment 10 artbx 2019-03-25 12:20:33 UTC
yes, it was shown on screenshots.
Comment 11 artbx 2019-03-25 12:49:14 UTC
I've checked it on second machine aarch64 and kpxc 2.4.0  doesn't work too, while 2.3 works ok, same behavior as on amd64.
I can add info that this database begining was quite a long time ago, it was first created in 2013-10-18, and used successfully with all earlier keepass, keepassx, keepassxc versions.
Last update to database was with keepassxc 2.3.4-r1.

Propably i found a reson.
On aarch 2.3.4-r1 showed me info that im using dperecated key format that would not be supported in the future.
This become more understandable to me what's going on with 2.4, but KPXC 2.4 should present info that key is no longer supported instead of giving info that database is broken or key invalid, and give a clue how to upgrade it.

Btw I i've noidea how to upgrade key.
Comment 13 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2019-03-25 13:38:17 UTC
From an IRC conversation I had about your bug:

14:35:11 <@phoerious> If it's just the warning, then tell him to ignore it or create a new keyfile. If it's an error, then it's a bug and you should tell him to generate a new keyfile as well.
14:35:44 <@phoerious> Open it in KeePassXC 2.3.4, generate a new key file, save db.
Comment 14 artbx 2019-03-25 13:51:09 UTC
I understand i can create new keyfile, however i don't see a reson to do so.
If only the keyformat is becomong unsppported it should allow me to upgrade the keyformat instead of requiring me to generate a new keyfile and distribute in on all may machines which is a bit rudiculus, time consuming, and im going to stay with 3.4.1 as long as it will be possible.

People from keepass have a good point of view on that:

Dominik Reichl - 6 days ago 
"As soon as the support for some of the key file formats would be removed (i.e. no warning anymore), these users wouldn't be able to open their databases anymore, which is unacceptable."
[..]
"Therefore, I think that full backward compatibility here is more important than a small complexity reduction. So, I'm not going to deprecate any of the formats. "

https://sourceforge.net/p/keepass/feature-requests/2434/
Comment 15 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2019-03-25 14:07:34 UTC
(In reply to artbx from comment #14)
> I understand i can create new keyfile, however i don't see a reson to do so.
> If only the keyformat is becomong unsppported it should allow me to upgrade
> the keyformat instead of requiring me to generate a new keyfile and
> distribute in on all may machines which is a bit rudiculus, time consuming,
> and im going to stay with 3.4.1 as long as it will be possible.
> 
> People from keepass have a good point of view on that:
> 
> Dominik Reichl - 6 days ago 
> "As soon as the support for some of the key file formats would be removed
> (i.e. no warning anymore), these users wouldn't be able to open their
> databases anymore, which is unacceptable."
> [..]
> "Therefore, I think that full backward compatibility here is more important
> than a small complexity reduction. So, I'm not going to deprecate any of the
> formats. "
> 
> https://sourceforge.net/p/keepass/feature-requests/2434/

It's not up to me as package maintainer to judge keppassxc upstream decisions. If you really wanna have that fixed, please go to their GitHub page [1] and file a support request or comment on the already existing issue 2037

[1]: https://github.com/keepassxreboot/keepassxc/issues
Comment 16 artbx 2019-03-25 14:29:25 UTC
Sure.
Comment 17 artbx 2019-03-25 21:32:59 UTC
I've checked code, and debugged keppassxc 2.4.0
- Leagcy code is still present and enabled by efault
- there is a bug in regexp that causing 
-- not to laod xml data from key
-- at next if process it as binary hash

In code the line Tools::isBase64(rawData) returns false for valid base64 data from XML node, thus causing to fail loading my key as xml and then treating it as binary hash.
When I comment it out like below everyting works ok with leagcy key in 2.4.0

keepassxc-2.4.0/src/keys/FileKey.cpp

QByteArray FileKey::loadXmlKey(QXmlStreamReader& xmlReader)
{
    QByteArray data;

    while (!xmlReader.error() && xmlReader.readNextStartElement()) {
        if (xmlReader.name() == "Data") {
            QByteArray rawData = xmlReader.readElementText().toLatin1();
//             if (Tools::isBase64(rawData)) {
                data = QByteArray::fromBase64(rawData);
//             }
        }
    }

- So the buggy code is 2.4.0

    bool isBase64(const QByteArray& ba)
    {
        constexpr auto pattern = R"(^(?:[a-z0-9+]{4})*(?:[a-z0-9+]{3}=|[a-z0-9+]{2}==)?$)";
        QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::RegExp2);

        QString base64 = QString::fromLatin1(ba.constData(), ba.size());

        return regexp.exactMatch(base64);
    }

- and 2.3.4 working one

bool isBase64(const QByteArray& ba)
{
    QRegExp regexp("^(?:[a-z0-9+/]{4})*(?:[a-z0-9+/]{3}=|[a-z0-9+/]{2}==)?$",
                   Qt::CaseInsensitive, QRegExp::RegExp2);

    QString base64 = QString::fromLatin1(ba.constData(), ba.size());

    return regexp.exactMatch(base64);
}
    return data;
}
Comment 18 artbx 2019-03-25 21:45:22 UTC
Except the literal R witch means raw data, there are missing / and propably author make an error and tought about them as escape characters \ which would not be required with literal R"()" sequence and removed them.

R"(^(?:[a-z0-9+]{4})*(?:[a-z0-9+]{3}=|[a-z0-9+]{2}==)?$)";
  "^(?:[a-z0-9+/]{4})*(?:[a-z0-9+/]{3}=|[a-z0-9+/]{2}==)?$"
Comment 19 Lars Wendler (Polynomial-C) (RETIRED) gentoo-dev 2019-04-20 19:03:53 UTC
Should be fixed with >=app-admin/keepassxc-2.4.1
Comment 20 artbx 2019-04-22 07:53:09 UTC
Yes, it is.