智能合约安全-parity多重签名钱包安全漏洞
漏洞原因:
因为initWallet函数是公开函数( public function) , 攻击者调用initWallet,重新初始化钱包会把之前合约钱包所有者覆盖, 即可改变钱包所有者。
漏洞代码:
// constructor - just pass on the owner array to the multiowned and
// the limit to daylimit
function initWallet(address[] _owners, uint _required, uint _daylimit) {
initDaylimit(_daylimit);
initMultiowned(_owners, _required);
} // constructor - stores initial daily limit and records the present day's index.
function initDaylimit(uint _limit) {
m_dailyLimit = _limit;
m_lastDay = today();
} // constructor is given number of sigs required to do protected "onlymanyowners" transactions
// as well as the selection of addresses capable of confirming them.
function initMultiowned(address[] _owners, uint _required) {
m_numOwners = _owners.length + ;
m_owners[] = uint(msg.sender);
m_ownerIndex[uint(msg.sender)] = ;
for (uint i = ; i < _owners.length; ++i)
{
m_owners[ + i] = uint(_owners[i]);
m_ownerIndex[uint(_owners[i])] = + i;
}
m_required = _required;
}
修复方法:
设置 initMultiowned 和 initDaylimit 禁止外部调用,给initWallet添加only_uninitialized函数修改器,确保initWallt只被调用一次。
安全修复代码:
// throw unless the contract is not yet initialized.
modifier only_uninitialized { if (m_numOwners > ) throw; _; } // constructor - just pass on the owner array to the multiowned and
// the limit to daylimit
function initWallet(address[] _owners, uint _required, uint _daylimit) only_uninitialized {
initDaylimit(_daylimit);
initMultiowned(_owners, _required);
} // constructor - stores initial daily limit and records the present day's index.
function initDaylimit(uint _limit) internal {
m_dailyLimit = _limit;
m_lastDay = today();
} // constructor is given number of sigs required to do protected "onlymanyowners" transactions
// as well as the selection of addresses capable of confirming them.
function initMultiowned(address[] _owners, uint _required) internal {
m_numOwners = _owners.length + ;
m_owners[] = uint(msg.sender);
m_ownerIndex[uint(msg.sender)] = ;
for (uint i = ; i < _owners.length; ++i)
{
m_owners[ + i] = uint(_owners[i]);
m_ownerIndex[uint(_owners[i])] = + i;
}
m_required = _required;
}
POC
web3.eth.contract(MultiSigParityAbit).at(Vulnerable_Address).initWallet.getData([YOUR_ADDRESS], ,)
POC未测试,待测。
REF:http://shellcode.se/programming/simple-mistake-leads-to-30m-usd-theft/
智能合约安全-parity多重签名钱包安全漏洞的更多相关文章
- 【精解】EOS智能合约演练
EOS,智能合约,abi,wasm,cleos,eosiocpp,开发调试,钱包,账户,签名权限 热身 本文旨在针对EOS智能合约进行一个完整的实操演练,过程中深入熟悉掌握整个EOS智能合约的流程,过 ...
- 比特股-去中心化交易所, STEEM - 去中心化社区, EOS - 下一代智能合约
libsnark 是实现了 zkSNARK 模式的 C++ 库.zkSNARK 是一个证明/验证计算完整性的加密方法,也即零知识验证的算法, https://github.com/scipr-lab/ ...
- Solidity 智能合约开发
需要专用浏览器或部署节点支持. Solidity (中文:固态,固体)是一种语法与Javascript相似的高级语言,它为Ethereum虚拟机(EVM)编译代码而设计. Solidity是静态类型的 ...
- EOS智能合约开发(二):EOS创建和管理钱包
上节介绍了EOS智能合约开发之EOS环境搭建及启动节点 那么,节点启动后我们要做的第一件事儿是什么呢?就是我们首先要有账号,但是有账号的前提是什么呢?倒不是先创建账号,而是先要有自己的一组私钥,有了私 ...
- [转]EOS智能合约 & 私链激活 & 基本操作
链接:https://www.jianshu.com/p/90dea623ffdf 简介 本篇文章,将跟大家介绍eos私链的激活.基础智能合约的安装,以及为大家演示转账等基础操作.还没有安装eos私链 ...
- NEO智能合约开发(二)再续不可能的任务
NEO智能合约开发中,应用合约比较简单,是的你没看错,应用合约比较简单. 应用合约三部曲,发布.调用.看结果.除了看结果工具比较缺乏,发布调用neogui最起码可以支撑你测试. 鉴权合约比较麻 ...
- NEO智能合约开发(一)不可能完成的任务
悬赏任务 兹有如下合约 public static object Main(string method, object[] args) { if (Runtime.Trigger == Trigger ...
- 使用web3+solc编译发布以太坊智能合约
一.环境安装: 1.安装web3工程:npm install web3 2.安装solc工程:npm install solc二.在node环境中使用 先引用所需环境: var fs = requir ...
- BOOM -- 智能合约编程
译注:原文首发于ConsenSys开发者博客,原作者为Eva以及ConsenSys的开发团队.如果您想要获取更多及时信息,可以访问ConsenSys首页点击左下角Newsletter订阅邮件.本文的翻 ...
随机推荐
- 玩转Vim-札记(一)
玩转Vim-札记(一) 简介 在这个蔚蓝色的星球上,流传着两大神器的传说:据说Emacs是神的编辑器,而Vim是编辑器之神.一些人勇敢地拾起了Vim或Emacs,却发现学习曲线陡峭而漫长,还是有一些人 ...
- 【BZOJ 1269】文本编辑器
题目 这些日子,可可不和卡卡一起玩了,原来可可正废寝忘食的想做一个简单而高效的文本编辑器.你能帮助他吗?为了明确任务目标,可可对"文本编辑器"做了一个抽象的定义: Move k:将 ...
- 「日常训练」「小专题·图论」 Cow Contest (1-3)
题意 分析 问题是要看出来这是个floyd闭包问题.我没看出来- - 分析之后补充. 代码 // Origin: // Theme: Graph Theory (Basic) // Date: 080 ...
- React Antd中样式的修改
如果需要对antd的样式进行修改, 进入你要修改的页面 注意:不能直接在自己的文件下面,加入一个css,修改这个class的样式,应该 加入global限定,global {} , 在{}里面写入 . ...
- Jenkins - 持续集成部署
1. 安装svn:用于checkout源码 (1)yum 安装:yum -y install subversion (2)查看svn版本信息:svnserver --version 2. 安装jdk ...
- Tomcat突然用开发工具启动不起来,只报了个红色的警告,没有其他任何异常
碰到这个问题是,是因为我的catalina.bat文件做了配置修改,导致与工具这边的启动设置起了冲突 下面这个是我在Catalina.bat中新增的配置,删掉这个就可以了 set JAVA_OPTS= ...
- cocos2d-x 中菜单类
菜单相关类包含:菜单类和菜单项类,菜单类图,从类图可见Menu类继承于Layer. 菜单项类图,从图中可见所有的菜单项都是从BaseMenuItem继承而来的,BaseMenuItem是抽象类,具体使 ...
- 11-Mysql数据库----单表查询
本节重点: 单表查询 语法: 一.单表查询的语法 SELECT 字段1,字段2... FROM 表名 WHERE 条件 GROUP BY field HAVING 筛选 ORDER BY field ...
- LeetCode 全解(bug free 训练)
1.Two Sum Given an array of integers, return indices of the two numbers such that they add up to a s ...
- BZOJ 3809 Gty的二逼妹子序列 莫队算法+分块
Description Autumn和Bakser又在研究Gty的妹子序列了!但他们遇到了一个难题. 对于一段妹子们,他们想让你帮忙求出这之内美丽度∈[a,b]的妹子的美丽度的种类数. 为了方便,我们 ...