Skip to content

Commit 17ca457

Browse files
susnuxbackportbot[bot]
authored andcommitted
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 <opensource@fthiessen.de>
1 parent 551e360 commit 17ca457

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

core/Migrations/Version19000Date20200211083441.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
3535
]);
3636
$table->addColumn('public_key_credential_id', 'string', [
3737
'notnull' => true,
38-
'length' => 255
38+
'length' => 512
3939
]);
4040
$table->addColumn('data', 'text', [
4141
'notnull' => true,
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

+1
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,7 @@
13651365
'OC\\Core\\Migrations\\Version30000Date20240429122720' => $baseDir . '/core/Migrations/Version30000Date20240429122720.php',
13661366
'OC\\Core\\Migrations\\Version30000Date20240708160048' => $baseDir . '/core/Migrations/Version30000Date20240708160048.php',
13671367
'OC\\Core\\Migrations\\Version30000Date20240717111406' => $baseDir . '/core/Migrations/Version30000Date20240717111406.php',
1368+
'OC\\Core\\Migrations\\Version30000Date20240814180800' => $baseDir . '/core/Migrations/Version30000Date20240814180800.php',
13681369
'OC\\Core\\Notification\\CoreNotifier' => $baseDir . '/core/Notification/CoreNotifier.php',
13691370
'OC\\Core\\ResponseDefinitions' => $baseDir . '/core/ResponseDefinitions.php',
13701371
'OC\\Core\\Service\\LoginFlowV2Service' => $baseDir . '/core/Service/LoginFlowV2Service.php',

lib/composer/composer/autoload_static.php

+1
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
13981398
'OC\\Core\\Migrations\\Version30000Date20240429122720' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240429122720.php',
13991399
'OC\\Core\\Migrations\\Version30000Date20240708160048' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240708160048.php',
14001400
'OC\\Core\\Migrations\\Version30000Date20240717111406' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240717111406.php',
1401+
'OC\\Core\\Migrations\\Version30000Date20240814180800' => __DIR__ . '/../../..' . '/core/Migrations/Version30000Date20240814180800.php',
14011402
'OC\\Core\\Notification\\CoreNotifier' => __DIR__ . '/../../..' . '/core/Notification/CoreNotifier.php',
14021403
'OC\\Core\\ResponseDefinitions' => __DIR__ . '/../../..' . '/core/ResponseDefinitions.php',
14031404
'OC\\Core\\Service\\LoginFlowV2Service' => __DIR__ . '/../../..' . '/core/Service/LoginFlowV2Service.php',

0 commit comments

Comments
 (0)