From b582630715a0a671f35f507b3cd36569c3b504b6 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Wed, 14 Aug 2024 18:07:51 +0200 Subject: fix(webauthn): Increase database column for public key id * Resolves https://github.com/nextcloud/server/issues/34476 There is no maximum length defined in the standard, most common the length is between 128 and 200 characters, but as we store it not in plain data but base64 encoded the length can grow about 1/3. We had a regression with 'Nitrokey 3' which created IDs with 196 byte length -> 262 bytes encoded base64. So to be save we increase the size to 512 bytes. Signed-off-by: Ferdinand Thiessen --- core/Migrations/Version19000Date20200211083441.php | 2 +- core/Migrations/Version30000Date20240814180800.php | 37 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 core/Migrations/Version30000Date20240814180800.php (limited to 'core') diff --git a/core/Migrations/Version19000Date20200211083441.php b/core/Migrations/Version19000Date20200211083441.php index 4b361149b30..2f8b46ad772 100644 --- a/core/Migrations/Version19000Date20200211083441.php +++ b/core/Migrations/Version19000Date20200211083441.php @@ -35,7 +35,7 @@ class Version19000Date20200211083441 extends SimpleMigrationStep { ]); $table->addColumn('public_key_credential_id', 'string', [ 'notnull' => true, - 'length' => 255 + 'length' => 512 ]); $table->addColumn('data', 'text', [ 'notnull' => true, diff --git a/core/Migrations/Version30000Date20240814180800.php b/core/Migrations/Version30000Date20240814180800.php new file mode 100644 index 00000000000..199af8cc0aa --- /dev/null +++ b/core/Migrations/Version30000Date20240814180800.php @@ -0,0 +1,37 @@ +getTable('webauthn'); + $column = $table->getColumn('public_key_credential_id'); + + /** + * There is no maximum length defined in the standard, + * most common the length is between 128 and 200 characters, + * but as we store it not in plain data but base64 encoded the length can grow about 1/3. + * We had a regression with 'Nitrokey 3' which created IDs with 196 byte length -> 262 bytes encoded base64. + * So to be save we increase the size to 512 bytes. + */ + if ($column->getLength() < 512) { + $column->setLength(512); + } + + return $schema; + } +} -- cgit v1.2.3