fix(agent_registry): authenticate transaction registration/completion and forbid self-rating (#77) - #211
Open
Vyacheslav-Tomashevskiy wants to merge 1 commit into
Conversation
4 tasks
… and forbid self-rating (vespera-labs#77) register_transaction was unauthenticated, letting anyone fabricate transaction records for arbitrary agents and parties. complete_transaction never called require_auth on the agent, so anyone could complete on the agent's behalf and inflate completed_agreements; it also re-counted on repeated calls. rate_agent had no self-rating guard. - register_transaction now takes a caller, requires its auth, and only accepts the agent or a listed party; parties must be non-empty, distinct, and must not include the agent (which also forecloses self-rating). - complete_transaction now calls agent.require_auth() and rejects double-completion (TransactionAlreadyCompleted). - rate_agent rejects rater == agent (SelfRatingNotAllowed). - 8 new adversarial tests; existing transaction tests updated to the new register_transaction signature. cargo test 31 passed; fmt + clippy clean.
Vyacheslav-Tomashevskiy
force-pushed
the
fix/agent-registry-auth-77
branch
from
June 30, 2026 12:48
4d99428 to
6fcf50e
Compare
Author
|
Rebased onto latest
RTC wallet for payout: RTCd1554f0f35576faf01d386a6be1c947f560dd0b7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #77 —
[Security] agent_registry register_transaction and complete_transaction are unauthenticated, letting reputation be fabricated.Problem
In
contracts/agent_registry/src/agent.rs:register_transactionnever calledrequire_authon anyone, so any caller could createAgentTransactionrecords with an attacker-chosen agent and parties.complete_transactiononly compared the suppliedagentto stored state but never calledagent.require_auth(), so anyone could complete on the agent's behalf and bumpcompleted_agreements. It also re-incrementedcompleted_agreementson every repeated call.rate_agenthad norater != agentguard.Combined, one actor could manufacture transactions, complete them, and rate any verified agent at will.
Fix
register_transactionnow takes acaller: Address, callscaller.require_auth(), and requires the caller to be the agent or one of the listed parties.partiesmust be non-empty, all distinct, and must not include the agent — parties are the counterparties who may later rate, so excluding the agent forecloses self-rating at the source (InvalidParties).complete_transactionnow callsagent.require_auth()and rejects double-completion withTransactionAlreadyCompleted, socompleted_agreementscan be bumped at most once per transaction and only by the agent.rate_agentrejectsrater == agentwithSelfRatingNotAllowed(defense-in-depth alongside the register-time exclusion). The existing party / completed / already-rated checks are kept.New errors:
SelfRatingNotAllowed = 14,InvalidParties = 15,TransactionAlreadyCompleted = 16.Acceptance criteria
register_transactionauthenticates a legitimate party and validates parties are distinct/real (non-empty, no duplicates, not the agent)complete_transactioncallsrequire_authon the agentrate_agentrejects self-rating and only allows a real party of a completed transaction to rate, onceTests
8 new adversarial tests (caller auth required for register/complete; non-participant caller rejected; agent-in-parties / duplicate / empty parties rejected; party caller allowed; double-completion rejected); existing transaction tests updated to the new
register_transactionsignature.Scope / breaking change
register_transactiongains a leadingcaller: Addressparameter (deliberate — required to authenticate the registrant). Out of scope per the issue: weighting reputation by transaction value, cross-contract verification.RTC payout wallet:
RTCd1554f0f35576faf01d386a6be1c947f560dd0b7