Skip to content

Commit

Permalink
Add john fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nivcertora committed Aug 21, 2024
1 parent 2299bce commit d4a9be6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
20 changes: 16 additions & 4 deletions certora/specs/SafeWebAuthnSignerFactory.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,29 @@ methods{

function WebAuthnHarness.checkInjective(bytes32 challenge, bytes32 authenticatorData, bytes32 clientDataFields, bytes32 result) internal returns (bool) =>
checkInjectiveSummary(challenge, authenticatorData, clientDataFields, result);
function _.isValidSignature(bytes32,bytes) external => DISPATCHER(optimistic=true, use_fallback=true);

function _._ external => DISPATCH [
proxy._,
singleton._
] default NONDET;
}

function GETencodeSigningMessageCVL(bytes32 challenge, bytes authenticatorData, string clientDataFields) returns bytes
{
env e;
return WebAuthnHarness.GETencodeSigningMessageSummary(e, challenge, authenticatorData, clientDataFields);
ghost mapping(bytes32 => mapping(bytes32 => mapping(bytes32 => bytes32))) componentToEncodeHash;
ghost mapping(bytes32 => bytes32) revChallenge;
ghost mapping(bytes32 => bytes32) revAuthenticator;
ghost mapping(bytes32 => bytes32) revClientData;

function GETencodeSigningMessageCVL(bytes32 challenge, bytes authenticatorData, string clientDataFields) returns bytes {
bytes32 authHash = keccak256(authenticatorData);
bytes32 clientHash = keccak256(clientDataFields);
bytes32 toRetHash = componentToEncodeHash[challenge][authHash][clientHash];
require(revChallenge[toRetHash] == challenge);
require(revAuthenticator[toRetHash] == authHash);
require(revClientData[toRetHash] == clientHash);
bytes toRet;
require keccak256(toRet) == toRetHash;
return toRet;
}

ghost checkInjectiveSummary(bytes32, bytes32, bytes32, bytes32) returns bool {
Expand Down
19 changes: 15 additions & 4 deletions certora/specs/SafeWebAuthnSignerSingleton.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@ methods {
function SafeWebAuthnSignerFactory.getSigner(uint256 x, uint256 y, P256.Verifiers v) internal returns (address) => getSignerGhost(x, y, v);
}

function GETencodeSigningMessageCVL(bytes32 challenge, bytes authenticatorData, string clientDataFields) returns bytes
{
env e;
return WebAuthnHarness.GETencodeSigningMessageSummary(e, challenge, authenticatorData, clientDataFields);
ghost mapping(bytes32 => mapping(bytes32 => mapping(bytes32 => bytes32))) componentToEncodeHash;
ghost mapping(bytes32 => bytes32) revChallenge;
ghost mapping(bytes32 => bytes32) revAuthenticator;
ghost mapping(bytes32 => bytes32) revClientData;

function GETencodeSigningMessageCVL(bytes32 challenge, bytes authenticatorData, string clientDataFields) returns bytes {
bytes32 authHash = keccak256(authenticatorData);
bytes32 clientHash = keccak256(clientDataFields);
bytes32 toRetHash = componentToEncodeHash[challenge][authHash][clientHash];
require(revChallenge[toRetHash] == challenge);
require(revAuthenticator[toRetHash] == authHash);
require(revClientData[toRetHash] == clientHash);
bytes toRet;
require keccak256(toRet) == toRetHash;
return toRet;
}

ghost checkInjectiveSummary(bytes32, bytes32, bytes32, bytes32) returns bool {
Expand Down
4 changes: 0 additions & 4 deletions certora/specs/WebAuthn.spec
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ rule verifySignatureConsistent(){
env e1;
env e2;
require e1.msg.value == 0 && e2.msg.value == 0;
method f;
calldataarg args;

bytes32 challenge;
Expand All @@ -127,7 +126,6 @@ rule verifySignatureConsistent(){
bool result1 = verifySignature@withrevert(e1, challenge, bytesSignature, authenticatorFlags, x, y, verifiers);
bool firstCallRevert = lastReverted;

f(e, args);

bool result2 = verifySignature@withrevert(e2, challenge, bytesSignature, authenticatorFlags, x, y, verifiers);
bool secondCallRevert = lastReverted;
Expand All @@ -150,7 +148,6 @@ rule castSignatureConsistent(){

require (e1.msg.value == e2.msg.value) && (e1.msg.value == e.msg.value) && (e.msg.value == 0);

method f;
calldataarg args;

bytes signature;
Expand All @@ -164,7 +161,6 @@ rule castSignatureConsistent(){
firstIsValid, firstData = castSignature@withrevert(e1, signature);
bool firstRevert = lastReverted;

f(e, args);

secondIsValid, secondData = castSignature@withrevert(e2, signature);
bool secondRevert = lastReverted;
Expand Down

0 comments on commit d4a9be6

Please sign in to comment.