Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add cross-origin check #200

Merged
merged 4 commits into from
Nov 26, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
ly0va marked this conversation as resolved.
Show resolved Hide resolved
invalidCrossOrigin = Strings.equal("true", crossOriginValue);
}
// TODO: check 'cross-origin' keys as part of signature
}
}

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

Expand Down