Skip to content

Feat/smart account blind signing fix#229

Open
hard-nett wants to merge 7 commits intomainfrom
feat/smart-account-blind-signing-fix
Open

Feat/smart account blind signing fix#229
hard-nett wants to merge 7 commits intomainfrom
feat/smart-account-blind-signing-fix

Conversation

@hard-nett
Copy link
Collaborator

This pr aims to resolve UX issues when registering composite authenticators. Specifically, SubAuthenticators config data ends up as raw binary in UI's of wallets when a user is adding a composite authenticator (anyOf,allOf). This is a security vector that limits the verification of what a user is actually approving, especially for such a critical action like delegated authorization of actions for a users wallet.

The solution is to update the config values expected for MsgAddAuthenticator to replace data byes expected with AuthenticatorConfig, that defines a oneOf parameter for either raw string or bytes (preserving backwards compatibility).

This allows authenticators to retain the decision on how to compose the data structure set in its parameters, for example here is what the SignatureVerification expects to be passed as the config data when adding an authenticator:

       // a. register a single `SignatureVerification` authenticator using raw bytes of public key being authorized
	key := "6cf5103c60c939a5f38e383b52239c5296c968579eec1c68a47d70fbf1d19159"
	bz, _ := hex.DecodeString(key)
	priv := &secp256k1.PrivKey{Key: bz}
        // use bytes
	_, err := s.App.SmartAccountKeeper.AddAuthenticator(
		ctx,
		accAddress,
		"SignatureVerification",
		priv.PubKey().Bytes(),
	)
	// b. registering a `SingleVerification` authenticator as a part of a composite `allOf` authenticator,
       // using pubkey string proto.Message:
	initDataSig := sat.SubAuthenticatorInitData{
		Type: "SignatureVerification",
		Config: &sat.AuthenticatorConfig{
			// The protobuf one‑of “value_string” is filled with the SDK‑style
			// string, e.g.  "PubKeySecp256k1{033C6F20...}"
			Data: &sat.AuthenticatorConfig_ValueString{
				ValueString: priv.PubKey().String(),
			},
		},
	}
	compositeData, err := json.Marshal([]sat.SubAuthenticatorInitData{initDataSig})
	_, err = keeper.AddAuthenticator(
		ctx,
		accAddress,
		"AllOf", // parent composite type
		compositeData,
	)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant