SCP-4108 Vulnerability Analysis of Marlowe Contracts #282
bwbush
started this conversation in
Architecture
Replies: 1 comment
-
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Requirements
The Summary of Testing History and Results highlights several situations where the Marlowe validator does or can not guard against Marlowe contract instances that are either partly or wholly unexecutable. There are also situations where it is unwise to deploy a particular Marlowe contract.
computeTransaction
:We need library functions and a CLI tool that allows users to check whether a contract might be subject to the above limitations.
Approach
We're considering a multi-pronged approach to analyzing contract instances to determine whether they are subject to any of these problems:
State
in the transaction can also be bounded via this method. This involves boundingaccounts
,choices
, andboundValues
at each transaction step, which is slightly tricky because it involves bounding the size ofInteger
s present.computeTransaction
along all paths identified bygetAllInputs
: The actual value of maximum-value and minimum-UTxO can be computed by semantic execution along all paths of the contract.getAllInputs
: A safe value for execution memory and steps can be computed by running all transaction paths throughevaluateScriptCounting
, which executes the validator using the Plutus interpreter. This involves creating a minimally viableScriptContext
for each transaction.getAllInputs
: A safe value for transaction size can be computed by running all transaction paths throughmakeTransactionBodyAutoBalance
. This involves creating a minimally viableTxBody
for each transaction.By "safe value" we mean that there exists some valid Cardano transaction for which the particular path will validate. It might be the case that the validator fails for a
ScriptContext
with excess inputs or outputs, but there exists an minimalScriptContext
for which it succeeds.Why take a multpronged approach? The two simple analyses above will be extremely fast for any contract. The "path-based upper bounds" method will also run fast, but it does involve full DAG traversal of the contract. Methods that rely on
getAllInputs
will be slow or impractical for large contracts.Will executing all transactions along all paths prove the safety of a contract instance? This will find all unsafe contracts, under the assumptions that
getAllInputs
returns all execution paths, thatmakeTransactionBodyAutoBlance
is faithful to the ledger and to Plutus, and that the path traversal is correct.Questions
getAllInputs
?getAllInputs
be made incremental?getAllInputs
support merkleized contracts?getAllInputs
?Implementation
Spec.Marlowe.Plutus.Transaction
already can create the minimally viableScriptContext
andSpec.Marlowe.Plutus.Scripts
supports executing scripts with the Plutus intepreter, but off chain, which is much faster than on chain.Language.Marlowe.CLI.Run
already can create the minimally viableTxBody
can catch validation and ledger errors. It runs off chain but is faithful to the chain rules.CLI interface
Beta Was this translation helpful? Give feedback.
All reactions