MySQL Forums
Forum List  »  Security

keyring_file plugin EOF error during master key writing
Posted by: Gaurav Garg
Date: April 08, 2018 01:13PM

Hello Team,

I am debugging keyring_file plugin for mysql-server.

I came across code where its writing master key to keyring storage file.

file name: mysql-server/plugin/keyring/common/keys_container.cc
actual function which is writing key in storage:
// this function actually wrting file to keyring file
bool Keys_container::flush_to_storage(IKey *key, Key_operation operation)
{
ISerialized_object *serialized_object=
keyring_io->get_serializer()->serialize(*keys_hash, key, operation);

if (serialized_object == NULL || keyring_io->flush_to_storage(serialized_object))
{
logger->log(MY_ERROR_LEVEL, "Could not flush keys to keyring");
delete serialized_object;
return TRUE;
}
delete serialized_object;
return FALSE;
}

somehow i managed to edit this key. because by default this key consist of prefix+server_uuid+key_number.

here prefix is INNODBKey
and server_uuid is your server uuid which present in configuration file.
and here key_number every time increment as we do innodb key rotation. initially its value is 1.
so initially you will get your key: INNODBKey-your_server_uuid_which_present_in_conf_file-1

so i decided to edit this and write my own key. my actual implementation is different but i managed to edit this->key_id and its writing successfully in keyring file.

but its not writing EOF value in the file.

Keyring file version:2.0�0 INNODBKey-xxxxxxxx-xxxx-xxxx-xxxx-f44d306286a6-7AES����܆�Sż�>�ugv���v��VԺS�EOFe��q=t/�̪Y�9݀SO�L�`h�;�J���


but correct value should be:

Keyring file version:1.0�. INNODBKey-xxxxxxxx-xxxx-xxe7-a08c-f44d306286a6-1AES��{�v�JQ`
�s拴P~8��j�qEOF


my question here is this:

if i do not edit this key and print this->key_id value then it will print my key value which is: INNODBKey-your_server_uuid_which_present_in_conf_file-1 whit out EOF

and after my change if i print this->key_id then it will print me:
INNODBKey-my_modified_key_id-x . both key value are same in length but question here is why its not able to write EOF at the end of keyring file as soon it write key.

its writing dummy character in keyring file after applying my change.


Thank you very much in advance :)

Thanks,

Regards,
Gaurav

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.