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

Invalid crypt key after restart of Firebird [CORE5836] #6097

Closed
firebird-automations opened this issue May 29, 2018 · 12 comments
Closed

Invalid crypt key after restart of Firebird [CORE5836] #6097

firebird-automations opened this issue May 29, 2018 · 12 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Daniel Mazur (danielmazur)

ALTER DATABASE ENCRYPT WITH cryptPlugin works fine after fix in 3.0.4 snapshot but i have found another critical bug.
Encryption and decryption works fine but after restart of FB, there is Exception Invalid crypt key (and this is surely not fault of my code, checked it twice)
The temporary fix is to use

ALTER DATABASE ENCRYPT WITH cryptPlugin KEY SOMELETTERS

With this, after encryption and restart of FB, everything works fine.
I think that now FB without KEY KEYNAME writes into db file random data (there wasn't issue with 3.0.3 official version)
Note: ALTER DATABASE DECRYPT is not affected

@firebird-automations
Copy link
Collaborator Author

Commented by: Daniel Mazur (danielmazur)

After few minutes got Internal coisitence error, after recreating connection I saw error
"Invalid crypt key KEYNAME"

I will check it on new snapshot and 64bit (FB on my machine is 32bit right now)

EDIT: To be clear, I do not use keyholder
EDIT2: On latest snapshot it gives error to after restart

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

assignee: Alexander Peshkov [ alexpeshkoff ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

priority: Critical [ 2 ] => Major [ 3 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Not reproduced.

Encrypt:
alex@alex-Vostro-15-3568:~/firebird/B3_0_Release/gen/Debug/firebird/bin$ ./isql -user sysdba -pas masterkey localhost:employee
Database: localhost:employee, User: SYSDBA
SQL> alter database encrypt with "DbCrypt_example";
SQL> ^D

Restart server:
alex@alex-Vostro-15-3568:~/firebird/B3_0_Release/gen/Debug/firebird/bin$ %1
./firebird
^Calex@alex-Vostro-15-3568:~/firebird/B3_0_Release/gen/Debug/firebird/bin$
alex@alex-Vostro-15-3568:~/firebird/B3_0_Release/gen/Debug/firebird/bin$ ./firebird& [1] 30311

Check database:
alex@alex-Vostro-15-3568:~/firebird/B3_0_Release/gen/Debug/firebird/bin$ ./isql -user sysdba -pas masterkey localhost:employee
Database: localhost:employee, User: SYSDBA
SQL> show db;
Database: localhost:employee
...................
Database encrypted

@firebird-automations
Copy link
Collaborator Author

Commented by: Daniel Mazur (danielmazur)

Please try in windows environment
EDIT: Also there was't problem with that on 3.0.3

EDIT: On 64bit version of latest snapshot 32980 got this after restart (I can do everything with encrypted database until restart):

[Window Title]
Unhandled Error in FlameRobin

[Content]
*** IBPP::SQLException ***
Context: Database::Connect
Message: isc_attach_database failed

SQL Message : -902
can't format message 13:98 -- message file C:\WINDOWS\SYSTEM32\firebird.msg not found

Engine Code : 335544333
Engine Message :
internal Firebird consistency check (decompression overran buffer (179), file: sqz.cpp line: 293)
IProvider::attachDatabase failed when loading mapping cache

[OK]

@firebird-automations
Copy link
Collaborator Author

Commented by: @hvlad

Daniel,

i just check current snapshot with cryptDb sample - it works as expected.
Both 32 and 64 bit.

Please, explain:
> After few minutes got Internal coisitence error, after recreating connection I saw error
"Invalid crypt key KEYNAME"

what exact consistence error ? any message in firebird.log ?
what was done in that few minutes ?

> On latest snapshot it gives error to after restart
Do you mean "On latest snapshot it gives error too, after restart" ?

Could you try with cryptDb sample ?

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Daniel, please add new comments when you answer instead editing old one.

Is that behavior reproduced with an example plugin?

@firebird-automations
Copy link
Collaborator Author

Commented by: Daniel Mazur (danielmazur)

Hard to say. Look, I've moved all my local variables from encrypt and decrypt function into global scope. DLL has to start working after restart but while writing few thousand recods i got this:

internal Firebird consistency check (can't continue after bugcheck)

I may try with sample plugin but there is only xor 5 and no use of local variables.
I think it may be issue with overwriting my keyTable by Firebird (Stack Overflow ??)

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Cannot Reproduce [ 5 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Stack overflow in firebird caused by restart? No, I do not accept that.
According to old rule related with segfaults in UDFs I've closed a ticket.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: Daniel Mazur (danielmazur)

Not by restart, on latest snapshot I have found the place with fbtracemgr the query which making a error.

INSERT INTO(...)

param0 = integer, "2"
param1 = bigint(*, -4), "5005.3100"
param2 = bigint(*, -4), "0"
param3 = integer, "25772"
param4 = integer, "201825772"
param5 = integer, "82"
param6 = date, "2018-05-30"
param7 = date, "2018-05-30"
param8 = date, "2018-05-30"
param9 = integer, "0"
param10 = smallint, "1"
param11 = smallint, "0"
param12 = smallint, "0"
param13 = integer, "0"
param14 = integer, "104379"
param15 = date, "2018-05-30"
param16 = integer, "693244"
param17 = integer, "1"
param18 = smallint, "0"
param19 = integer, "8"
param20 = float, "1"
param21 = date, "2018-05-30"
param22 = bigint(*, -4), "5005.3100"
param23 = bigint(*, -4), "0"
param24 = smallint, "0"
param25 = bigint(*, -6), "5005.310000"
param26 = bigint(*, -6), "0"
param27 = varchar(20), "200000000"
param28 = varchar(20), "S różne"
param29 = varchar(2), "FA"
...5 more arguments skipped...

2018-05-30T09:48:38.0610 (7892:0000000007A30040) EXECUTE_TRIGGER_START
DBFILE (ATT_131, SYSDBA:NONE, WIN1250, XNET:)
PROCESS:5832
(TRA_19412, READ_COMMITTED | REC_VERSION | NOWAIT | READ_WRITE)
TRIGGERNAME FOR TABLENAME(BEFORE INSERT)

2018-05-30T09:48:38.0890 (7892:0000000007A30040) ERROR AT JStatement::execute
DBFILE (ATT_131, SYSDBA:NONE, WIN1250, XNET:)
PROCESS:5832
335544333 : internal Firebird consistency check (index inconsistent (204), file: btr.cpp line: 4560)

I will try with dbcrypt example now

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

No branches or pull requests

2 participants