<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alexander Seleznev on Medium]]></title>
        <description><![CDATA[Stories by Alexander Seleznev on Medium]]></description>
        <link>https://medium.com/@alexanderseleznev?source=rss-e1a3d7ba9753------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*aXz4Zbunk0j_mOIAM587Kg.jpeg</url>
            <title>Stories by Alexander Seleznev on Medium</title>
            <link>https://medium.com/@alexanderseleznev?source=rss-e1a3d7ba9753------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 14:07:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alexanderseleznev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Tigereum Smart Contracts Security Analysis]]></title>
            <link>https://medium.com/smartdec/tigereum-smart-contracts-security-analysis-8e628c8160f3?source=rss-e1a3d7ba9753------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e628c8160f3</guid>
            <category><![CDATA[audit]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Alexander Seleznev]]></dc:creator>
            <pubDate>Mon, 27 Aug 2018 11:57:10 GMT</pubDate>
            <atom:updated>2018-08-27T13:12:33.634Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xV0ZJW_-zxtF4HD6y-EU_g.jpeg" /></figure><p><em>In this report we consider the security of the </em><a href="https://www.tigereum.io/"><em>Tigereum</em></a><em> project. Our task is to find and describe security issues in the smart contracts of the platform.</em></p><blockquote><strong>This audit was performed on December 21st, 2017.</strong></blockquote><h3>Procedure</h3><p>In our analysis we consider Tigereum <a href="https://docs.wixstatic.com/ugd/970dc6_2c6e379920be4d38afb324a8aa076df4.pdf">whitepaper</a> (sha1sum 0a21f688e1b7eddceaf9285bdbb49fdd0607af65 *970dc6_2c6e379920be4d38afb324a8aa076df4.pdf) and smart contracts code (sha1sum 02805d71084468f6c16db7a1c7115a6319cc9361 *tgICOv1.zip).</p><p>We perform our audit according to the following procedure:</p><p><strong>Automated analysis</strong></p><ul><li>we scan project’s smart contracts with our own Solidity static code analyzer <a href="https://tool.smartdec.net/">SmartCheck</a></li><li>we scan project’s smart contracts with several publicly available automated Solidity analysis tools such as <a href="https://remix.ethereum.org/">Remix</a>, <a href="https://oyente.melon.network/">Oyente</a>, <a href="http://securify.ch/">Securify</a> (beta version since full version was unavailable at the moment this report was made), and <a href="https://protofire.github.io/solhint/">Solhint</a>.</li><li>we manually verify (reject or confirm) all the issues found by tools</li></ul><p><strong>Manual</strong> <strong>audit</strong></p><ul><li>we manually analyze smart contracts for security vulnerabilities</li><li>we check smart contracts logic and compare it with the one described in the whitepaper</li></ul><p><strong>Report</strong></p><ul><li>we report all the issues found to the developer during the audit process</li><li>we check the issues fixed by the developer</li><li>we reflect all the gathered information in the report</li></ul><h3>The latest version of the code</h3><p>We have performed the check of the vulnerabilities fixed by the developer in the latest version of code — sha1sum ca2fbd84c203c6757e2e4a00f148a7673ed1aecf *tgICOv7.zip.</p><h3>Disclaimer</h3><p>The audit does not give any warranties on the security of the code. One audit can not be considered enough. We always recommend proceeding to several independent audits and a public bug bounty program to ensure the security of the smart contracts.</p><h3>Checked vulnerabilities</h3><p>We have scanned Tigereum smart contracts for commonly known and more specific vulnerabilities. Here are some of the commonly known vulnerabilities that we considered (the full list includes them but is not limited to them):</p><ul><li><a href="https://media.readthedocs.org/pdf/solidity/develop/solidity.pdf">Reentrancy</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#timestamp-dependence">Timestamp Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#gas-limit-and-loops">Gas Limit and Loops</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-unexpected-throw">DoS with (Unexpected) Throw</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-block-gas-limit">DoS with Block Gas Limit</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#transaction-ordering-dependence-tod">Transaction-Ordering Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#tx-origin">Use of tx.origin</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Exception disorder</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Gasless send</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#enforce-invariants-with-assert">Balance equality</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#fixed-size-byte-arrays">Byte array</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#be-aware-of-the-tradeoffs-between-send-transfer-and-callvalue">Transfer forwards all gas</a></li><li><a href="https://theethereum.wiki/w/index.php/ERC20_Token_Standard">ERC20 API violation</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#libraries">Malicious libraries</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#lock-pragmas-to-specific-compiler-version">Compiler version not fixed</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#fallback-function">Redundant fallback function</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#members-of-addresses">Send instead of transfer</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#linters">Style guide violation</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#external-calls">Unchecked external call</a></li><li><a href="https://ethereum.stackexchange.com/questions/7293/is-it-possible-to-overflow-uints">Unchecked math</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#type-deduction">Unsafe type inference</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#visibility-and-getters">Implicit visibility level</a></li></ul><h3>About The Project</h3><h4>Project Architecture</h4><p>Smart contracts are provided as a Truffle project with js-tests. The project consists of:</p><p><strong>Mintable token</strong></p><ul><li>Tigereum.sol inherited from OpenZeppelin MintableToken (<em>in the latest version of the code — also from OpenZeppelin </em><em>BurnableToken)</em></li></ul><p><strong>Crowdsale</strong></p><ul><li><strong>TigereumCrowdsale.sol</strong> inherited from OpenZeppelin <strong>Crowdsale.sol</strong></li></ul><h4>Code Logic</h4><p>Tigereum is ERC20 mintable token: symbol — TIG, decimals — 18, name — Tigereum. (<em>In the latest version of the code Tigerium is also an OpenZeppelin </em><em>BurnableToken, i.e. and owner can burn his/her tokens)</em> Since the token is mintable, its TotalSupply depends on how many tokens were sold at presale.</p><p>The crowdsale is capped crowdsale with the following parameters:</p><ul><li>33,500,000 are to be sold during the crowdsale<br><em>In the latest version of the code the number of tokens was changed to 32,800,000</em></li><li>after the end of the crowdsale 17,200,000 are to be send to the specified addresses (role / address / the amount of tokens / the share of tokens)</li><li>ICOadvisor1 / 0xBD1b96D30E1a202a601Fa8823Fc83Da94D71E3cc / 400000 / 0.8%</li><li>hundredKInvestor / 0x93da612b3DA1eF05c5D80c9B906bf9e7aAdc4a23 / 3200000 / 6.4%</li><li>additionalPresaleInvestors / 0x095e80F85f3D260bF959Aa524F2f3918f56a2493 / 1000000 / 2%</li><li>preSaleBotReserve / 0x095e80F85f3D260bF959Aa524F2f3918f56a2493 / 2500000 / 5%</li><li>ICOadvisor2 / 0xe05416EAD6d997C8bC88A7AE55eC695c06693C58 / 100000 / 0.2%</li><li>team / 0xA919B56D099C12cC8921DF605Df2D696b30526B0 / 1820000 / 3.64%</li><li>bounty / 0x20065A723d43c753AD83689C5f9F4786a73Be6e6 / 1000000 / 2%</li><li>founders / 0x49ddcD8b4B1F54f3E5c4fEf705025C1DaDC753f6 / 7180000 / 14.36%</li></ul><p><em>All the numbers are taken from the latest version of the code. We recommend checking that the correct addresses are set when the contract is deployed. Besides, the addresses can be changed by the contract owner with </em><em>fixAddress function.</em></p><ul><li>The payed ETH go to:</li></ul><p><strong>A. </strong>1% — to the specified advisor address 0xBD1b96D30E1a202a601Fa8823Fc83Da94D71E3cc</p><p><strong>B. </strong>99% — to the to specified admin address 0x021e366d41cd25209a9f1197f238f10854a0c662</p><p><em>The addresses are specified in the deploy script. We recommend checking that the correct addresses are set when the contract is deployed. Besides, the addresses can be changed by the contract owner with </em><em>fixAddress function.</em></p><ul><li>funds (ETH) are forwarded to owner and advisor immediately after the payment is sent</li><li>tokens are minted immediately after the payment is sent</li><li>the crowdsale start is 8.12.2017 9:00 GMT</li><li>the crowdsale end is 18.12.2017 23:59 GMT</li><li>the price is 1 ETH = 1000 TIG</li><li>during the first 12 hours there is a 33% bonus (1 ETH = 1333 TIG)</li><li>the founders’ tokens are locked for 90 days after crowdsale end</li></ul><p>However, there are bugs in the implementation due which the crowdsale will not end when the cap is reached (besides, it is impossible to exceed the cap).</p><h3>Automated Analysis</h3><p>We used several publicly available automated Solidity analysis tools. Here are the combined results of their analysis. All the issues found by tools were manually checked (rejected or confirmed).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fairtable.com%2Fembed%2FshrMhmkHwOg8Nd9rz&amp;url=https%3A%2F%2Fairtable.com%2FshrMhmkHwOg8Nd9rz&amp;image=https%3A%2F%2Fstatic.airtable.com%2Fimages%2Foembed%2Fairtable.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=airtable" width="800" height="533" frameborder="0" scrolling="no"><a href="https://medium.com/media/992f39b414a11b29c64cc0c7d390d632/href">https://medium.com/media/992f39b414a11b29c64cc0c7d390d632/href</a></iframe><p><strong>Securify* </strong>— beta version, full version is unavailable.</p><p><strong>Securify, Oyente </strong>— these tools do not support 0.4.18 compiler version; the specified version was<br>changed in the code to 0.4.16 and 0.4.17 respectively for these tools.</p><p>Cases when these issues lead to actual bugs or vulnerabilities are described in the next section.</p><h3>Manual Analysis</h3><p>Contracts were completely manually analyzed, their logic was checked and compared with the one described in the whitepaper. Besides, the results of automated analysis were manually verified. All confirmed issues are described below.</p><h3>Critical issues</h3><p>Critical issues seriously endanger smart contracts security. We highly recommend fixing them.</p><h4>Incorrect tokensale finalization</h4><p>TigereumCrowdsale.sol contains the following problems:</p><ul><li>TigereumCrowdsale.sol, line 184</li></ul><pre>if(state == State.NormalSale &amp;&amp; msg.value*rate &gt; cap) {…}</pre><p>First, the comparison must be non-strict (otherwise users can not buy all tokens). Second, the comparison should be not with cap, but with the remaining number of tokens (tokensLeft). Third, here the rate is not updated, though it can become smaller if the state changes.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><ul><li>TigereumCrowdsale.sol, line 191</li></ul><pre>tokensLeft = SafeMath.sub(tokensLeft, numTokens);</pre><p>An exception will be thrown when trying to subtract if tokensLeft &lt; numTokens.</p><p>Thus, if the user wants to buy more tokens than he/she has left, he/she will not be able to buy anything. We recommend checking that tokensLeft &gt;= numTokens before subtracting.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><ul><li>TigereumCrowdsale.sol, line 213</li></ul><pre>uint256 tokensToRefundFor = cap.sub(tokensTotalWithFullBuy);</pre><p>An exception will be thrown when trying to subtract if cap &lt; tokensTotalWithFullBuy.</p><p>In this case, as in the previous one, if the user wants to buy more tokens than there is left, his/her transaction will not succeed and he/she will not buy anything. This is a serious bug since this part of code is supposed to handle this particular situation. We highly recommend fixing the bug and implementing the logic of selling all the remaining tokens and sending extra ETH (change) to the investor.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><ul><li>TigereumCrowdsale.sol, line 215:</li></ul><pre>uint256 weiAmountToRefund = tokensToRefundFor.div(rate);</pre><p>Since tokensToRefundFor may not be divided exactly the rate, in this case less wei will be returned to the user than it should be. (However, this last part of bug is not critical, but medium)</p><h3>Medium severity issues</h3><p>Medium issues can influence smart contracts operation in current implementation. We highly recommend addressing them.</p><h4>Discrepancies with the whitepaper</h4><p>There are several discrepancies between the whitepaper and the contracts code:</p><ol><li>According to the whitepaper, p.23 and p.34, the amount of tokens for investors is 80%, for founders 17%, for team members and advisors 2% and 1% for bounty. But according to the contracts code, there are 79% for participants, 14,36% for founders, 4,64% for team members and advisors (3,64% and 1% respectively) and 2% for bounty.</li></ol><blockquote>The issue <strong>has not</strong> been fixed by the developer in the latest version of the code. Besides, the total amount of tokens was changed to 32,800,000.</blockquote><p>2. According to the whitepaper, p.34, the tokensale ends at 18 Dec 2017, GMT 23:00. But according to the contracts code, it ends at 18 Dec 2017, GMT 23:59.</p><h4>Incorrect state transition</h4><ul><li>If no purchases are made during the bonus period (i.e., within the first 12 hours after the beginning of the crowdsale), the first purchase after the end of the bonus period will still occur at the bonus price, since the state transition in the buyTokens function (TigereumCroudsale.sol, line 187) occurs only after purchase (TigereumCroudsale.sol, lines 188 and 189).</li></ul><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><p>If the time of the beginning of the crowdsale exactly matches with the timestamp of the current block, it will be possible to purchase tokens without switching the state from BeforeSale to Bonus. This happens because there is a strict check in the buyTokensUpdateState function in line 181, and in the validPurchase function (<strong>Crowdsale.sol</strong>), which is called in the buyTokens and lastTokens functions, the check is non-strict. Therefore, if this transaction tries to buy more tokens than cap then the contract will not change state to ShouldFinalize and an attempt to make a regular purchase of tokens (via the buyTokens function) can be made. Thus, it will be possible to buy more tokens than cap.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><ul><li>There is a similar issue in case if there is an attempt to buy more tokens than cap at the Bonus stage. This bug is even more severe, because there is no need for the specific time match (as in previous case).</li></ul><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><p>We highly recommend considering all possible combinations of conditions in the buyTokensUpdateState function.</p><h3>Function Calling Order</h3><p>The withdrawLockupTokens function can be called before the finalize function (because at TigereumCroudsale.sol, line 196 state changes to Lockup). This requires that no one calls finalize during the Lockup period (which is possible). As a result, tokens will not be given to any of users with addresses that are stored in the crowdsale fields (lines 26–48), except founders.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><h4>User can not withdraw all his/her funds</h4><p>In functions forwardFunds (TigereumCroudsale.sol, line 128) and forwardFundsAmount (line 134), 99% and 1% of received wei are calculated. In this case, since the result of division can be only integer, the sum of received funds will not be equal to the transferred amount.</p><p>For example, if we pass 199 wei then</p><pre>onePercent=1 wei</pre><p>, so</p><pre>onePercent.mul(99)=99 wei</pre><p>Thus, 99 wei will be lost. That is, weis will be lost on every token purchase transaction.</p><p>Also, the problem is that some amounts may not converge.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><h4>Production deploy</h4><p>The provided code does not contain production deploy scripts, only test deploy with test addresses. Bugs and vulnerabilities in deploy scripts often appear and severely endanger contracts’ security. We highly recommend not only developing deploy scripts very carefully but also performing audit of them.</p><blockquote>The deploy has been added by the developer in the latest version of the code. Thus, the now issue severity is not <strong>Critical</strong> but <strong>Low</strong>. However, we recommend using Truffle deploy instead, since the provided deploy passes the bytecode of the crowdsale and thus requires checking that the bytecode corresponds to the source code.</blockquote><h4>ERC20 approve issue</h4><p>There is <a href="https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729">ERC20 approve issue</a> (<strong>StandardToken.sol</strong>, line 51). We recommend explicitly warning investors and users not to use approve directly and to use increaseApproval/decreaseApproval functions (or to change the approved amount to 0 and then to the desired value) instead — <a href="https://github.com/ethereum/EIPs/issues/20#issuecomment-263555598">link</a>.</p><h3>Low severity issues</h3><p>Low severity issues can influence smart contracts operation in future versions of code. We recommend to take them into account.</p><h4>Sending tokens and ethers to unusual investors</h4><p>A contract is exposed to this vulnerability if a miner (who executes and validates transactions) can reorder the transactions within a block in a way that affects the receiver of ether. In <strong>TigereumCroudsale.sol</strong>, this applies to all transfers of ethers or tokens to addresses that are stored in the crowdsale fields (lines 26–48). The owner can change these fields using the fixAddress (line 144) function. The owner should be warned that the transfer of ethers/tokens to these addresses depends on the order of the mining. Let us say, the crowdsale is completed, and the owner wants to call the finalize function, but before that he/she wants to change the addresses and calls fixAddress and then calls finalize. Depending on the order of the mining of these transactions, the tokens will be sent to different addresses.</p><h4>Code duplication</h4><p>Functions forwardFundsAmount (<strong>TigereumCroudsale.sol</strong>, line 134) and forwardFunds (line 128) are almost exactly the same. Instead of the function forwardFunds one can simply call forwardFundsAmount(msg.value).</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><h4>Discrepancy with the ERC20 standard</h4><p>In <strong>Tigereum.sol</strong>, line 14, according to the ERC20 standard, the variable decimals should be declared as uint8.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><h3>Check ICOadvisor1 and admin addresses</h3><p>The ether is redirected to addresses ICOadvisor1 and admin. So, one needs to check in advance that these addresses are not addresses of contracts. In if case if, for example, address of ICOadvisor1 is a contract and its fallback function is implemented as follows:</p><pre>function {</pre><pre>throw;</pre><pre>}</pre><p>no purchase transaction will work.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><h4>Suboptimal code</h4><ul><li>At each attempt to purchase tokens, the buyTokensUpdateState (<strong>TigereumCroudsale.sol</strong>, line 180) function is called. It would be enough to call only the status check and calculateCurrentRate</li><li>it is possible to calculateCurrentRate only once</li><li>The hasEnded duplicates the state check in finalize <em>(The issue has been fixed by the developer and is not present in the latest version of the code.)</em></li></ul><h4>Unused code</h4><p>Event numIs (<strong>TigereumCroudsale.sol</strong>, line 71) and modifier canMint (line 73) are not used.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><h4>Use of “this” for local functions</h4><p>In <strong>TigereumCrowdsale.sol</strong> in line 246 the internal function hasEnded is called as an external with the use of this. We recommend not using this to call functions in the same contract, it consumes more gas than normal local calls.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><h3>Code style</h3><p>Codestyle issues influence code conciseness and readability and in some cases may lead to bugs in future. We recommend to take them into account.</p><h4>Constants readability</h4><p>Constants lockupPeriod (<strong>TigereumCroudsale.sol</strong>, line 62), bonusPeriod (line 63) are defined not clearly for the reader. We recommend defining them as a product of values (number of days, day length, etc., e.g. 90 * 1 days or 12*1 hours), so that it will be obvious that they are calculated correctly.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><h4>Variables that are constants, but not marked constant</h4><p>In the TigereumCrowdsale contract, the following variables are constants but not marked so: cap (<strong>TigereumCroudsale.sol</strong>, line 18), startRate (line 19), toDec (line 16), hundredKInvestorSum (line 33), additionalPresaleInvestorsSum (line 36), preSaleBotReserveSum (line 39), ICOadvisor2Sum (line 42), teamSum (line 45), bountySum (line 48), foundersSum (line 53), startTimeNumber (line 59), endTimeNumber (line 60), lockupPeriod (line 62), bonusPeriod (line 63), bonusEndTime (line 65).</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><h4>Misleading comment</h4><p>In TigereumCrowdsale.sol, line 33, the comment</p><pre>//2–2.8% — 2,500,000</pre><p>was written. But according to the whitepaper the comment should be:</p><pre>//2–5% — 2,500,000</pre><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><h4>Using throw</h4><p>In <strong>TigereumCrowdsale.sol</strong>, line 183 throw is used. This function is deprecated, we recommend to avoid using it.</p><blockquote>The issue has been fixed by the developer and is not present in the latest version of the code.</blockquote><h3>Conclusion</h3><p>In this report we have considered the security of Tigereum smart contracts. We performed our audit according to the procedure described above.</p><p>The audit showed several issues of different severity level, all of them were reported to the developer. All of the critical issues has been fixed; most of the medium and low severity issues has been fixed by the developer in the latest version of the code.</p><blockquote>This audit was performed by <a href="https://www.smartcontracts.smartdec.net/">SmartDec</a>, a security team specialized in static code analysis, decompilation and secure development.</blockquote><blockquote>Feel free to use SmartCheck, our <a href="https://tool.smartdec.net/">smart contract security tool</a> for Solidity language, and <a href="https://blog.smartdec.net/">follow us on Medium</a>. We are also available for <a href="https://smartcontracts.smartdec.net/">smart contract development and auditing work</a>.</blockquote><figure><a href="https://smartdec.net/"><img alt="" src="https://cdn-images-1.medium.com/max/984/1*c1MY0JqSA5CRkkYe0eBx5g.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e628c8160f3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/smartdec/tigereum-smart-contracts-security-analysis-8e628c8160f3">Tigereum Smart Contracts Security Analysis</a> was originally published in <a href="https://medium.com/smartdec">SmartDec Cybersecurity Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digitex Vesting Smart Contracts Security Analysis]]></title>
            <link>https://medium.com/smartdec/digitex-vesting-smart-contracts-security-analysis-61fb19d5132a?source=rss-e1a3d7ba9753------2</link>
            <guid isPermaLink="false">https://medium.com/p/61fb19d5132a</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[audit]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Alexander Seleznev]]></dc:creator>
            <pubDate>Thu, 15 Feb 2018 12:53:37 GMT</pubDate>
            <atom:updated>2018-02-15T18:10:18.196Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*KRqmdlu4K-NT4eO0e-otIg.png" /></figure><p><em>In this report we consider the security of the Digitex Vesting project. Our task is to find and describe security issues in the smart contracts of the platform.</em></p><h3>Disclosure</h3><p>The contract in consideration was developed by SmartDec, this is our internal report. We follow our usual procedure for security audit of a smart contract (described below) and present the report in the same manner as for an external audit.</p><h3>Procedure</h3><p>In our analysis we consider Digitex Vesting <a href="https://www.digitexfutures.com/whitepaper/Digitex-Whitepaper.v.1.1.pdf">whitepaper</a> (Digitex-Whitepaper.v.1.1.pdf, sha1sum c0d1808fce894e864f688ab40eb5c0b2601c836a), <a href="https://github.com/smartdec/dgtx-vesting/blob/master/README.md">documentation</a> and <a href="https://github.com/smartdec/dgtx-vesting">smart contracts code</a> (version on commit cd77395).</p><p>We perform our audit according to the following procedure:</p><p><strong>Automated analysis</strong></p><ul><li>we scan project’s smart contracts with our own Solidity static code analyzer <a href="https://tool.smartdec.net/">SmartCheck</a></li><li>we scan project’s smart contracts with several publicly available automated Solidity analysis tools such as <a href="https://remix.ethereum.org/">Remix</a>, <a href="https://protofire.github.io/solhint/">Solhint</a>, and <a href="http://securify.ch/">Securify</a> (beta version since full version was unavailable at the moment this report was made)</li><li>we manually verify (reject or confirm) all the issues found by tools</li></ul><p><strong>Manual audit</strong></p><ul><li>we manually analyze smart contracts for security vulnerabilities</li><li>we check smart contracts logic and compare it with the one described in the documentation</li><li>we run tests and check code coverage</li><li>we deploy contracts to testnet and test them manually</li></ul><p><strong>Report</strong></p><ul><li>we reflect all the gathered information in the report</li></ul><h3>Disclaimer</h3><p>The audit does not give any warranties on the security of the code. One audit can not be considered enough. We always recommend proceeding with several independent audits and a public bug bounty program to ensure the security of smart contracts. Besides, security audit is not an investment advice.</p><h3>Checked vulnerabilities</h3><p>We have scanned Digitex Auction smart contracts for commonly known and more specific vulnerabilities. Here are some of the commonly known vulnerabilities that we considered (the full list includes them but is not limited to them):</p><ul><li><a href="https://media.readthedocs.org/pdf/solidity/develop/solidity.pdf">Reentrancy</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#timestamp-dependence">Timestamp Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#gas-limit-and-loops">Gas Limit and Loops</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-unexpected-throw">DoS with (Unexpected) Throw</a></li><li><a href="https://consensys.github.io/smart-contract-best-practices/known_attacks/#dos-with-unexpected-revert">DOS with (Unexpected) revert</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-block-gas-limit">DoS with Block Gas Limit</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#transaction-ordering-dependence-tod">Transaction-Ordering Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#tx-origin">Use of tx.origin</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Exception disorder</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Gasless send</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#enforce-invariants-with-assert">Balance equality</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#fixed-size-byte-arrays">Byte array</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#be-aware-of-the-tradeoffs-between-send-transfer-and-callvalue">Transfer forwards all gas</a></li><li><a href="https://theethereum.wiki/w/index.php/ERC20_Token_Standard">ERC20 API violation</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#libraries">Malicious libraries</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#lock-pragmas-to-specific-compiler-version">Compiler version not fixed</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#fallback-function">Redundant fallback function</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#members-of-addresses">Send instead of transfer</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#linters">Style guide violation</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#external-calls">Unchecked external call</a></li><li><a href="https://ethereum.stackexchange.com/questions/7293/is-it-possible-to-overflow-uints">Unchecked math</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#type-deduction">Unsafe type inference</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#visibility-and-getters">Implicit visibility level</a></li><li><a href="http://vessenes.com/the-erc20-short-address-attack-explained/">Address hardcoded</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#delete">Using delete for arrays</a></li><li><a href="https://ethereumdev.io/safemath-protect-overflows/">Integer overflow/underflow</a></li><li><a href="http://solidity.readthedocs.io/en/develop/common-patterns.html#withdrawal-from-contracts">Locked money</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#visibility-and-getters">Private modifier</a></li><li><a href="https://solidity.readthedocs.io/en/develop/control-structures.html#error-handling-assert-require-revert-and-exceptions">Revert/require functions</a></li><li><a href="http://solidity.readthedocs.io/en/develop/frequently-asked-questions.html#how-do-for-loops-work">Using var</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#explicitly-mark-visibility-in-functions-and-state-variables">Visibility</a></li><li><a href="https://ethereum.stackexchange.com/questions/419/when-can-blockhash-be-safely-used-for-a-random-number-when-would-it-be-unsafe/427#427">Using blockhash</a></li><li><a href="https://consensys.github.io/smart-contract-best-practices/recommendations/">Using SHA3</a></li><li><a href="https://consensys.github.io/smart-contract-best-practices/recommendations/">Using suicide</a></li><li><a href="https://consensys.github.io/smart-contract-best-practices/recommendations/">Using throw</a></li><li><a href="https://consensys.github.io/smart-contract-best-practices/recommendations/">Using inline assembly</a></li></ul><h3>About The Project</h3><h4>Project Architecture</h4><p>For the audit, we have been provided with the following set of files:</p><ul><li>ERC223.sol (with ERC223 interface)</li><li>ERC223ReceivingContract.sol (with ERC223ReceivingContract interface)</li><li>Vesting.sol (with Vesting contract, which inherits ERC223ReceivingContract interface and Ownable contract from <a href="https://github.com/OpenZeppelin/zeppelin-solidity">OpenZeppelin library</a>, version 1.6.0)</li></ul><p>Total size of the contracts is 749 lines of code.</p><p>Provided file set is a truffle project and an npm package. The project is compiled with a combination of npm install (installs all dependencies, including the OpenZeppelin library) and npm run truffle compile commands.</p><p>The project compiles successfully without warnings. The project contains tests that are run with the npm run test command and these tests successfully pass. Test coverage is full.</p><p>The project contains deploy scripts for the Vesting contract. The project contains directory with building and testing scripts. The project also contains configuration files for the solium linter, solidity-coverage and doxity tools.</p><h4>Code Logic</h4><p>The code logic is fully consistent with the <a href="https://github.com/smartdec/dgtx-vesting/blob/master/README.md">documentation</a>.</p><p>ERC223 token interface is ERC223 compatible, ERC223ReceivingContract is interface with takenFallback function to handle token transfers to the contract (ERC223 standard compliance was verified in the audit).</p><p>Vesting contract implements vesting of 100 000 000 DGTX tokens:</p><ol><li>Owner of the contract is the address the contract is deployed from.</li><li>The owner can transfer its ownership to another address.</li><li>The parameter of the constructor is contract address (deploy script passes the address of DGTX token as parameter).</li><li>tokenFallback function implements token receiving: only 100 000 000 tokens can be received and tokens can be received only once.</li><li>Owner of the contract can withdraw their tokens according to the following scheme: on July 15 2018 25% of tokens locked in the contract become available; further, after every quarter of the year the contract unlocks 6.25% of the tokens it is holding.</li></ol><h3>Automated Analysis</h3><p>We used several publicly available automated Solidity analysis tools. Here are the combined results of their analyses. All the issues found by tools were manually checked (rejected or confirmed).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fairtable.com%2Fembed%2FshrIk7BPEPW78MVeV&amp;url=https%3A%2F%2Fairtable.com%2FshrIk7BPEPW78MVeV&amp;image=https%3A%2F%2Fstatic.airtable.com%2Fimages%2Foembed%2Fairtable.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=airtable" width="800" height="533" frameborder="0" scrolling="no"><a href="https://medium.com/media/b6e86548155873699a1fabb7b934b2cc/href">https://medium.com/media/b6e86548155873699a1fabb7b934b2cc/href</a></iframe><p><strong>Securify* </strong>— beta version, full version is unavailable.</p><p>Cases where these issues lead to actual bugs or vulnerabilities are described in the next section.</p><h3>Manual Analysis</h3><p>Contracts were completely manually analyzed, their logic was checked and compared with the one described in the documentation. Besides, the results of automated analysis were manually verified. All confirmed issues are described below.</p><h4>Critical issues</h4><p>Critical issues seriously endanger smart contracts security. We highly recommend fixing them.</p><p><strong>The audit showed no critical issues.</strong></p><h4>Medium severity issues</h4><p>Medium issues can influence smart contracts operation in current implementation. We highly recommend addressing them.</p><p><strong>The audit showed no medium severity issues.</strong></p><h4>Low severity issues</h4><p>Low severity issues can influence smart contracts operation in future versions of code. We recommend to take them into account.</p><p><strong>The audit showed no low severity issues.</strong></p><h3>Conclusion</h3><p>In this report we considered the security of Digitex Vesting smart contract. We performed our audit according to the procedure described above.</p><p>The audit showed high code quality, high test coverage, and no security issues.</p><blockquote>This audit was performed by <a href="https://www.smartcontracts.smartdec.net/">SmartDec</a>, a security team specialised in static code analysis, decompilation and secure development.</blockquote><blockquote>Feel free to use SmartCheck, our <a href="https://tool.smartdec.net/">smart contract security tool</a> for Solidity language, and <a href="https://blog.smartdec.net/">follow us on Medium</a>. We are also available for <a href="https://smartcontracts.smartdec.net/">smart contract security development and auditing work</a>.</blockquote><figure><a href="https://smartdec.net/"><img alt="" src="https://cdn-images-1.medium.com/max/984/1*lQzS16OSX9-DCSNveDlN5g.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61fb19d5132a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/smartdec/digitex-vesting-smart-contracts-security-analysis-61fb19d5132a">Digitex Vesting Smart Contracts Security Analysis</a> was originally published in <a href="https://medium.com/smartdec">SmartDec Cybersecurity Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Digitex Auction Smart Contracts Security Analysis]]></title>
            <link>https://medium.com/smartdec/digitex-auction-smart-contracts-security-analysis-3082570708d3?source=rss-e1a3d7ba9753------2</link>
            <guid isPermaLink="false">https://medium.com/p/3082570708d3</guid>
            <category><![CDATA[crowdsale]]></category>
            <category><![CDATA[auction]]></category>
            <category><![CDATA[audit]]></category>
            <category><![CDATA[blockchain-development]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Alexander Seleznev]]></dc:creator>
            <pubDate>Thu, 15 Feb 2018 12:41:13 GMT</pubDate>
            <atom:updated>2018-02-15T18:10:53.687Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*kX3CYHUorK90AG22N1esAw.png" /></figure><p><em>In this report we consider the security of the Digitex Auction project. Our task is to find and describe security issues in the smart contracts of the platform.</em></p><h3>Disclosure</h3><p>The contract in consideration was developed by SmartDec, this is our internal report. We follow our usual procedure for security audit of a smart contract (described below) and present the report in the same manner as for an external audit.</p><h3>Procedure</h3><p>In our analysis we consider Digitex Auction <a href="https://github.com/smartdec/dgtx-auction/blob/master/README.md">documentation</a> (version on commit e51a834) and <a href="https://github.com/smartdec/dgtx-auction">smart contracts code</a> (version on commit e51a834).</p><p>We perform our audit according to the following procedure:</p><p><strong>Automated analysis</strong></p><ul><li>we scan project’s smart contracts with our own Solidity static code analyzer <a href="https://tool.smartdec.net/">SmartCheck</a></li><li>we scan project’s smart contracts with several publicly available automated Solidity analysis tools such as <a href="https://remix.ethereum.org/">Remix</a>, <a href="https://protofire.github.io/solhint/">Solhint</a>, and <a href="http://securify.ch/">Securify</a> (beta version since full version was unavailable at the moment this report was made)</li><li>we manually verify (reject or confirm) all the issues found by tools</li></ul><p><strong>Manual audit</strong></p><ul><li>we manually analyze smart contracts for security vulnerabilities</li><li>we check smart contracts logic and compare it with the one described in the documentation</li><li>we run tests and check code coverage</li><li>we deploy contracts to testnet and test them manually</li></ul><p><strong>Report</strong></p><ul><li>we reflect all the gathered information in the report</li></ul><h3>Disclaimer</h3><p>The audit does not give any warranties on the security of the code. One audit can not be considered enough. We always recommend proceeding with several independent audits and a public bug bounty program to ensure the security of smart contracts. Besides, security audit is not an investment advice.</p><h3>Checked vulnerabilities</h3><p>We have scanned Digitex Auction smart contracts for commonly known and more specific vulnerabilities. Here are some of the commonly known vulnerabilities that we considered (the full list includes them but is not limited to them):</p><ul><li><a href="https://media.readthedocs.org/pdf/solidity/develop/solidity.pdf">Reentrancy</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#timestamp-dependence">Timestamp Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#gas-limit-and-loops">Gas Limit and Loops</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-unexpected-throw">DoS with (Unexpected) Throw</a></li><li><a href="https://consensys.github.io/smart-contract-best-practices/known_attacks/#dos-with-unexpected-revert">DOS with (Unexpected) revert</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-block-gas-limit">DoS with Block Gas Limit</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#transaction-ordering-dependence-tod">Transaction-Ordering Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#tx-origin">Use of tx.origin</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Exception disorder</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Gasless send</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#enforce-invariants-with-assert">Balance equality</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#fixed-size-byte-arrays">Byte array</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#be-aware-of-the-tradeoffs-between-send-transfer-and-callvalue">Transfer forwards all gas</a></li><li><a href="https://theethereum.wiki/w/index.php/ERC20_Token_Standard">ERC20 API violation</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#libraries">Malicious libraries</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#lock-pragmas-to-specific-compiler-version">Compiler version not fixed</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#fallback-function">Redundant fallback function</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#members-of-addresses">Send instead of transfer</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#linters">Style guide violation</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#external-calls">Unchecked external call</a></li><li><a href="https://ethereum.stackexchange.com/questions/7293/is-it-possible-to-overflow-uints">Unchecked math</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#type-deduction">Unsafe type inference</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#visibility-and-getters">Implicit visibility level</a></li><li><a href="http://vessenes.com/the-erc20-short-address-attack-explained/">Address hardcoded</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#delete">Using delete for arrays</a></li><li><a href="https://ethereumdev.io/safemath-protect-overflows/">Integer overflow/underflow</a></li><li><a href="http://solidity.readthedocs.io/en/develop/common-patterns.html#withdrawal-from-contracts">Locked money</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#visibility-and-getters">Private modifier</a></li><li><a href="https://solidity.readthedocs.io/en/develop/control-structures.html#error-handling-assert-require-revert-and-exceptions">Revert/require functions</a></li><li><a href="http://solidity.readthedocs.io/en/develop/frequently-asked-questions.html#how-do-for-loops-work">Using var</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#explicitly-mark-visibility-in-functions-and-state-variables">Visibility</a></li><li><a href="https://ethereum.stackexchange.com/questions/419/when-can-blockhash-be-safely-used-for-a-random-number-when-would-it-be-unsafe/427#427">Using blockhash</a></li><li><a href="https://consensys.github.io/smart-contract-best-practices/recommendations/">Using SHA3</a></li><li><a href="https://consensys.github.io/smart-contract-best-practices/recommendations/">Using suicide</a></li><li><a href="https://consensys.github.io/smart-contract-best-practices/recommendations/">Using throw</a></li><li><a href="https://consensys.github.io/smart-contract-best-practices/recommendations/">Using inline assembly</a></li></ul><h3>About The Project</h3><h4>Project Architecture</h4><p>For the audit we have been provided with the following set of files:</p><ul><li>Auction.sol (with Auction contract, which inherits ERC223ReceivingContract interface, usingOraclize contract from <a href="https://github.com/oraclize/ethereum-api">Oraclize library</a> and Ownable contract from <a href="https://github.com/OpenZeppelin/zeppelin-solidity">OpenZeppelin library</a>, version 1.6.0)</li><li>ERC223.sol (with ERC223 interface)</li><li>ERC223Receiver.sol (with ERC223ReceivingContract interface)</li></ul><p>Total size of the contracts is 1436 lines of code. Provided file set is a truffle project and an npm package. The project is compiled with a combination of npm install (installs all dependencies, including the OpenZeppelin library) and npm run truffle compile commands.</p><p>The main contract compiles successfully without warnings (see the <a href="https://docs.google.com/document/d/1B1mWFn327iBeNKeNg-fzZ1fk6w6QT4djRGSosWYmlns/edit#heading=h.x3scx2m8dgd4">compilation output</a> in <a href="https://docs.google.com/document/d/1B1mWFn327iBeNKeNg-fzZ1fk6w6QT4djRGSosWYmlns/edit#heading=h.7uu8vk6xs55w">Appendix</a>, all warnings are for usingOraclize contract).</p><p>The project contains tests that are run with the npm run test command and successfully pass. Tests coverage is full (see the <a href="https://docs.google.com/document/d/1B1mWFn327iBeNKeNg-fzZ1fk6w6QT4djRGSosWYmlns/edit#heading=h.ec4egoft5xvw">output of the test command</a> and <a href="https://docs.google.com/document/d/1B1mWFn327iBeNKeNg-fzZ1fk6w6QT4djRGSosWYmlns/edit#heading=h.cip5cx840dht">code coverage</a> in the <a href="https://docs.google.com/document/d/1B1mWFn327iBeNKeNg-fzZ1fk6w6QT4djRGSosWYmlns/edit#heading=h.7uu8vk6xs55w">Appendix</a>, only oraclize functions are not covered).</p><p>The project contains deploy scripts for the Auction contract. The project contains directory with building and testing scripts. The project also contains configuration files for the solium linter, solidity-coverage and doxity tools.</p><h4>Code Logic</h4><p>The code logic is fully consistent with the <a href="https://github.com/smartdec/dgtx-auction/blob/master/README.md">documentation</a>.</p><p>Auction contract implements Dutch auction for 100 000 000 DGTX tokens.</p><p>Token auction will start at 9am EST on February 15th, 2018 (this date is passed to the contract constructor in deploy script). The price starts from $0.25 per 1 DGTX and linearly decreases by $0.01 every hour until it reaches $0.01. The auction lasts no more than 30 days.</p><p>Public can participate in auction by sending ETH to the auction contract. It is not allowed to participate from contract accounts, only from external accounts.</p><p>Buyer’s bid is calculated in USD cents according to the ETH/USD exchange rate in the contract at the time ETH are received.</p><p>Contributions are limited: maximum — $10000 per address (this value is passed to the contract constructor in deploy script), minimum — 0.01 ETH per transaction. The ETH/USD rate is updated every hour using an oracle. To launch rate update cycle someone needs to call startEthToCentsRateUpdateCycle function.</p><p>Owner of the contract can transfer and withdraw ETH to/from the contract, this is needed to pay commission to the oracle.</p><p>Auction is finished when the amount of USD received (sum of all bids) is equal to the current valuation of the tokens offered (that is, current auction token price multiplied by total amount of tokens offered).</p><p>After the auction is finished, buyers can claim tokens according to the final auction price and the size of their bid. Each buyer receives the portion of all tokens offered proportional to their bid (calculated in USD at the moment ETH are received as described above). This way each buyer receives tokens according to the final price at the moment of the end of auction. Each buyer is guaranteed to receive tokens at a price no higher than the price at which they bid.</p><p>Unsold token are transferred to the owner.</p><p>Anyone can trigger the claiming of tokens for some addresses using distributeTokensRange function.</p><p>Extra ETH (above the maximum per address or what is needed to close the auction) are sent back to the bidder.</p><h3>Automated Analysis</h3><p>We used several publicly available automated Solidity analysis tools. Here are the combined results of their analyses. All the issues found by tools were manually checked (rejected or confirmed).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fairtable.com%2Fembed%2Fshr3BSIF9pZJzef66&amp;url=https%3A%2F%2Fairtable.com%2Fshr3BSIF9pZJzef66&amp;image=https%3A%2F%2Fstatic.airtable.com%2Fimages%2Foembed%2Fairtable.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=airtable" width="800" height="533" frameborder="0" scrolling="no"><a href="https://medium.com/media/3381d48a390fb77a5ca30ddc747b9a41/href">https://medium.com/media/3381d48a390fb77a5ca30ddc747b9a41/href</a></iframe><p><strong>Securify* </strong>— beta version, full version is unavailable.</p><p>Cases where these issues lead to actual bugs or vulnerabilities are described in the next section.</p><h3>Manual Analysis</h3><p>Contracts were completely manually analyzed, their logic was checked and compared with the one described in the documentation. Besides, the results of automated analysis were manually verified. All confirmed issues are described below.</p><h4>Critical issues</h4><p>Critical issues seriously endanger smart contracts security. We highly recommend fixing them.</p><p><strong>The audit showed no critical issues.</strong></p><h4>Medium severity issues</h4><p>Medium issues can influence smart contracts operation in current implementation. We highly recommend addressing them.</p><p><strong>The audit showed no medium severity issues.</strong></p><h4>Low severity issues</h4><p>Low severity issues can influence smart contracts operation in future versions of code. We recommend to take them into account.</p><p><strong>Large fallback function</strong></p><p>The Auction.sol fallback function is large. If the fallback function requires more than 2300 gas, the contract cannot receive ETH through some of standard ways. We recommend to avoid creating large fallback functions. However, since in this case this is necessary, we recommend to mention in the API documentation that contract might not be able to accept ETH in some cases.</p><h3>Conclusion</h3><p>In this report we have considered the security of Digitex Auction smart contract. We performed our audit according to the procedure described above.</p><p>The audit showed high code quality, high test coverage, and no critical or medium severity issues. We recommend mentioning <strong>Large fallback function</strong> low severity issue in API documentation.</p><blockquote>This audit was performed by <a href="https://www.smartcontracts.smartdec.net/">SmartDec</a>, a security team specialised in static code analysis, decompilation and blockchain.</blockquote><blockquote>Feel free to use SmartCheck, our <a href="https://tool.smartdec.net/">smart contract security tool</a> for Solidity language, and <a href="https://blog.smartdec.net/">follow us on Medium</a>. We are also available for <a href="https://smartcontracts.smartdec.net/">smart contract security development and auditing work</a>.</blockquote><figure><a href="https://smartdec.net/"><img alt="" src="https://cdn-images-1.medium.com/max/984/1*lQzS16OSX9-DCSNveDlN5g.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3082570708d3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/smartdec/digitex-auction-smart-contracts-security-analysis-3082570708d3">Digitex Auction Smart Contracts Security Analysis</a> was originally published in <a href="https://medium.com/smartdec">SmartDec Cybersecurity Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SmartDec Meetup in Moscow]]></title>
            <link>https://medium.com/smartdec/moscow-smartdec-smart-contracts-security-meetup-announcement-1e0fa1a5e8bd?source=rss-e1a3d7ba9753------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e0fa1a5e8bd</guid>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Alexander Seleznev]]></dc:creator>
            <pubDate>Mon, 25 Dec 2017 18:01:01 GMT</pubDate>
            <atom:updated>2017-12-26T03:29:08.713Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BrDpZlql9L6bwoT3Eq8hVQ.jpeg" /></figure><p>We are glad to invite everyone to SmartDec <a href="https://www.meetup.com/ru-RU/SmartDec-meetup/events/245988270/">Smart Contracts Security Meetup in Moscow</a>!</p><p><a href="https://smartdec.net/">SmartDec</a> performs research in the area of Ethereum Smart Contracts security, develops tools for decompilation and static code analysis and conducts security audits for code.</p><p>At this meetup we will discuss main security issues we encounter during Smart Contract security audits. We will also talk about how to develop secure ICO smart contracts.</p><p>This time we invited Sergei Tikhomirov — Ethereum security researcher at the University of Luxembourg and main author of <a href="https://basicblockradio.libsyn.com/">Basic Block podcast</a>. Sergei will talk about promising payment channels technology.</p><h4>Agenda</h4><p>1. <strong>Ivan Ivanitsky,</strong> lead analyst at SmartDec. “Smart Contract as a threat to security of blockchain startup”<br>2. <strong>Sergei Tikhomirov</strong>, researcher at CryptoLux, University of Luxembourg. “Payment channels”<br>3. <strong>Alexander Seleznev</strong>, business development executive at SmartDec. “Our experience in security audits of ICO startups”</p><p>Meetup will take place on <strong>28th of December at 18:30</strong> at the <a href="https://deworkacy.com/location/red-october">Minor Lecture Hall of Deworkacy space, Moscow</a>.</p><p>Subscribe to <a href="https://www.meetup.com/ru-RU/SmartDec-meetup/">SmartDec Meetup account</a> for updates!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*lQzS16OSX9-DCSNveDlN5g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e0fa1a5e8bd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/smartdec/moscow-smartdec-smart-contracts-security-meetup-announcement-1e0fa1a5e8bd">SmartDec Meetup in Moscow</a> was originally published in <a href="https://medium.com/smartdec">SmartDec Cybersecurity Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[VoiceOfCoins Smart Contracts Audit]]></title>
            <link>https://medium.com/smartdec/voiceofcoins-smart-contracts-audit-49815464d38b?source=rss-e1a3d7ba9753------2</link>
            <guid isPermaLink="false">https://medium.com/p/49815464d38b</guid>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[audit]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Alexander Seleznev]]></dc:creator>
            <pubDate>Mon, 18 Dec 2017 15:02:04 GMT</pubDate>
            <atom:updated>2018-03-06T11:56:28.871Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3HgXT-pKqqQBwUblJhu30g.png" /></figure><blockquote>In this report we consider the security of the VoiceOfCoins project. Our task was to find and describe security issues in the smart contracts of the platform.</blockquote><p>Several issues of different severity level have been found and reported to the developer. All of them were fixed by the developer and are not present on commit <strong>f86ecf6</strong>.</p><h3>Procedure</h3><p>In our analysis we consider VoiceOfCoins whitepaper (VOC Index Fund .pdf, sha1sum 37955f43c3b85811c4691a649dafab7005e13ac3) and <a href="https://github.com/VoiceOfCoins/VOCTOP25">smart contracts code</a> (version on commit 98ef76e).</p><p>We perform our audit according to the following procedure:</p><p><strong>Automated analysis</strong></p><ul><li>we scan project’s smart contracts with our own Solidity static code analyzer <a href="https://tool.smartdec.net/">SmartCheck</a></li><li>we scan project’s smart contracts with several publicly available automated Solidity analysis tools such as <a href="https://remix.ethereum.org/">Remix</a>, <a href="https://oyente.melon.network/">Oyente</a>, <a href="http://securify.ch/">Securify</a> (beta version since full version was unavailable at the moment this report was made) and <a href="https://protofire.github.io/solhint/">Solhint</a></li><li>we manually verify (reject or confirm) all the issues found by tools</li></ul><p><strong>Manual audit</strong></p><ul><li>we manually analyze smart contracts for security vulnerabilities</li><li>we check smart contracts logic</li></ul><p><strong>Report</strong></p><ul><li>we reflect all the gathered information in the report</li></ul><h3>Disclaimer</h3><p>The audit does not give any warranties on the security of the code. One audit can not be considered enough. We always recommend proceeding to several independent audits and a public bug bounty program to ensure the security of the smart contracts. Besides, security audit is not an investment advice.</p><h3>Checked vulnerabilities</h3><p>We have scanned VoiceOfCoins smart contracts for commonly known and more specific vulnerabilities. Here are some of the commonly known vulnerabilities that we considered (the full list includes them but is not limited to them):</p><ul><li><a href="https://media.readthedocs.org/pdf/solidity/develop/solidity.pdf">Reentrancy</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#timestamp-dependence">Timestamp Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#gas-limit-and-loops">Gas Limit and Loops</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-unexpected-throw">DoS with (Unexpected) Throw</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-block-gas-limit">DoS with Block Gas Limit</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#transaction-ordering-dependence-tod">Transaction-Ordering Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#tx-origin">Use of tx.origin</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Exception disorder</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Gasless send</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#enforce-invariants-with-assert">Balance equality</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#fixed-size-byte-arrays">Byte array</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#be-aware-of-the-tradeoffs-between-send-transfer-and-callvalue">Transfer forwards all gas</a></li><li><a href="https://theethereum.wiki/w/index.php/ERC20_Token_Standard">ERC20 API violation</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#libraries">Malicious libraries</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#lock-pragmas-to-specific-compiler-version">Compiler version not fixed</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#fallback-function">Redundant fallback function</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#members-of-addresses">Send instead of transfer</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#linters">Style guide violation</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#external-calls">Unchecked external call</a></li><li><a href="https://ethereum.stackexchange.com/questions/7293/is-it-possible-to-overflow-uints">Unchecked math</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#type-deduction">Unsafe type inference</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#visibility-and-getters">Implicit visibility level</a></li></ul><h3>About The Project</h3><h4>Project Architecture</h4><p>The project consists of a single source code file VOCTOP25.sol. The code on commit 98ef76e implements:</p><ol><li>the owned contract which is responsible for authorizing addresses using the onlyOwner modifier<br><em>The contract was renamed to Owned on commit f86ecf6.</em></li><li>the tokenRecipient interface which contains the definition of the one receiveApproval function, which is designed to handle approving tokens to the address of the contract<br><em>There is no tokenRecipient interface on commit f86ecf6.</em></li><li>the VOCTOP25 contract is the main project contract that implements the token (ERC20 token with some violations — they are described in the report below — and with additional functionality).<br><em>The is no ERC20 standard violations on commit f86ecf6.</em></li><li>The project does not contain automatic tests and deploy scripts.<br><em>Automatic tests and deploy scripts are present on commit f86ecf6.</em></li></ol><h4>Code Logic</h4><p>The code implements the logic of the token. The token partly corresponds to the ERC20 standard (the discrepancies are described in the report below).<br><em>There are no ERC20 standard violations on commit f86ecf6.</em></p><p>Symbol — VOC25, decimals — 18, name — “Voice Of Coins TOP 25 Index Fund”, totalSupply depends on how many tokens are generated by the mintToken function.</p><p>In addition to the ERC20 standard functionality of the token, the following features are implemented (the owner of the contract is the address from which the the contract was deployed):</p><ol><li>The contract owner can include an address in the frozen list, so the account will be frozen. Also, the owner of the contract can remove an address from this list. Tokens from frozen addresses can not be transferred. The logic contains a vulnerability, see the report.<br><em>Also tokens can not be transferred to frozen addresses on commit f86ecf6. The vulnerability has been fixed by the developer and is not present on commit f86ecf6.</em></li><li>In addition to the standard approve function, one can call the approveAndCall function, which, in addition to calling the usual approve, calls the receiveApproval function from the address for which tokens are being approved.<br><em>approveAndCall function is not present on commit f86ecf6.</em></li><li>The owner of the contract can burn tokens from any address.</li><li>The contract owner can create (mint) tokens to his/her address.</li></ol><h3>Automated Analysis</h3><p>We used several publicly available automated Solidity analysis tools. Here are the combined results of their analysis. All the issues found by tools were manually checked (rejected or confirmed).</p><blockquote>There are no confirmed issues on commit f86ecf6.</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fairtable.com%2Fembed%2FshrQxEJHXuT2nNktw&amp;url=https%3A%2F%2Fairtable.com%2FshrQxEJHXuT2nNktw&amp;image=https%3A%2F%2Fstatic.airtable.com%2Fimages%2Foembed%2Fairtable.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=airtable" width="800" height="533" frameborder="0" scrolling="no"><a href="https://medium.com/media/ea5c20dbaf292661dabcb1817812e5d7/href">https://medium.com/media/ea5c20dbaf292661dabcb1817812e5d7/href</a></iframe><p><strong>Securify* </strong>— beta version, full version is unavailable.</p><p><strong>Securify, Oyente </strong>— these tools do not support 0.4.18 compiler version; the specified version was changed in the code to 0.4.16 and 0.4.17 respectively for these tools.</p><p>Cases when these issues lead to actual bugs or vulnerabilities are described in the next section.</p><h3>Manual Analysis</h3><p>Contracts were completely manually analyzed, their logic was checked. Besides, the results of automated analysis were manually verified. All confirmed issues are described below.</p><h3>Critical issues</h3><p>Critical issues seriously endanger smart contracts security. We highly recommend fixing them.</p><h4>Frozen funds logic</h4><p>There is a bug in frozen funds logic. When one calls the transferFrom function, he/she is spending not his/her funds. However, the check at line 129 that is called inside the _transfer function (which is called inside the transferFrom):</p><pre>require(!_frozenAccount[msg.sender]);</pre><p>checks whether the msg.sender’s account is frozen, not the _from account. We recommend addressing the issue and clarifying what is meant by “freeze” — freezing the account (forbidding it to perform any actions) or the funds.</p><p>In the current implementation, the following situation is possible. Let us say, User1 account is frozen. He/she calls approve to another address. User2 transfers the approved funds. Thus, the frozen logic is broken. The check</p><pre>require(!_frozenAccount[_from]);</pre><p>might help in this particular situation; however, we recommend clarifying the logic.</p><blockquote>The issue has been fixed by the developer and is not present on commit f86ecf6.</blockquote><h3>Medium severity issues</h3><p>Medium issues can influence smart contracts operation in current implementation. We highly recommend addressing them.</p><h4>No tests</h4><p>The provided code does not contain tests. Testing is crucial for code security. Manual testing should not be considered enough. We highly recommend not only to cover the code with tests but also to make sure that the coverage is sufficient.</p><blockquote>The issue has been fixed by the developer and is not present on commit f86ecf6.</blockquote><h4>ERC20 standard violation</h4><p>There are several ERC20 standard violations:</p><ul><li>transfer does not return bool (it does not return anything at all)</li><li>no Approve event, so approve does not fire Approval event</li><li>in the Transfer event, the names of the parameters are incorrect (they should be specified with underscores, so that the search for standard names will be possible)</li></ul><blockquote>The issue has been fixed by the developer and is not present on commit f86ecf6.</blockquote><h4>ERC20 approve issue</h4><p>There is <a href="https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729">ERC20 approve issue</a> (VOCTOP25.sol, line 196). We recommend instructing users not to use approve directly and to use increaseApproval/decreaseApproval functions (or to change the approved amount to 0, wait for the transaction to be mined, and then to change the approved amount to the desired value) instead — <a href="https://github.com/ethereum/EIPs/issues/20#issuecomment-263555598">link</a> (changing the approved amount from a nonzero value to another nonzero value allows a double spending with a front-running attack).</p><blockquote>Functions increaseApproval/decreaseApproval are present on commit f86ecf6.</blockquote><h3>Low severity issues</h3><p>Low severity issues can influence smart contracts operation in future versions of code. We recommend to take them into account.</p><h4>Redundant code</h4><ul><li>Line 149: the condition in</li></ul><pre>assert(_balanceOf[_from] + _balanceOf[_to] == previousBalances);</pre><p>will always be met. It follows from the logic described above, so assert is redundant and will just spend extra gas each time.</p><ul><li>Line 238: redundant check</li></ul><pre>require(_totalSupply &gt;= _value);</pre><p>Total supply will always be greater than or equal to the balance of the owner (because they are increased together by the same amount in mint), and the comparison of the value and balance of the owner is on the line 235.</p><blockquote>The issue has been fixed by the developer and is not present on commit f86ecf6.</blockquote><h4>approve logic</h4><p>The approve function (line 196) does not allow to make _allowance more than the number of tokens the msg.sender has. However, there is a check for not spending more funds than one has in the _transfer function (through which all transfers pass). Thus, the check in approve is redundant. Besides, it deprives one from approving tokens for the future (when he/she will has more tokens).</p><blockquote>The issue has been fixed by the developer and is not present on commit f86ecf6.</blockquote><h4>Another contract is called</h4><p>There is a call of another contract at line 218. We recommend to warn users to carefully check what contract will be called.</p><blockquote>The issue has been fixed by the developer and is not present on commit f86ecf6.</blockquote><h4>Code Style</h4><p>The code violates the <a href="http://solidity.readthedocs.io/en/develop/style-guide.html">Style Guide for Solidity</a>.</p><blockquote>The issue has been fixed by the developer and is not present on commit f86ecf6.</blockquote><h4>Implicit visibility level</h4><p>In many places in the code there are variables with implicit visibility level. We recommend specifying visibility level explicitly and correctly.</p><blockquote>The issue has been fixed by the developer and is not present on commit f86ecf6.</blockquote><h4>Constant functions</h4><p>We recommend to use view instead of constant, which will be deprecated for functions. If a function is not supposed to modify the state or read from state, consider declaring it as pure.</p><blockquote>The issue has been fixed by the developer and is not present on commit f86ecf6.</blockquote><h3>Conclusion</h3><p>In this report we have considered the security of VoiceOfCoins smart contracts. We performed our audit according to the procedure described above. Several issues of different severity level have been found and reported to the developer.</p><blockquote>All of them were fixed by the developer and are not present on commit f86ecf6.</blockquote><p><strong>This analysis was performed by </strong><a href="https://smartcontracts.smartdec.net/"><strong>SmartDec</strong></a><strong>.</strong></p><figure><a href="https://smartdec.net/"><img alt="" src="https://cdn-images-1.medium.com/max/984/1*lQzS16OSX9-DCSNveDlN5g.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49815464d38b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/smartdec/voiceofcoins-smart-contracts-audit-49815464d38b">VoiceOfCoins Smart Contracts Audit</a> was originally published in <a href="https://medium.com/smartdec">SmartDec Cybersecurity Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ConnectJob Smart Contracts Security Audit]]></title>
            <link>https://medium.com/smartdec/connectjob-smart-contracts-security-audit-9d4b20f7e83f?source=rss-e1a3d7ba9753------2</link>
            <guid isPermaLink="false">https://medium.com/p/9d4b20f7e83f</guid>
            <category><![CDATA[ico]]></category>
            <category><![CDATA[audit]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Alexander Seleznev]]></dc:creator>
            <pubDate>Fri, 08 Dec 2017 14:23:14 GMT</pubDate>
            <atom:updated>2018-02-15T18:12:32.777Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*ogBhYj9QoeDYnfUljain9A.png" /></figure><blockquote>In this report we consider the security of the <a href="https://ico.connectjob.io/">ConnectJob</a> project. Our task is to find and describe security issues in the smart contracts of the platform.</blockquote><h3>Procedure</h3><p>In our analysis we consider ConnectJob whitepaper and <a href="https://github.com/eclips16/CJToken">smart contracts</a> code.</p><p>We have performed first audit for version on commit <em>2106aaf</em> and reported all the issues to the developer. The developer has fixed some of the reported issues, which is also reflected in the report.</p><p>After the developer changed the code we performed second audit for version on commit <em>a0e20aa</em>.</p><p>Results of both audits are presented in this document.</p><p>We perform our audit according to the following procedure:</p><p><strong>Automated analysis</strong></p><ul><li>we scan project’s smart contracts with our own Solidity static code analyzer <a href="https://tool.smartdec.net/">SmartCheck</a></li><li>we scan project’s smart contracts with several publicly available automated Solidity analysis tools such as <a href="https://remix.ethereum.org/">Remix</a>, <a href="https://oyente.melon.network/">Oyente</a> and <a href="http://securify.ch/">Securify</a> (beta version since full version was unavailable at the moment this report was made)</li><li>we manually verify (reject or confirm) all the issues found by tools</li></ul><p><strong>Manual audit:</strong></p><ul><li>we manually analyze smart contracts for security vulnerabilities</li><li>we check smart contracts logic and compare it with the one described in the whitepaper</li><li>we deploy contracts and run tests</li></ul><p><strong>Report</strong></p><ul><li>we report all the issues found to the developer during the audit process</li><li>we check issues fixed by the developer</li><li>we reflect all the gathered information in the report</li></ul><h3>Disclaimer</h3><p>The audit does not give any warranties on the security of the code. One audit can not be considered enough. We always recommend proceeding to several independent audits and a public bug bounty program to ensure the security of the smart contracts.</p><h3>Checked vulnerabilities</h3><p>We have scanned ConnectJob smart contracts for commonly known and more specific vulnerabilities. Here are some of the commonly known vulnerabilities that we considered (the full list includes them but is not limited to them):</p><ul><li><a href="https://media.readthedocs.org/pdf/solidity/develop/solidity.pdf">Reentrancy</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#timestamp-dependence">Timestamp Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#gas-limit-and-loops">Gas Limit and Loops</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-unexpected-throw">DoS with (Unexpected) Throw</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-block-gas-limit">DoS with Block Gas Limit</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#transaction-ordering-dependence-tod">Transaction-Ordering Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#tx-origin">Use of tx.origin</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Exception disorder</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Gasless send</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#enforce-invariants-with-assert">Balance equality</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#fixed-size-byte-arrays">Byte array</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#be-aware-of-the-tradeoffs-between-send-transfer-and-callvalue">Transfer forwards all gas</a></li><li><a href="https://theethereum.wiki/w/index.php/ERC20_Token_Standard">ERC20 API violation</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#libraries">Malicious libraries</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#lock-pragmas-to-specific-compiler-version">Compiler version not fixed</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#fallback-function">Redundant fallback function</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#members-of-addresses">Send instead of transfer</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#linters">Style guide violation</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#external-calls">Unchecked external call</a></li><li><a href="https://ethereum.stackexchange.com/questions/7293/is-it-possible-to-overflow-uints">Unchecked math</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#type-deduction">Unsafe type inference</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#visibility-and-getters">Implicit visibility level</a></li></ul><h3>First audit (commit 2106aaf)</h3><h3>Automated Analysis</h3><p>We used several publicly available automated Solidity analysis tools. Here are the combined results of their analysis. All the issues found by tools were manually checked (rejected or confirmed).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fairtable.com%2Fembed%2FshrRTa2C9bMphMtQG&amp;url=https%3A%2F%2Fairtable.com%2FshrRTa2C9bMphMtQG&amp;image=https%3A%2F%2Fstatic.airtable.com%2Fimages%2Foembed%2Fairtable.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=airtable" width="800" height="533" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c3a27d4bd665ad482847aedfa91bb10/href">https://medium.com/media/2c3a27d4bd665ad482847aedfa91bb10/href</a></iframe><p><strong>Securify* </strong>— beta version, full version is unavailable.</p><p>Cases when these issues lead to actual bugs or vulnerabilities are described in the next section.</p><h3>Manual Analysis</h3><p>Contracts were completely manually analyzed, their logic was checked and compared with the one described in the whitepaper. Besides, the results of automated analysis were manually verified. We describe all confirmed issues below.</p><h3>High severity issues</h3><p>High severity issues seriously endanger smart contracts security. We highly recommend fixing them.</p><h4>Pre-ICO and bounty tokens</h4><p>Contracts do not contain any method for transferring tokens to presale and bounty investors. The administrator needs to transfer tokens between the initialization of CJToken (2_deploy_contracts.js, line 17) and transferring all tokens to the Crowdsale contract (2_deploy_contracts.js, line 26). We highly recommend implementing the corresponding method.</p><blockquote>This issue has been fixed by the developer and is not present on commit 0823ff9.</blockquote><h4>Incorrect crowdsale end</h4><p>The sendReserveTokens function (Crowdsale.sol, line 130) contains a bug. If total is almost equal to maxCap, then burnAmount will be negative. But since its type is uint256, its value will become a large positive number. Thus, line 135 (coin.transfer) will throw, and the owner will not be able to burn tokens and to transfer tokens to multisigVault. We highly recommend fixing the bug.</p><blockquote>This issue has been fixed by the developer and is not present on commit 0823ff9.</blockquote><h4>No vesting logic</h4><p>The whitepaper says: <em>“Vesting periods will be certified through the crowdsale smart-contract and publicly verifiable”</em>. But there is no code in the contracts for this logic. We highly recommend implementing it or excluding it from the whitepaper.</p><h4>Remaining token after ICO logic</h4><p>Whitepaper: <em>“If the ICO cap is not reached, all unsold CJT Tokens will be destroyed consequently. 35% of all tokens are kept for team, advisors and future.”</em> Comment in code: “send reserve tokens (35% of the sold amount) to the multisig wallet and burn the rest”. The comment does not match the whitepaper; neither comment, nor whitepaper matches the code. The code reserves 35% of tokens remained after burn, investors hold 65% of the remaining tokens. We highly recommend fixing the code, the comment or/and the whitepaper.</p><blockquote>This issue has been fixed by the developer and is not present on commit 0823ff9.</blockquote><h3>Medium severity issues</h3><p>Medium issues can influence smart contracts operation in current implementation. We highly recommend addressing them.</p><h4>Incorrect cap check</h4><p>The contract will not be able to end the crowdsale before endTime. The only way to end the crowdsale before endTime is to raise exactly maxCap amount (buyTokens throws if getTotalTokenSold() &gt; maxCap, Crowdsale.sol, line 109, hasEnded and sendReserveTokens checks if getTotalTokenSold() &gt;= maxCap). We highly recommend either eliminating maxCap check from hasEnded and sendReserveTokens functions or implementing correct check of cap.</p><blockquote>This issue has been fixed by the developer and is not present on commit 03e8a25.</blockquote><h4>Only owner can finish crowdsale</h4><p>Only owner can call the sendReserveTokens function. The better practice is to allow any user to end crowdsale. We have to warn investors that potentially the owner has the possibility not to end the crowdsale. We highly recommend making the function for crowdsale end available for all users.</p><blockquote>This issue has been fixed by the developer and is not present on commit 0823ff9.</blockquote><h4>Minimal transaction</h4><p>Minimal transaction amount should be 0.4 ether according to the whitepaper, but in the contracts it is equal to 0.41(6). We recommend either checking minimal amount in ethers, not in tokens, or changing the minimal amount in the whitepaper.</p><blockquote>This issue has been fixed by the developer and is not present on commit b74f5d7.</blockquote><h4>Outdated OpenZeppelin contracts</h4><p>The contracts use outdated version of OpenZeppelin contracts. The BasicToken.transfer and StandartToken.transferFrom functions have no require (see <em>e70dd18</em> commit in OpenZeppelin — 23 sep). Instead of this, assert is used. assert spends all gas and require does not spend remaining gas, <a href="http://solidity.readthedocs.io/en/develop/control-structures.html#error-handling-assert-require-revert-and-exceptions">link</a> (after Metropolis release). Also <em>e70dd18</em> commit fix _allowance local variable, it spends more gas. We highly recommend using the latest versions of frameworks.</p><blockquote>This issue has been fixed by the developer and is not present on commit 14d2599.</blockquote><h4>Migrations</h4><p>2_deploy_contracts.js does not contain owner and wallet addresses. We draw your attention to the fact that the developer needs to add real addresses before deploy.</p><p>Migrations contract checks are restricted by if (msg.sender == owner) _;. Better practice is to use require and Ownable interface — require does not spend remaining gas (<em>3d6988c</em> commit in OpenZeppelin repo).</p><p>Also, startTime in Crowdsale constructor is set to now, so the developer must not forget to set actual startTime.</p><blockquote>This issue has been partially fixed by the developer on commit bbee19b: require added, comment about wallet address added; startTime issue not fixed.</blockquote><h4>ERC20 approve issue</h4><p>There is <a href="https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729">ERC20 approve issue</a> (StandardToken.sol, line 51). We recommend explicitly warning investors and users not to use approve directly and to use increaseApproval/decreaseApproval functions (or to change the approved amount to 0 and then to the desired value) instead — <a href="https://github.com/ethereum/EIPs/issues/20#issuecomment-263555598">link</a>.</p><h3>Low severity issues</h3><p>Low severity issues can influence smart contracts operation in future versions of code. We recommend to take them into account.</p><h4>Addresses checks</h4><p>We recommend adding require to Crowdsale constructor (Crowdsale.sol, line 34) to check that the _CJTokenAddress and _to addresses are non-zero.</p><h4>if instead of require</h4><p>Crowdsale.sol. line 54, setMultiSigVault — we recommend using require instead of if to spend less gas in case of errors.</p><blockquote>This issue has been fixed by the developer and is not present on commit 3f5ebe4.</blockquote><h4>Fallback function requires too much gas</h4><p>Fallback function in Crowdsale.sol, line 50 (line 95) is pretty big. If the fallback function requires more than 2300 gas, the contract cannot receive Ether by some of standard ways. We recommend to avoid creating big fallback functions. If it is impossible, we recommend to instruct user to explicitly call the function with more gas.</p><h4>Pragmas version</h4><p>Solidity source files indicate the versions of the compiler they can be compiled with. Example:</p><pre>pragma solidity ^0.4.18; // bad: compiles w 0.4.18 and above</pre><pre>pragma solidity 0.4.18; // good : compiles w 0.4.18 only</pre><p>We recommend following the latter example, as future compiler versions may handle certain language constructions in a way the developer did not foresee. Besides, we recommend using the latest compiler version (0.4.18 at the moment).</p><blockquote>This issue has been partially fixed by the developer on commit bbee19b: ^ fixed; version not fixed.</blockquote><h4>Cap computation</h4><p>Cap for ICO can be computed before contract deployment (maxCap — preIcoTokensSold), so there will be no need in getTotalTokenSold function and the calls to Crowdsale will require less gas. On the other hand it can reduce code readability. We recommend considering this possibility to reduce the gas cost of the contract.</p><blockquote>This issue has been fixed by the developer and is not present on commit 0823ff9.</blockquote><h3>Codestyle issues</h3><p>Codestyle issues influence code conciseness and readability and in some cases may lead to bugs in future. We recommend to take them into account.</p><h4>Function can be declared as view</h4><p>If a function is not supposed to modify the state, consider declaring it as view (alias for constant, which will be deprecated for functions). This provides additional checks in case these assumptions are violated. Issues:</p><ul><li>Crowdsale.sol, line 66 (<em>This issue has been fixed by the developer and is not present on commit 0823ff9.)</em></li><li>Crowdsale.sol, line 71</li></ul><h4>Implicit visibility level</h4><p>In many places in the code there are functions and variables with implicit visibility level. We recommend specifying visibility level explicitly and correctly. Issues:</p><ul><li>BasicToken.sol, line 15</li><li>Crowdsale.sol, line 49</li><li>Crowdsale.sol, line 95</li><li>Crowdsale.sol, line 130 (<em>This issue has been fixed by the developer and is not present on commit 0823ff9.)</em></li><li>StandardToken.sol, line 17 (<em>This issue has been fixed by the developer and is not present on commit 14d2599.)</em></li><li>StandardToken.sol, line 73 (<em>This issue has been fixed by the developer and is not present on commit 14d2599.)</em></li><li>StandardToken.sol, line 80 (<em>This issue has been fixed by the developer and is not present on commit 14d2599.)</em></li></ul><h3>Second audit (commit a0e20aa)</h3><h3>Automated Analysis</h3><p>We used several publicly available automated Solidity analysis tools. Here are the combined results of their analysis. All the issues found by tools were manually checked (rejected or confirmed). Automated analysis results are provided for commit <em>d96aaac</em>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fairtable.com%2Fembed%2FshrwSnP6sK9PjJNN3&amp;url=https%3A%2F%2Fairtable.com%2FshrwSnP6sK9PjJNN3&amp;image=https%3A%2F%2Fstatic.airtable.com%2Fimages%2Foembed%2Fairtable.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=airtable" width="800" height="533" frameborder="0" scrolling="no"><a href="https://medium.com/media/29387634aab4ede0c55a61d0156345ad/href">https://medium.com/media/29387634aab4ede0c55a61d0156345ad/href</a></iframe><p><strong>Securify* </strong>— beta version, full version is unavailable.</p><p>Cases when these issues lead to actual bugs or vulnerabilities are described in the next section.</p><h3>Manual Analysis</h3><p>Contracts were completely manually analyzed, their logic was checked and compared with the one described in the whitepaper. Besides, the results of automated analysis were manually verified. We describe all confirmed issues below. Manual analysis results are provided for commit <em>a0e20aa</em>.</p><h3>High severity issues</h3><p>High severity issues seriously endanger smart contracts security. We highly recommend fixing them.</p><h4>Discrepancies with the whitepaper</h4><ol><li>Crowdsale dates in the code and in the whitepaper differ: 27 nov — 7 Jan instead of 3 Jan — 12 Feb. We highly recommend fixing either the code or the whitepaper.<br><em>This issue has been fixed by the developer and is not present on commit d96aaac.</em></li><li>Bonuses in the code and in the whitepaper differ: 15–12–9–6–3 (by weeks) instead of 12–9–6–3. We highly recommend fixing either the code or the whitepaper.<br><em>This issue has been fixed by the developer and is not present on commit e2e7e1e.</em></li><li>The whitepaper says (on page 26) that 65% of all tokens are sold during ICO (on the diagram). But the fact is 65% of all tokens are sold <strong><em>or burnt</em></strong> during ICO. This means that after ICO the owner can have more than 65% of remaining tokens. We highly recommend fixing either the code or the whitepaper.<br><em>The developer states that the whitepaper will be fixed.</em></li><li>The whitepaper says (on page 26) says: “Depending on the sale stage, the contributor will receive a certain amount of tokens that will be unlocked once the token sale process is over.” However, there is no locking logic in code. We highly recommend fixing either the code or the whitepaper.<br><em>The developer states that the whitepaper will be fixed.</em></li></ol><h4>Insufficient tests</h4><p>There are no tests for the last transaction (Crowdsale.sol, lines 91–95). This code transfers ethers to investor, so it is crucial to cover it with tests. We highly recommend creating the corresponding tests.</p><blockquote>The developer states that the functionality has been tested manually.</blockquote><h4>Checks-Effects-Interactions pattern violation</h4><p>The buyTokens functions violates the Checks-Effects-Interactions pattern. Investor can call any code in result of transfer call (line 98 of Crowdsale.sol). This issue is critical. The best practice here is to let user to withdraw this ethers. Besides, transfer can be called at the end of the function (<a href="http://solidity.readthedocs.io/en/develop/security-considerations.html">link</a>).</p><blockquote>This issue has been fixed by the developer and is not present on commit c0b2f64.</blockquote><h3>Conclusion</h3><p>In this report we have considered the security of ConnectJob smart contracts. We performed our audit according to the procedure described above.</p><p>Several vulnerabilities of different severity were found and reported to the developer of the contracts during the audit. All the important issues have been fixed by the developer.</p><p><strong>This analysis was performed by </strong><a href="https://smartcontracts.smartdec.net/"><strong>SmartDec</strong></a><strong>.</strong></p><figure><a href="https://smartdec.net/"><img alt="" src="https://cdn-images-1.medium.com/max/984/1*lQzS16OSX9-DCSNveDlN5g.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9d4b20f7e83f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/smartdec/connectjob-smart-contracts-security-audit-9d4b20f7e83f">ConnectJob Smart Contracts Security Audit</a> was originally published in <a href="https://medium.com/smartdec">SmartDec Cybersecurity Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Brickblock Smart Contracts Security Audit]]></title>
            <link>https://medium.com/smartdec/brickblock-smart-contracts-security-audit-1a3a46845dc1?source=rss-e1a3d7ba9753------2</link>
            <guid isPermaLink="false">https://medium.com/p/1a3a46845dc1</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[brickblock]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[audit]]></category>
            <dc:creator><![CDATA[Alexander Seleznev]]></dc:creator>
            <pubDate>Thu, 07 Dec 2017 16:21:55 GMT</pubDate>
            <atom:updated>2018-03-06T11:55:36.383Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2fTl_TDm_lfr6-oEj6_6dg.png" /></figure><blockquote>In this report we consider the security of the <a href="https://www.brickblock.io/">Brickblock</a> project. Our task is to find and describe security issues in the smart contracts of the platform.</blockquote><h3>Procedure</h3><p>In our analysis we consider Brickblock <a href="https://github.com/brickblock-io/whitepaper-technical">whitepaper</a> (version on commit cc4ee61) and <a href="https://github.com/brickblock-io/smart-contract-structure">smart contracts code</a> (version on commit 76351a4).</p><p>We perform our audit according to the following procedure:</p><p><strong>Automated analysis</strong></p><ul><li>we scan project’s smart contracts with our own Solidity static code analyzer <a href="https://tool.smartdec.net/">SmartCheck</a></li><li>we scan project’s smart contracts with several publicly available automated Solidity analysis tools such as <a href="https://remix.ethereum.org/">Remix</a>, <a href="https://oyente.melon.network/">Oyente</a> and <a href="http://securify.ch/">Securify</a> (beta version since full version was unavailable at the moment this report was made)</li><li>we manually verify (reject or confirm) all the issues found by tools</li></ul><p><strong>Manual audit</strong></p><ul><li>we manually analyze smart contracts for security vulnerabilities</li><li>we check smart contracts logic and compare it with the one described in the whitepaper</li><li>we run tests and check code coverage</li></ul><p><strong>Report</strong></p><ul><li>we report all the issues found to the developer during the audit process</li><li>we check the issues fixed by the developer</li><li>we reflect all the gathered information in the report</li></ul><h3>Disclaimer</h3><p>The audit does not give any warranties on the security of the code. One audit can not be considered enough. We always recommend proceeding to several independent audits and a public bug bounty program to ensure the security of the smart contracts.</p><h3>Checked vulnerabilities</h3><p>We have scanned Brickblock smart contracts for commonly known and more specific vulnerabilities. Here are some of the commonly known vulnerabilities that we considered (the full list includes them but is not limited to them):</p><ul><li><a href="https://media.readthedocs.org/pdf/solidity/develop/solidity.pdf">Reentrancy</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#timestamp-dependence">Timestamp Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#gas-limit-and-loops">Gas Limit and Loops</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-unexpected-throw">DoS with (Unexpected) Throw</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-block-gas-limit">DoS with Block Gas Limit</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#transaction-ordering-dependence-tod">Transaction-Ordering Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#tx-origin">Use of tx.origin</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Exception disorder</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Gasless send</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#enforce-invariants-with-assert">Balance equality</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#fixed-size-byte-arrays">Byte array</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#be-aware-of-the-tradeoffs-between-send-transfer-and-callvalue">Transfer forwards all gas</a></li><li><a href="https://theethereum.wiki/w/index.php/ERC20_Token_Standard">ERC20 API violation</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#libraries">Malicious libraries</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#lock-pragmas-to-specific-compiler-version">Compiler version not fixed</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#fallback-function">Redundant fallback function</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#members-of-addresses">Send instead of transfer</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#linters">Style guide violation</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#external-calls">Unchecked external call</a></li><li><a href="https://ethereum.stackexchange.com/questions/7293/is-it-possible-to-overflow-uints">Unchecked math</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#type-deduction">Unsafe type inference</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#visibility-and-getters">Implicit visibility level</a></li></ul><h3>Automated Analysis</h3><p>We used several publicly available automated Solidity analysis tools.</p><p>Securify and Remix do not support 0.4.18 compiler version; the specified version was changed in the code to 0.4.16 for these tools.</p><p>Securify and Oyente have not found any bugs.</p><p>Here are the combined results of SmartCheck and Remix.</p><p>All the issues found by tools were manually checked (rejected or confirmed).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fairtable.com%2Fembed%2FshrKgfiFff3pSvulf&amp;url=https%3A%2F%2Fairtable.com%2FshrKgfiFff3pSvulf&amp;image=https%3A%2F%2Fstatic.airtable.com%2Fimages%2Foembed%2Fairtable.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=airtable" width="800" height="533" frameborder="0" scrolling="no"><a href="https://medium.com/media/2336d4b95cdd959b7b0dcd777ac7d8a6/href">https://medium.com/media/2336d4b95cdd959b7b0dcd777ac7d8a6/href</a></iframe><p>Cases when these issues lead to actual bugs or vulnerabilities are described in the next section.</p><h3>Code coverage</h3><p>BrickblockToken.sol is well covered with tests:</p><ul><li>58/68 of statements (85.29%)</li><li>23/32 of branches (71.88%)</li><li>11/12 of functions (91.67%)</li><li>61/72 of lines (84.72%)</li></ul><p>We recommend improving tests for finalizeTokenSale function.</p><h3>Manual Analysis</h3><p>Contracts were completely manually analyzed, their logic was checked and compared with the one described in the whitepaper. Besides, the results of automated analysis were manually verified. All confirmed issues are described below.</p><h3>Critical issues</h3><p>Critical issues seriously endanger smart contracts security. We highly recommend fixing them.</p><p>The analysis showed no critical issues.</p><h3>Medium severity issues</h3><p>Medium issues can influence smart contracts operation in current implementation. We highly recommend addressing them.</p><h4>Contract address</h4><p>The upgrade function (BrickBlockToken.sol, line 147) allows setting the contract’s successor, which is supposed to be a contract, too. We highly recommend adding a check that the given address belongs to a contract account and not to an external account.</p><blockquote>The issue has been fixed by the developer and is not present on commit 63443af8.</blockquote><h4>ERC20 concerns</h4><p>BrickBlockToken contract does not follow some recommendations of ERC20 standard:</p><p><em>“A token contract which creates new tokens SHOULD trigger a Transfer event with the _from address set to 0x0 when tokens are created.”</em></p><p>We recommend adding Trasfer event to constructor.</p><blockquote>The issue has been fixed by the developer and is not present on commit 63443af8.</blockquote><p>We also recommend modifying distributeTokens and finalizeTokenSale functions so that they fire Trasfer and Approval events while working with balances and allowed mappings.</p><blockquote>The issue has been fixed by the developer and is not present on commit 63443af8.</blockquote><h3>Low severity issues</h3><p>Low severity issues can influence smart contracts operation in future versions of code. We recommend to take them into account.</p><h4>Uninitialized variable</h4><p>The fountainContractAddress variable, which is used at BrickBlockToken.sol, line 114 may be not initialized. We recommend checking this address before using it.</p><blockquote>The issue has been fixed by the developer and is not present on commit 63443af8.</blockquote><h4>No 51% check</h4><p>The distributeTokens function at BrickBlockToken.sol, line 87, allows distributing more than 51% of tokens. This constraint could be checked outside BrickBlockToken contract though. If more than 51% of tokens are distributed then finalizeTokenSale function will always throw. We highly recommend adding the check to the distributeTokens function.</p><blockquote>The issue has been fixed by the developer and is not present on commit 63443af8.</blockquote><h4>Checks-Effects-Interaction pattern violation</h4><p>There is a Checks-Effects-Interaction violation at BrickblockToken.sol, line 165. In this case the violations do not lead to actual vulnerabilities.</p><blockquote>The issue has been fixed by the developer and is not present on commit 63443af8.</blockquote><h4>Pragmas version</h4><p>Solidity source files indicate the versions of the compiler they can be compiled with. Example:</p><pre>pragma solidity ^0.4.18; // bad: compiles w 0.4.18 and above</pre><pre>pragma solidity 0.4.18; // good : compiles w 0.4.18 only</pre><p>We recommend following the latter example, as future compiler versions may handle certain language constructions in a way the developer did not foresee. Besides, we recommend using the latest compiler version (0.4.18 at the moment).</p><blockquote>The issue has been fixed by the developer and is not present on commit 63443af8.</blockquote><h4>Function can be declared as view</h4><p>In many places in the code there are functions that can be declared as view. If a function is not supposed to modify the state, consider declaring it as view (alias for constant, which will be deprecated for functions). This provides additional checks in case these assumptions are violated. If a function is not supposed to modify the state or read from state, consider declaring it as pure.</p><blockquote>The issue has been fixed by the developer and is not present on commit 63443af8.</blockquote><h3>Conclusion</h3><p>In this report we have considered the security of Brickblock smart contracts. We performed our audit according to the procedure described above.</p><p>The audit showed high code quality and no critical issues. Several medium and low severity issues have been found and reported to the developer. All of them were fixed by the developer and are not present on commit 63443af8.</p><p>This analysis was performed by <a href="https://www.smartcontracts.smartdec.net/">SmartDec</a></p><figure><a href="https://smartdec.net/"><img alt="" src="https://cdn-images-1.medium.com/max/984/1*lQzS16OSX9-DCSNveDlN5g.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1a3a46845dc1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/smartdec/brickblock-smart-contracts-security-audit-1a3a46845dc1">Brickblock Smart Contracts Security Audit</a> was originally published in <a href="https://medium.com/smartdec">SmartDec Cybersecurity Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Narrative Smart Contracts Security Audit]]></title>
            <link>https://medium.com/smartdec/narrative-smart-contracts-security-audit-284cd8ef3a9f?source=rss-e1a3d7ba9753------2</link>
            <guid isPermaLink="false">https://medium.com/p/284cd8ef3a9f</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[solidity]]></category>
            <category><![CDATA[audit]]></category>
            <dc:creator><![CDATA[Alexander Seleznev]]></dc:creator>
            <pubDate>Thu, 09 Nov 2017 13:51:05 GMT</pubDate>
            <atom:updated>2018-02-15T18:11:45.572Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*LHU113KBSb3v7pFT8J4BIQ.png" /></figure><p>In this report we consider the security of the <a href="https://www.narrative.network/">Narrative</a> project. Our task is to find and describe security issues in the smart contracts of the platform.</p><h3>Procedure</h3><p>In our analysis we consider Narrative <a href="https://assets.narrative.network/documents/narrative-network.pdf">whitepaper</a> (version on 4 Nov 2017) and <a href="https://github.com/NarrativeNetwork/tokensale-smartcontract">smart contracts</a> code (version on commit c2aed53).</p><p>We perform our audit according to the following procedure:</p><p><strong>Automated analysis:</strong></p><ul><li>we scan project’s smart contracts with our own Solidity static code analyzer <a href="https://tool.smartdec.net/">SmartCheck</a></li><li>we scan project’s smart contracts with several publicly available automated Solidity analysis tools such as <a href="https://remix.ethereum.org/">Remix</a>, <a href="https://oyente.melon.network/">Oyente</a> and <a href="http://securify.ch/">Securify</a> (beta version since full version was unavailable at the moment this report was made)</li><li>we manually verify (reject or confirm) all the issues found by tools</li></ul><p><strong>Manual audit:</strong></p><ul><li>we manually analyze smart contracts for security vulnerabilities</li><li>we check smart contracts logic and compare it with the one described in the whitepaper</li><li>we deploy contracts and run tests</li></ul><p><strong>Report:</strong></p><ul><li>we report all the issues found to the developer during the audit process</li><li>we check the issues fixed by the developer</li><li>we reflect all the gathered information in the report</li></ul><h3>Disclaimer</h3><p>The audit does not give any warranties on the security of the code. One audit can not be considered enough. We always recommend proceeding to several independent audits and a public bug bounty program to ensure the security of the smart contracts.</p><h3>Checked vulnerabilities</h3><p>We have scanned Narrative smart contracts for commonly known and more specific vulnerabilities. Here are some of the commonly known vulnerabilities that we considered (the full list includes them but is not limited to them):</p><ul><li><a href="https://media.readthedocs.org/pdf/solidity/develop/solidity.pdf">Reentrancy</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#timestamp-dependence">Timestamp Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#gas-limit-and-loops">Gas Limit and Loops</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-unexpected-throw">DoS with (Unexpected) Throw</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#dos-with-block-gas-limit">DoS with Block Gas Limit</a></li><li><a href="https://github.com/ethereum/wiki/wiki/Safety#transaction-ordering-dependence-tod">Transaction-Ordering Dependence</a></li><li><a href="http://solidity.readthedocs.io/en/develop/security-considerations.html#tx-origin">Use of tx.origin</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Exception disorder</a></li><li><a href="https://eprint.iacr.org/2016/1007.pdf">Gasless send</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#enforce-invariants-with-assert">Balance equality</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#fixed-size-byte-arrays">Byte array</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#be-aware-of-the-tradeoffs-between-send-transfer-and-callvalue">Transfer forwards all gas</a></li><li><a href="https://theethereum.wiki/w/index.php/ERC20_Token_Standard">ERC20 API violation</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#libraries">Malicious libraries</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#lock-pragmas-to-specific-compiler-version">Compiler version not fixed</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#fallback-function">Redundant fallback function</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#members-of-addresses">Send instead of transfer</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#linters">Style guide violation</a></li><li><a href="https://github.com/ConsenSys/smart-contract-best-practices#external-calls">Unchecked external call</a></li><li><a href="https://ethereum.stackexchange.com/questions/7293/is-it-possible-to-overflow-uints">Unchecked math</a></li><li><a href="http://solidity.readthedocs.io/en/develop/types.html#type-deduction">Unsafe type inference</a></li><li><a href="http://solidity.readthedocs.io/en/develop/contracts.html#visibility-and-getters">Implicit visibility level</a></li></ul><h3>Automated Analysis</h3><p>We used several publicly available automated Solidity analysis tools. Here are the combined results of their analysis. All the issues found by tools were manually checked (rejected or confirmed).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fairtable.com%2Fembed%2FshrJRLehnUIR8QhA8&amp;url=https%3A%2F%2Fairtable.com%2FshrJRLehnUIR8QhA8&amp;image=https%3A%2F%2Fstatic.airtable.com%2Fimages%2Foembed%2Fairtable.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=airtable" width="800" height="533" frameborder="0" scrolling="no"><a href="https://medium.com/media/93a0d6e13ad8efa2cb7b152a068bade9/href">https://medium.com/media/93a0d6e13ad8efa2cb7b152a068bade9/href</a></iframe><p><strong><em>Securify* </em></strong><em>— beta version, full version is unavailable.</em></p><p>Cases when these issues lead to actual bugs or vulnerabilities are described in the next section.</p><h3>Manual Analysis</h3><p>Contracts were completely manually analyzed, their logic was checked and compared with the one described in the whitepaper. Besides, the results of automated analysis were manually verified. We describe all confirmed issues below.</p><h3>High severity issues</h3><p>High severity issues seriously endanger smart contracts security. We highly recommend fixing them.</p><h4>Access control violation</h4><p>The removeFromWhiteList in whitelist.sol, line 51 does not have onlyOwner modifier (which the addToWhiteList function has). Thus, any user can remove users from white list. We highly recommend adding the modifier.</p><blockquote>The issue was fixed by the developer and is not present on commit b72f45f.</blockquote><h4>Bug in the code</h4><p>The removeFromWhiteList in whitelist.sol, line 54 does not decrease the counter when the user is removed from the whitelist. We highly recommend fixing this bug.</p><blockquote>The issue was fixed by the developer and is not present on commit b72f45f.</blockquote><h3>Medium severity issues</h3><p>Medium issues can influence smart contracts operation in current implementation. We highly recommend addressing them.</p><h4>Checks-Effects-Interactions pattern violation</h4><p>Checks-Effects-Interactions pattern is violated in crowdsale.sol, line 418:</p><pre>token.unlock();<br>dateICOEnded = now;</pre><p>We highly recommend following best practices including Checks-Effects-Interactions pattern since it helps to avoid many serious vulnerabilities.</p><blockquote>The issue was fixed by the developer and is not present on commit b72f45f.</blockquote><h4>Changed standard contract</h4><p>In whitelist.sol, line 22, standard version of the Ownable contract is overridden with the following:</p><pre>if (msg.sender == owner)</pre><p>In this version, the modifier will not give a throw as the standard version would.</p><p>On the other hand, in crowdsale.sol, line 42, the standard version with require is used. We highly recommend using standard versions of standard contracts. If changes are necessary, we recommend implicitly informing the user about the made changes. Besides, we highly recommend not using different (modified and standard) versions of the standard contract with the same name.</p><blockquote>The issue was fixed by the developer and is not present on commit b72f45f.</blockquote><h3>Low severity issues</h3><p>Low severity issues can influence smart contracts operation in future versions of code. We recommend to take them into account.</p><h4>Fallback function requires too much gas</h4><p>Fallback function in GLACrowdsale.sol, line 325 is pretty big. If the fallback function requires more than 2300 gas, the contract cannot receive Ether by some of standard ways. We recommend to avoid creating big fallback functions. If it is impossible, we recommend to mention in API documentation that contract might not be able to accept Ether in some cases.</p><blockquote>The issue was fixed by the developer: user is instructed to specify gas limit e.g. 250,000 when sending the contribution.</blockquote><h3>Codestyle issues</h3><p>Codestyle issues influence code conciseness and readability and in some cases may lead to bugs in future. We recommend to take them into account.</p><h4>Function name mistyped</h4><p>There are typos in function names:</p><ul><li>crowdsale.sol, line 140: tansferTeamTokens instead of transferTeamTokens</li><li>crowdsale.sol, line 164: tansferCompanyTokens instead of transferCompanyTokens</li></ul><blockquote>The issue was fixed by the developer and is not present on commit b72f45f.</blockquote><h4>View function</h4><p>The isWhiteListed function in crowdsale.sol, line 104 is actually view but does not have view modifier in crowdsale.sol, though it has the modifier in whitelist.sol where it is defined.</p><blockquote>The issue was fixed by the developer and is not present on commit b72f45f.</blockquote><h4>Implicit visibility level</h4><p>In crowdsale.sol, lines 585 and 586 there are variables with implicit visibility level:</p><pre>mapping(address =&gt; uint) balances;</pre><pre>mapping(address =&gt; mapping(address =&gt; uint)) allowed;</pre><p>We recommend specifying visibility level explicitly or following strict notation on when to specify it and when not to.</p><blockquote>The issue was fixed by the developer and is not present on commit b72f45f.</blockquote><h3>Conclusion</h3><p>In this report we have considered the security of Narrative smart contracts. We performed our audit according to the procedure described above.</p><p>The audit showed several issues of different severity level. All of them were reported to the developer and fixed by the developer on commit b72f45f.</p><p><strong>This analysis was performed by </strong><a href="https://smartcontracts.smartdec.net/"><strong>SmartDec</strong></a><strong>.</strong></p><figure><a href="https://smartdec.net/"><img alt="" src="https://cdn-images-1.medium.com/max/984/1*lQzS16OSX9-DCSNveDlN5g.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=284cd8ef3a9f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/smartdec/narrative-smart-contracts-security-audit-284cd8ef3a9f">Narrative Smart Contracts Security Audit</a> was originally published in <a href="https://medium.com/smartdec">SmartDec Cybersecurity Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reading iOS app binary files. Part 2: Swift]]></title>
            <link>https://medium.com/smartdec/reading-ios-app-binary-files-part-2-swift-313254abadd8?source=rss-e1a3d7ba9753------2</link>
            <guid isPermaLink="false">https://medium.com/p/313254abadd8</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[objective-c]]></category>
            <dc:creator><![CDATA[Alexander Seleznev]]></dc:creator>
            <pubDate>Sat, 28 Oct 2017 05:01:01 GMT</pubDate>
            <atom:updated>2017-10-28T05:01:01.495Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OrraVz7RE2R8Vb1xKfXKLw.jpeg" /></figure><p>This is another episode in the series about the reading of iOS app binary files. To dive into technical details, you are strongly encouraged to read Part 1 here:</p><p><a href="https://blog.smartdec.net/reading-ios-app-binary-files-2c9e63a381ad">Reading iOS app binary files</a></p><p>In this post, you will learn about how Swift code is packed into a binary file.</p><p>So, let’s code a Single View Application in Swift and add the following Inspected.swift:</p><pre><strong>import</strong> Foundation</pre><pre><strong>class</strong> InspectedObject {<br> <strong>var</strong> intVar : Int = 57<br> let stringConst = &quot;const string&quot;</pre><pre><strong>func</strong> instanceMethod(arg:Int) -&gt; Int {<br>  return arg + 57<br> }</pre><pre><strong>func</strong> toBeOverriden() {}</pre><pre><strong>static</strong> <strong>func</strong> classMethod() {}<br>}</pre><pre><strong>class</strong> SubInspectedObject: InspectedObject {<br> <strong>var</strong> subConstInt = 1543;<br> let subStringVar = &quot;sub const string&quot;</pre><pre><strong>func</strong> subInstanceMethod() {}</pre><pre><strong>override</strong> <strong>func</strong> toBeOverriden() {}<br>}</pre><p>Please note that it makes sense to create a build from such code in a debug configuration only, since in the creation of a release build everything will be inlined and devirtualized by Swift.</p><p>Again, let’s find our class in objc_classlist. Instead of a name, we see a mangled string: __TMC12InspectedApp15InspectedObject. I won’t dip into the Swift mangling algorithm here (and there is no need to do so), since new Xcode includes a swift-demangle utility which you can find using a path like this:</p><pre>/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-demangle</pre><p>Using swift-demangle gives us:</p><pre>_TMC12InspectedApp15InspectedObject ---&gt; type metadata for InspectedApp.InspectedObject</pre><p>In other words, the address keeps the description of the InspectedObject class, no surprises here. Let’s take a look at the description: the structure is similar to that of an Objective-C class but not identical:</p><ol><li>Two 64-bit words before the structure’s beginning also relate to the class description.</li><li>The last bit of a pointer to raw_data is equal to 1 and indicates that the class is written in Swift.</li><li>A set of fixed fields is followed by a variable-size part, a virtual table with methods and other class members.</li><li>A raw_data structure also exists here, but all information is contained in a class descriptor as well.</li></ol><p>To examine a Swift class structure in a binary file, refer to <a href="https://github.com/apple/swift/blob/swift-3.0.1-preview-2-branch/include/swift/Runtime/Metadata.h">source code</a>. A class entry is composed of fields of the following classes from this file:</p><ul><li>HeapMetadataHeaderPrefix (destructor),</li><li>TypeMetadataHeader (value witness table),</li><li>TypeMetadataHeader (kind=isa),</li><li>TargetClassMetadata (all the rest).</li></ul><p>Let’s put it all together:</p><pre><strong>struct</strong> swift_class{<br> <strong>uint64</strong> destructor_addr; <em>// destructor address</em><br> <strong>uint64</strong> witness_table_addr; <em>// address of a class utility method table enabling to allocate objects in memory and manipulate them</em><br> <strong>uint64</strong> metaclass_addr; <em>// as in Objective-C</em><br> <strong>uint64</strong> superclass_addr; <em>// as in Objective-C</em><br> <strong>uint64</strong> cache_addr; <em>// as in Objective-C</em><br> <strong>uint64</strong> vtable_addr; <em>// as in Objective-C</em><br> <strong>uint64</strong> data_addr; <em>// as in Objective-C + 1 LSB</em><br> <strong>uint32</strong> class_flags; <em>// Swift flags (see below)</em><br> <strong>uint32</strong> inst_addr_point; <em>// this is where, relatively to a class instance start, instance pointers point to</em><br> <strong>uint32</strong> inst_size;<em> // class instance size</em><br> <strong>uint16</strong> inst_align_mask; <em>// alignment mask</em><br> <strong>uint16</strong> reserved; <em>// reserved to be used in runtime</em><br> <strong>uint32</strong> class_size; <em>// class object size</em><br> <strong>uint32</strong> class_addr_point; <em>// this is where, relatively to a class start, class pointers point to</em><br> <strong>int64</strong> descriptor_rel_addr; <em>// relative pointer to a class descriptor (see below)</em><br> <strong>int64</strong> ivar_destroyer; <em>// a method for ivar deallocation in case of a premature return from a constructor (in case of an exception)</em><br>}</pre><p>Swift flags are ClassFlags objects taken from <a href="https://github.com/apple/swift/blob/swift-3.0.1-preview-2-branch/include/swift/ABI/MetadataValues.h">here</a>.</p><p>This fixed structure is followed by class members in the following order:</p><ul><li>Superclass members (recursively)</li><li>A reference to superclass data must be made here, however, currently it is always a zero 64-bit word</li><li>Template parameters for this class</li><li>Class variables (once Swift starts supporting them)</li><li>Virtual methods</li></ul><p>Take a look at InspectedObject and SubInspectedObject classes in our generated binary file. Please pay special attention to a variable-size part after the variable destructor, which includes several 64-bit words. They are not parsed by Hopper and look something like this (0x100008144 and 0x100008158 are written in succession):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*i2OxBjfzAKfOX5wqRXw58Q.png" /></figure><p>Let’s represent them in a more comprehensible form. InspectedObject:</p><pre>0x1000041b4 <em>// intVar getter</em></pre><pre>0x1000041c8 <em>// intVar setter</em></pre><pre>0x1000041e0 <em>// intVar.materializeForSet() is a method that returns a pointer to a point in memory where intVar is stored (see the details </em><a href="https://github.com/apple/swift/blob/swift-3.0.1-preview-2-branch/docs/proposals/Accessors.rst"><em>here</em></a><em>)</em></pre><pre>0x100004108 <em>// instanceMethod (arg: Int) -&gt; Int</em></pre><pre>0x100004138 <em>// InspectedObject.toBeOverriden() — this method is redefined in a subclass</em></pre><pre>0x1000081d8 <em>// InspectedObject.init () -&gt;InspectedObject</em></pre><pre>0x10 <em>// offset for intVar</em></pre><pre>0x18 <em>// stringConst offset</em></pre><pre>SubInspectedObject:</pre><pre>0x1000041b4 <em>// intVar getter</em></pre><pre>0x1000041c8 <em>// intVar setter</em></pre><pre>0x1000041e0 <em>// intVar.materializeForSet()</em></pre><pre>0x100004108 <em>// instanceMethod (arg: Int) -&gt; Int</em></pre><pre>0x100004344 <em>// SubInspectedObject.toBeOverriden() is a redefined method in place of an original method</em></pre><pre>0x10000447c <em>// SubInspectedObject.init() -&gt; SubInspectedObject — init is also in place of superclass init</em></pre><pre>0x10 <em>// offset for intVar</em></pre><pre>0x18 <em>// stringConst offset</em></pre><p>Superclass members end here. Next:</p><pre>0x1000043e8 <em>// subConstInt getter</em></pre><pre>0x1000043fc <em>// subConstInt setter</em></pre><pre>0x100004414 <em>// subConstInt.materializeForSet()</em></pre><pre>0x100004334 <em>// SubInspectedObject.subInstanceMethod ()</em></pre><pre>0x30 <em>// offset for subConstInt</em></pre><pre>0x38 <em>// offset for subStringVar</em></pre><p>Some points should be mentioned here.</p><p><strong>First,</strong> reference to the toBeOverriden() method is located at the same place in both InspectedObject and SubInspectedObject. This allows Swift to recall virtual methods by an offset from class start.</p><p><strong>Second,</strong> Swift does not generate certain setters and getters. Moreover, it does not appear to use a reasonable rule “generate them for variable ivars and not generate for constant ones”.</p><p><strong>Third,</strong> method names and interfaces were provided by Hopper, which retrieved them from a symbol table. However, respective symbols are not needed for program operation, so they are usually cut-off from a binary file. That is why details about Swift method signatures usually cannot be obtained from a binary file except for a case to follow.</p><p>And now let’s take a class descriptor, for which the pointer type is signed. For example, in our binary file, the pointer is stored at 0x1000094a0 and is written as 0xffffffffffffd9e8: a hexadecimal notation of a negative value -0x2618. Thus, we arrive at: 0x1000094a0–0x2618=0x100006e88, which is the address where the descriptor can be found. The descriptor contains the following data:</p><pre><strong>struct</strong> {<br> <strong>int32</strong> name_addr; <em>// name&#39;s relative address</em><br> <strong>uint32</strong> num_fields; <em>// the number of ivars</em><br> <strong>uint32</strong> fields_offsets_vector_offset; <em>// offset from class start to ivar offset vector</em><br> <strong>int32</strong> fields_names_addr; <em>// ivar names are consecutively stored at this address</em><br> <strong>int32</strong> fields_types_accessor_addr; <em>// a relative address of a method returning an ivar type vector</em><br> <strong>uint32</strong> generic_pattern_and_kind; <em>// information for template classes</em><br> <strong>int32</strong> metadata_accessor_addr; <em>// a relative pointer to a method returning a pointer to class data and used to construct class objects</em><br>}</pre><p>It turns out that ivar type information is not stored in an explicit form. However, it can be extracted from the code of fields types accessor method. For example, fields types accessor for InspectedObject has the following strings (<a href="https://www.raywenderlich.com/37181/ios-assembly-tutorial">arm64 assembler</a>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/573/1*P0i4wiOhHRHO0eYs5valMA.png" /></figure><p>Here, the stack keeps the types, which are referenced to at 0x100008000 and 0x100008008. Let’s take a look at what’s in there:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*X17y4BB00uXfmMr1_6ElQw.png" /></figure><p>We see Hopper-parsed __TMSS and __TMSi, which are demangled in Swift.String and Swift.Int. The respective symbols are not local and therefore not cut-off from a symbol table.</p><p>So, when collecting this all together and assuming there are no symbols corresponding to internal methods, we come to the following reconstructed interface of InspectedObject class:</p><pre><strong>class</strong> InspectedObject {<br> <strong>var</strong> intVar : Int;<br> <strong>var</strong> stringConst : String;</pre><pre> <strong>func</strong> sub_100004108()<br> <strong>func</strong>    sub_100004138()</pre><pre>}</pre><p>Please note that classMethod() is generated as an independent function and its presence cannot be reconstructed solely from a binary code.</p><p>In general, the interface reconstructed from a Swift class is rather scarce. However, if a class has an Objective-C class as a superclass, then it supports Objective-C compatibility mode and all Swift methods are packed in Objective-C methods, thus allowing for name reconstruction.</p><p>So, add NSobject inheritance to InspectedObject declaration:</p><pre><strong>class</strong> InspectedObject : NSObject{</pre><pre>...</pre><pre>}</pre><p>Let’s take a look at the binary file. Now, raw_data is filled and we see all declared methods, including setters, getters, and ClassMethod() in a metaclass. Method names are slightly changed, for example, we see “instanceMethodWithArg:” instead of “InstanceMethod”. What’s in the code of the method?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/866/1*Ahv9hBUuWbpMOenOFEHF1w.png" /></figure><p>This is an arm64 assembler code and all we need to know about it is that bl instructions correspond to the calls of other methods from such code. We can see that a respective Swift method can be called. Even if we have no symbol table, this method can be figured out because all other calls (bl instructions) are retain calls and release calls and their symbols are not cut-off.</p><p>The same approach is used to find ClassMethod in a metaclass. Now, the interface is reconstructed in a much better way:</p><pre><strong>class</strong> InspectedObject {<br> <strong>var</strong> intVar : Int<br> <strong>let</strong> stringConst : String</pre><pre> <strong>func</strong> instanceMethodWithArg(Int) -&gt; Int<br> <strong>func</strong> toBeOverriden()<br> <strong>static</strong> <strong>func</strong> classMethod()<br>}</pre><blockquote>Author of this article is <strong>Egor Fominykh</strong>, ex-lead developer in <a href="http://smartdec.net/"><strong>SmartDec</strong></a>.</blockquote><blockquote>Article was first published in <a href="https://appscreener.us/blog/reading-ios-app-binary-files/">Solared Blog</a></blockquote><blockquote>Photo by <a href="https://unsplash.com/photos/2M8_gK12vbw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Hal Gatewood</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></blockquote><figure><a href="https://smartdec.net/"><img alt="" src="https://cdn-images-1.medium.com/max/984/1*lQzS16OSX9-DCSNveDlN5g.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=313254abadd8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/smartdec/reading-ios-app-binary-files-part-2-swift-313254abadd8">Reading iOS app binary files. Part 2: Swift</a> was originally published in <a href="https://medium.com/smartdec">SmartDec Cybersecurity Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SmartDec & Confideal Partnership Announcement]]></title>
            <link>https://medium.com/smartdec/smartdec-confideal-partnership-announcement-1584c3fa85a8?source=rss-e1a3d7ba9753------2</link>
            <guid isPermaLink="false">https://medium.com/p/1584c3fa85a8</guid>
            <category><![CDATA[confideal]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[smart-contracts]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Alexander Seleznev]]></dc:creator>
            <pubDate>Fri, 27 Oct 2017 10:45:13 GMT</pubDate>
            <atom:updated>2017-10-27T10:45:44.905Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RkDvOvilBVHT5Ykfjk-63Q.png" /></figure><p>The <a href="https://smartcontracts.smartdec.net/"><strong>SmartDec</strong></a> team is excited to announce its technological partnership with <a href="https://confideal.io/"><strong>Confideal</strong></a>.</p><p>Confideal is a service for making fast and safe deals through smart contracts on Ethereum blockchain. It requires no programming skills and features a user-friendly interface for creating complex smart contracts. In case of disputes, parties can have them resolved through qualified trird-party arbitration (to be launched soon).</p><p>Confideal’s roadmap includes: advanced smart contract management tools, multi-language support, API, IoT integration, scalability to other blockchains.</p><blockquote>Confideal is the first platform to use SmartCheck, a vulnerability scanner for smart contracts written in Solidity.</blockquote><p>We’ve been working on SmartCheck since the beginning of 2017 and already use it in our <a href="https://blog.smartdec.net/tagged/audit"><strong>security audits</strong></a>. It is currently in closed beta. According to our studies, SmartCheck far surpasses other publicly available security tools for smart contracts in Solidity.</p><p>We are ready to discuss integration of SmartCheck into any blockchain platform or any website dedicated to smart contracts. We are also ready to allow its usage for research purposes.</p><p>Please feel free to <a href="/service/mailto:info@smartdec.net">contact us</a> for further information!</p><figure><a href="https://smartcontracts.smartdec.net/"><img alt="" src="https://cdn-images-1.medium.com/max/984/1*lQzS16OSX9-DCSNveDlN5g.png" /></a></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1584c3fa85a8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/smartdec/smartdec-confideal-partnership-announcement-1584c3fa85a8">SmartDec &amp; Confideal Partnership Announcement</a> was originally published in <a href="https://medium.com/smartdec">SmartDec Cybersecurity Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>