Skip to content

Commit

Permalink
Fix issue in createFidoAttestationStatementFromU2fRegisterResponse
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=272698
rdar://125024119

Reviewed by Charlie Wolfe.

Since the x509 length here is user supplied, the addition of the offset
could overflow. We fix this issue by using the CheckedArithmetic header.

Canonical link: https://commits.webkit.org/272448.931@safari-7618-branch
  • Loading branch information
Pascoe committed Apr 15, 2024
1 parent 2c47832 commit 595fc45
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "FidoConstants.h"
#include "WebAuthenticationConstants.h"
#include "WebAuthenticationUtils.h"
#include <wtf/CheckedArithmetic.h>

namespace fido {
using namespace WebCore;
Expand Down Expand Up @@ -116,7 +117,10 @@ static size_t parseX509Length(const Vector<uint8_t>& u2fData, size_t offset)
static cbor::CBORValue::MapValue createFidoAttestationStatementFromU2fRegisterResponse(const Vector<uint8_t>& u2fData, size_t offset)
{
auto x509Length = parseX509Length(u2fData, offset);
if (!x509Length || u2fData.size() < offset + x509Length)
auto requiredLength = CheckedSize { x509Length } + offset;
if (requiredLength.hasOverflowed())
return { };
if (!x509Length || u2fData.size() < requiredLength)
return { };

Vector<uint8_t> x509 { u2fData.data() + offset, x509Length };
Expand Down

0 comments on commit 595fc45

Please sign in to comment.