Skip to content

Commit

Permalink
fix: add cross-origin check
Browse files Browse the repository at this point in the history
We don't want to allow cross-origin requests
  • Loading branch information
cpb8010 committed Nov 26, 2024
1 parent 789dcf6 commit 3305df3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/validators/WebAuthValidator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ contract WebAuthValidator is PasskeyValidator, IModuleValidator {
bool validChallenge = false;
bool validType = false;
bool validOrigin = false;
bool invalidCrossOrigin = false;
for (uint256 index = 1; index < actualNum; index++) {
JsmnSolLib.Token memory t = tokens[index];
if (t.jsmnType == JsmnSolLib.JsmnType.STRING) {
Expand Down Expand Up @@ -97,12 +98,19 @@ contract WebAuthValidator is PasskeyValidator, IModuleValidator {

// This really only validates the origin is set
validOrigin = pubKey[0] != 0 && pubKey[1] != 0;
} else if (Strings.equal(keyOrValue, "crossOrigin")) {
JsmnSolLib.Token memory nextT = tokens[index + 1];
string memory crossOriginValue = JsmnSolLib.getBytes(clientDataJSON, nextT.start, nextT.end);
// this should only be set once, otherwise this is an error
if (!invalidCrossOrigin) {
return false;
}
invalidCrossOrigin = Strings.equal("true", typeValue);
}
// TODO: check 'cross-origin' keys as part of signature
}
}

if (!validChallenge || !validType) {
if (!validChallenge || !validType || !validOrigin || invalidCrossOrigin) {
return false;
}

Expand Down

0 comments on commit 3305df3

Please sign in to comment.