Skip to content

Commit 264f29e

Browse files
committed
fix(webauthn): Increase database column for public key id
* Resolves #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 <[email protected]>
1 parent aa7f5ac commit 264f29e

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

core/Migrations/Version19000Date20200211083441.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
5353
]);
5454
$table->addColumn('public_key_credential_id', 'string', [
5555
'notnull' => true,
56-
'length' => 255
56+
'length' => 512
5757
]);
5858
$table->addColumn('data', 'text', [
5959
'notnull' => true,
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
7+
* SPDX-License-Identifier: AGPL-3.0-or-later
8+
*/
9+
namespace OC\Core\Migrations;
10+
11+
use Closure;
12+
use OCP\DB\ISchemaWrapper;
13+
use OCP\Migration\IOutput;
14+
use OCP\Migration\SimpleMigrationStep;
15+
16+
class Version30000Date20240814180800 extends SimpleMigrationStep {
17+
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
18+
/** @var ISchemaWrapper $schema */
19+
$schema = $schemaClosure();
20+
21+
$table = $schema->getTable('webauthn');
22+
$column = $table->getColumn('public_key_credential_id');
23+
24+
/**
25+
* There is no maximum length defined in the standard,
26+
* most common the length is between 128 and 200 characters,
27+
* but as we store it not in plain data but base64 encoded the length can grow about 1/3.
28+
* We had a regression with 'Nitrokey 3' which created IDs with 196 byte length -> 262 bytes encoded base64.
29+
* So to be save we increase the size to 512 bytes.
30+
*/
31+
if ($column->getLength() < 512) {
32+
$column->setLength(512);
33+
}
34+
35+
return $schema;
36+
}
37+
}

lib/composer/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,7 @@
12791279
'OC\\Core\\Migrations\\Version29000Date20240124132201' => $baseDir . '/core/Migrations/Version29000Date20240124132201.php',
12801280
'OC\\Core\\Migrations\\Version29000Date20240124132202' => $baseDir . '/core/Migrations/Version29000Date20240124132202.php',
12811281
'OC\\Core\\Migrations\\Version29000Date20240131122720' => $baseDir . '/core/Migrations/Version29000Date20240131122720.php',
1282+
'OC\\Core\\Migrations\\Version30000Date20240814180800' => $baseDir . '/core/Migrations/Version30000Date20240814180800.php',
12821283
'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
12831284
'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php',
12841285
'OC\\DB\\Adapter' => $baseDir . '/lib/private/DB/Adapter.php',

lib/composer/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,6 +1312,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
13121312
'OC\\Core\\Migrations\\Version29000Date20240124132201' => __DIR__ . '/../../..' . '/core/Migrations/Version29000Date20240124132201.php',
13131313
'OC\\Core\\Migrations\\Version29000Date20240124132202' => __DIR__ . '/../../..' . '/core/Migrations/Version29000Date20240124132202.php',
13141314
'OC\\Core\\Migrations\\Version29000Date20240131122720' => __DIR__ . '/../../..' . '/core/Migrations/Version29000Date20240131122720.php',
1315+
'OC\\Core\\Migrations\\Version30000Date20240814180800' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240814180800.php',
13151316
'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php',
13161317
'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php',
13171318
'OC\\DB\\Adapter' => __DIR__ . '/../../..' . '/lib/private/DB/Adapter.php',

0 commit comments

Comments
 (0)