Skip to content

Commit

Permalink
fix(webauthn): Increase database column for public key id
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
susnux committed Aug 14, 2024
1 parent fb90e7e commit 255f44c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/Migrations/Version19000Date20200211083441.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
]);
$table->addColumn('public_key_credential_id', 'string', [
'notnull' => true,
'length' => 255
'length' => 512
]);
$table->addColumn('data', 'text', [
'notnull' => true,
Expand Down
37 changes: 37 additions & 0 deletions core/Migrations/Version30000Date20240814180800.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\Core\Migrations;

use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;

class Version30000Date20240814180800 extends SimpleMigrationStep {
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options) {
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();

$table = $schema->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;
}
}

0 comments on commit 255f44c

Please sign in to comment.