<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jcsec.io</title>
	<atom:link href="https://jcsec.io/feed/" rel="self" type="application/rss+xml" />
	<link>https://jcsec.io</link>
	<description>Smart Contracts Audit and Shift-Left Security Consulting</description>
	<lastBuildDate>Wed, 13 Sep 2023 11:11:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.5</generator>
	<item>
		<title>Give me Warnings! Tornado Cash’s Proposal Incident</title>
		<link>https://jcsec.io/give-me-warnings-tornado-cashs-proposal-incident-2/</link>
		
		<dc:creator><![CDATA[JC]]></dc:creator>
		<pubDate>Tue, 06 Jun 2023 11:14:59 +0000</pubDate>
				<category><![CDATA[Blockchain]]></category>
		<category><![CDATA[Dao]]></category>
		<category><![CDATA[Ethereum]]></category>
		<category><![CDATA[Governance]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://jcsec.io/?p=953</guid>

					<description><![CDATA[<p>Yet another post on Tornado Cash’s incident, but the problem is much bigger. In DeFi, we keep learning our lessons&#160;the hard way.&#160;That is, losing assets to a properly crafted&#160;scam, exploit or trick. The most recent event that highlights that even technical folks are being tricked into trusting is the&#160;Tornado Cash governance incident. On the 20th [&#8230;]</p>
<p>La entrada <a rel="nofollow" href="https://jcsec.io/give-me-warnings-tornado-cashs-proposal-incident-2/">Give me Warnings! Tornado Cash’s Proposal Incident</a> se publicó primero en <a rel="nofollow" href="https://jcsec.io">jcsec.io</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading" id="87db">Yet another post on Tornado Cash’s incident, but the problem is much bigger.</h2>



<p class="wp-block-paragraph" id="e3e1">In DeFi, we keep learning our lessons&nbsp;<em>the hard way.</em>&nbsp;That is, losing assets to a properly crafted&nbsp;<strong>scam, exploit or trick</strong>. The most recent event that highlights that even technical folks are being tricked into trusting is the&nbsp;<a href="https://twitter.com/samczsun/status/1660012956632104960" rel="noreferrer noopener" target="_blank">Tornado Cash governance incident</a>.</p>



<p class="wp-block-paragraph" id="9e03">On the 20th of May, a new proposal was submitted to TC governance,&nbsp;<a href="https://boardroom.io/tornadocash/proposal/cHJvcG9zYWw6dG9ybmFkb2Nhc2g6b25jaGFpbjoyMA==" rel="noreferrer noopener" target="_blank">Proposal #20</a>. It did not look suspicious, but proposals&nbsp;<strong>should not be blindly trusted</strong>&nbsp;and the code should be checked. The proposer stated&nbsp;<code>Use same logic of proposal #16</code>&nbsp;and indeed it looked&nbsp;<em>pretty</em>&nbsp;similar! so it was&nbsp;<strong>deemed benign</strong>.</p>



<p class="wp-block-paragraph" id="9632">But&nbsp;<em>pretty&nbsp;</em>similar is not good enough for security, as you already know by now. The following additional code was sneaked in:function emergencyStop() public onlyOwner {<br>selfdestruct(payable(0));<br>}</p>



<p class="wp-block-paragraph" id="cceb">After the proposal&nbsp;<strong>passed</strong>, the attacker triggered&nbsp;<code>selfdestruct</code>&nbsp;and deployed new code through the handy&nbsp;<code>create2</code>&nbsp;. This time they included&nbsp;<strong>arbitrary code</strong>&nbsp;that would be executed shortly after by the Governance contract.</p>



<p class="wp-block-paragraph" id="a8e3">This post is not to discuss the impact of the attack or the technicalities of how to deploy contracts to the same address through&nbsp;<code>create2</code>. Just to bring attention to the need for improved UX when&nbsp;<strong>informed decisions</strong>&nbsp;need to be made. Not just when a plain user signs their first transaction, but when technical folks deal with&nbsp;<strong>day-to-day tasks</strong>&nbsp;that require sharp attention to detail but more often than not&nbsp;<strong>result in a swift “LGTM”</strong>&nbsp;after a quick glance.</p>



<p class="wp-block-paragraph" id="e1d5">This highlights two problems with standard governance procedures:</p>



<ol class="wp-block-list">
<li>Voters may not the well-versed enough in a technical sense to vet a proposal.</li>



<li>Even technical users can easily be tricked by a poor&nbsp;<strong>user experience</strong>&nbsp;(UX).</li>
</ol>



<p class="wp-block-paragraph" id="387d">We will leave the first point for another (potentially long) discussion, but the second point is a generic problem and one of the&nbsp;<strong>big blockers to the mass adoption</strong>&nbsp;of Defi and Web3 in general.</p>



<p class="wp-block-paragraph" id="029b">We don’t even have to look as far as governance proposals. Even basic transaction signing is intimidating for less technical users (and expert users alike) as those long JSON messages may look like&nbsp;<strong>dark magic</strong>. Sometimes, you don’t even get JSON. Still, you should not “click through” without paying attention or risk your funds to&nbsp;<em>approve-all</em>&nbsp;requests or various scams.</p>



<p class="wp-block-paragraph" id="7d3a">However, the need for more user-friendly flows turns into&nbsp;<strong>an issue even for the more technical pals</strong>. It is not a matter of not being aware of the risks, but helping the user&nbsp;<strong>focus</strong>&nbsp;on the potentially concerning bits. Although sometimes perceived as redundant, being reminded that “this is the moment that you should make an informed decision!” or “Have you double-checked &lt;this&gt;?” could save you. Just think about when you incorrectly closed a document you were working on and the “Unsaved changes, do you really want to exit?” message saved you an hour&#8217;s work.</p>



<p class="wp-block-paragraph" id="cb0f">We cannot tell for sure, but if the process of reviewing the Tornado governance proposal code included a&nbsp;<strong>powerful UX/UI</strong>, we could maybe have seen a very different outcome. Having a handy environment that highlights&nbsp;<strong>important sections</strong>&nbsp;of the code and prompts the reviewer to&nbsp;<strong>explicitly accept</strong>&nbsp;<strong>each warning</strong>&nbsp;or recommendation before marking the code as trustworthy will reduce the number of&nbsp;<strong>tired LGTMs&nbsp;</strong>crossing our minds.</p>



<p class="wp-block-paragraph"><a href="https://medium.com/@jcsec-audits?source=post_page-----e70d125aa52c--------------------------------" target="_blank" rel="noopener"></a></p>
<p>La entrada <a rel="nofollow" href="https://jcsec.io/give-me-warnings-tornado-cashs-proposal-incident-2/">Give me Warnings! Tornado Cash’s Proposal Incident</a> se publicó primero en <a rel="nofollow" href="https://jcsec.io">jcsec.io</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>CosmWasm security spotlight #2</title>
		<link>https://jcsec.io/cosmwasm-security-spotlight-2/</link>
					<comments>https://jcsec.io/cosmwasm-security-spotlight-2/#respond</comments>
		
		<dc:creator><![CDATA[JC]]></dc:creator>
		<pubDate>Mon, 17 Apr 2023 09:05:46 +0000</pubDate>
				<category><![CDATA[Blockchain]]></category>
		<category><![CDATA[Cosmos]]></category>
		<category><![CDATA[Cosmwasm]]></category>
		<category><![CDATA[Security Audit]]></category>
		<category><![CDATA[Smart Contracts]]></category>
		<guid isPermaLink="false">https://jcsec.io/?p=943</guid>

					<description><![CDATA[<p>Are you a CosmWasm Smart Contract developer? A random Cosmonaut peeking into this cool tech? A Solidity auditor looking for new knowledge?&#160;Then keep reading! There are loads of great content about security findings and auditing of Solidity Smart Contracts. Sadly, that is not the case in CosmWasm…&#160;yet! Access Controls Access controls are one of the [&#8230;]</p>
<p>La entrada <a rel="nofollow" href="https://jcsec.io/cosmwasm-security-spotlight-2/">CosmWasm security spotlight #2</a> se publicó primero en <a rel="nofollow" href="https://jcsec.io">jcsec.io</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph" id="e0c7"><em>Are you a CosmWasm Smart Contract developer? A random Cosmonaut peeking into this cool tech? A Solidity auditor looking for new knowledge?</em>&nbsp;Then keep reading!</p>



<p class="wp-block-paragraph" id="0fbc">There are loads of great content about security findings and auditing of Solidity Smart Contracts. Sadly, that is not the case in CosmWasm…&nbsp;<strong>yet!</strong></p>



<h1 class="wp-block-heading" id="db95">Access Controls</h1>



<p class="wp-block-paragraph" id="8be1">Access controls are one of the main&nbsp;<strong>concerns&nbsp;</strong>in software security. It doesn’t matter if you are talking about webapps, mobile APIs, network services, or Smart Contracts. Being able to restrict who can access specific functionality is key.</p>



<p class="wp-block-paragraph" id="6d05">And of course, if you are protecting access to key functionality that means that&nbsp;<strong>untrusted parties</strong>&nbsp;would cause negative effects by operating them. The actual impact will depend on each individual case, of course. You probably already get a sense of how deadly this could be for your smart contract, but let’s look at the example below. What would happen if you spot the following function in some kind of staking protocol? An anonymous user could set their own address as the vault, receiving&nbsp;<strong>all the rewards accrued</strong>&nbsp;by the contract.fn update_config(<br>deps: DepsMut,<br>msg: UpdateMsg<br>) -&gt; Result&lt;Response, ContractError&gt; {<br>let config = CONFIG.load(deps.storage)?;</p>



<p class="wp-block-paragraph">let new_config = Config {<br>rewards_vault_contract: msg.vault_address<br>.map(|human| deps.api.addr_validate(&amp;human))<br>.transpose()?<br>.unwrap_or(config.rewards_vault_contract)<br>};<br>CONFIG.save(deps.storage, &amp;new_config)?;</p>



<p class="wp-block-paragraph">Ok(Response::new().add_attribute(&#8220;action&#8221;, &#8220;update_config&#8221;))<br>}</p>



<p class="wp-block-paragraph" id="3345">A&nbsp;<strong>Broken Access Control&nbsp;</strong>issue happens either when: access control is missing, it is in place but can be bypassed or the guard in place does not restrict access to the expected actor exclusively.</p>



<p class="wp-block-paragraph" id="52d4">Let’s take a look at the following real-life issues:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph" id="8e8b"><strong>[CRITICAL]&nbsp;</strong>Report 1 finding #1&nbsp;<a href="https://github.com/oak-security/audit-reports/blob/master/CronCat/2023-03-14%20Audit%20Report%20-%20CronCat%20CosmWasm%20v1.0.pdf" rel="noreferrer noopener" target="_blank">“Task contract execute_update_config is permissionless”</a></p>
</blockquote>



<p class="wp-block-paragraph" id="3433">This is one of those “from the book” cases: missing access control in an administrative function. It allowed anonymous users to modify critical parameters to disrupt the contract in different ways, for example, triggering the emergency break.</p>



<p class="wp-block-paragraph" id="8327">The developers knew about Access Controls, of course. Indeed they are very skilled coders that created a high-quality product, in my opinion. But&nbsp;<strong>tiny mistakes</strong>&nbsp;happen to the best, which could lead to disastrous situations if exploited in the wild. That is why auditors are part of the&nbsp;<strong>Secure Development Lifecycle</strong>, to act as additional security-focused pairs of eyes.&nbsp;<strong>Three pairs of eyes</strong>&nbsp;in the case of Oak Security audits <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph" id="d563"><strong>[MAJOR]&nbsp;</strong>Report 2 finding #1&nbsp;<a href="https://github.com/oak-security/audit-reports/blob/master/Astroport/2023-02-14%20Audit%20Report%20-%20Astroport%20IBC%20v1.0.pdf" rel="noreferrer noopener" target="_blank">“Incorrect permissioning of IbcExecuteProposal execution leads to failure of proposal execution and elevated owner privileges”</a></p>
</blockquote>



<p class="wp-block-paragraph" id="a7d7">In this case, there was access control in place! Just not the correct one. Instead of restricting access to the contract expected to submit proposals through IBC, access was granted to the&nbsp;<code>owner</code>.</p>



<p class="wp-block-paragraph" id="a165">This results in two different risks: the protocol was not able to&nbsp;<strong>properly operate</strong>&nbsp;as it will error out on each new proposal, and the&nbsp;<code>owner</code>&nbsp;could freely submit proposals. The second one does not just go against&nbsp;<strong>decentralization</strong>&nbsp;principles but opens up for a more dramatic impact in case the owner&nbsp;<strong>keys get compromised</strong>.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph" id="2235"><strong>[CRITICAL]&nbsp;</strong>Report 3 finding #6&nbsp;<a href="https://github.com/oak-security/audit-reports/blob/master/Margined%20Protocol/2022-10-28%20Audit%20Report%20-%20Margined%20Protocol%20Perpetuals%20v1.0.pdf" rel="noreferrer noopener" target="_blank">“Emergency ShutDownVamms messages are not able to execute SetOpen transactions due to lack of permissions”</a></p>
</blockquote>



<p class="wp-block-paragraph" id="bc49">As in the above finding, incorrect access controls were in place. In this case, the affected functionality was an emergency feature to pause virtual AMMs in case of need. This was not possible at all as instead of accepting interactions from the key&nbsp;<code>insurance_fund</code>&nbsp;contract, the guard only allowed the owner to use the emergency pause feature.</p>



<h2 class="wp-block-heading" id="2226">Hunt the bug!</h2>



<p class="wp-block-paragraph" id="bd80">Go practice in the&nbsp;<a href="https://github.com/oak-security/cosmwasm-security-dojo/tree/main/challenges/02-auth" rel="noreferrer noopener" target="_blank">second challenge</a>&nbsp;of Oak Security CosmWasm Security Dojo created by Richie, and hunt this bug in a small lending contract. Peeking into the exploit too soon counts as cheating! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f61b.png" alt="😛" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<h2 class="wp-block-heading" id="f626">How to avoid this issue?</h2>



<p class="wp-block-paragraph" id="d6fc">This vulnerability should be approached at different stages: design, implementation, and testing.</p>



<p class="wp-block-paragraph" id="9029">During the&nbsp;<strong>design phase</strong>, you should thoroughly brainstorm and&nbsp;<strong>document&nbsp;</strong>who should access each entry point or feature following the&nbsp;<strong>“least privilege” principle</strong>. That is, being as restrictive as possible to reduce the attack surface exposed to external actors.</p>



<p class="wp-block-paragraph" id="46c4">The next step may sound obvious to all of you… but well, actually&nbsp;<strong>implement what you have documented</strong>. Double-check it! Still, you should add a safeguard in the form of&nbsp;<strong>thorough testing</strong>&nbsp;to ensure that everything is in place.</p>



<p class="wp-block-paragraph" id="79c6">Someone probably told you already, but your testing should not be limited to happy paths and expected use cases. Years ago I read a statement that looked like this: “a system can be considered secure&nbsp;<strong>if and only if</strong>&nbsp;it does what is supposed to&nbsp;<strong>and nothing else</strong>” — it is a good principle to follow while designing your test cases.</p>



<p class="wp-block-paragraph" id="ae26">Going back to testing access controls, the following may act as a non-exhaustive cheat sheet.&nbsp;<strong>Explicitly test&nbsp;</strong>that:</p>



<ol class="wp-block-list">
<li>The&nbsp;<strong>expected caller</strong>, the one you noted down during the design, can successfully access the feature.</li>



<li>An “Unauthorized” error (or any other custom and descriptive error) is returned when calling from a&nbsp;<strong>random address</strong>. Unless the function is expected to be used by anonymous users, of course.</li>



<li>An “Unauthorized” error is returned when calling from&nbsp;<strong>any other of the privileged addresses</strong>&nbsp;defined in your contract.</li>
</ol>



<h2 class="wp-block-heading" id="7f5d">Contact me!</h2>



<p class="wp-block-paragraph" id="46fe">If you have any questions or comments or want to know more about Oak Security and Solidified, feel free to drop a line to&nbsp;<a href="https://t.me/jcr_auditor" rel="noreferrer noopener" target="_blank"><strong>@jcr_auditor</strong></a>&nbsp;on Telegram or email me at&nbsp;<a href="mailto:jcr@oaksecurity.io" rel="noreferrer noopener" target="_blank"><strong>jcr@oaksecurity.io</strong></a></p>



<p class="wp-block-paragraph" id="9152"><a href="https://github.com/jcsec-security" rel="noreferrer noopener" target="_blank">Check out my&nbsp;<strong>Github&nbsp;</strong>profile</a>&nbsp;for further educational content on Smart Contract security and auditing. For example, the&nbsp;<a href="https://github.com/jcsec-security/Cosmwasm-Audit-roadmap" rel="noreferrer noopener" target="_blank">CosmWasm Security and Audits roadmap</a>!</p>



<p class="wp-block-paragraph" id="c2de"><a href="https://t.me/jcr_auditor" target="_blank" rel="noreferrer noopener"><strong>Telegram</strong></a><strong> | </strong><a href="http://jcr@oaksecurity.io/" target="_blank" rel="noreferrer noopener"><strong>Email</strong></a><strong> | </strong><a href="https://twitter.com/jcsec_audits" target="_blank" rel="noreferrer noopener"><strong>Twitter</strong></a><strong> | </strong><a href="https://github.com/jcsec-security" target="_blank" rel="noreferrer noopener"><strong>Github</strong></a><strong> | </strong><a href="https://www.linkedin.com/in/jcramirezv/" target="_blank" rel="noreferrer noopener"><strong>LinkedIn</strong></a></p>



<hr class="wp-block-separator has-alpha-channel-opacity is-style-dots"/>



<p class="wp-block-paragraph" id="c2de">D<strong>isclaimer!</strong> Although most of the reports I will link are of audits I took part in, I will also include others. <strong>I do not claim ownership of any kind of the external resources included in these articles</strong> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p class="wp-block-paragraph"><a href="https://medium.com/tag/smart-contracts?source=post_page-----3b8abeb066a1---------------smart_contracts-----------------" target="_blank" rel="noopener"></a></p>



<p class="wp-block-paragraph"><a href="https://medium.com/@jcsec-audits?source=post_page-----3b8abeb066a1--------------------------------" target="_blank" rel="noopener"></a></p>
<p>La entrada <a rel="nofollow" href="https://jcsec.io/cosmwasm-security-spotlight-2/">CosmWasm security spotlight #2</a> se publicó primero en <a rel="nofollow" href="https://jcsec.io">jcsec.io</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://jcsec.io/cosmwasm-security-spotlight-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>CosmWasm security spotlight #1</title>
		<link>https://jcsec.io/cosmwasm-security-spotlight-1-2/</link>
		
		<dc:creator><![CDATA[JC]]></dc:creator>
		<pubDate>Mon, 03 Apr 2023 06:58:05 +0000</pubDate>
				<category><![CDATA[Blockchain]]></category>
		<category><![CDATA[Cosmwasm]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Security Audit]]></category>
		<category><![CDATA[Smart Contracts]]></category>
		<guid isPermaLink="false">https://jcsec.io/?p=509</guid>

					<description><![CDATA[<p>Are you a CosmWasm Smart Contract developer? A random Cosmonaut peeking into this cool tech? A Solidity auditor looking for new knowledge?&#160;Then keep reading! There are loads of great content about security findings and auditing of Solidity Smart Contracts. Sadly, that is not the case in CosmWasm…&#160;yet! My name is JC and I have been&#160;auditing [&#8230;]</p>
<p>La entrada <a rel="nofollow" href="https://jcsec.io/cosmwasm-security-spotlight-1-2/">CosmWasm security spotlight #1</a> se publicó primero en <a rel="nofollow" href="https://jcsec.io">jcsec.io</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading" id="b943"><em>Are you a CosmWasm Smart Contract developer? A random Cosmonaut peeking into this cool tech? A Solidity auditor looking for new knowledge?</em>&nbsp;Then keep reading!</h3>



<p class="wp-block-paragraph" id="0fbc">There are loads of great content about security findings and auditing of Solidity Smart Contracts. Sadly, that is not the case in CosmWasm…&nbsp;<strong>yet!</strong></p>



<p class="wp-block-paragraph" id="c387">My name is JC and I have been&nbsp;<strong>auditing CosmWasm</strong>&nbsp;contracts since the end of 2021. I am a proud member of the&nbsp;<a href="https://www.oaksecurity.io/" rel="noreferrer noopener" target="_blank">Oak Security</a>&nbsp;team,&nbsp;<strong>uncontested security provider quality-wise&nbsp;</strong>for all things CW. From now on I will be publishing&nbsp;<strong>knowledge pills</strong>&nbsp;of common security pitfalls of CosmWasm smart contracts, based on issues found during my auditing.</p>



<p class="wp-block-paragraph" id="f7b7">Enough with the introduction! let’s get into today’s topic.</p>



<figure class="wp-block-image"><img decoding="async" src="https://miro.medium.com/v2/resize:fit:700/1*hpOr6Bmfo9t3fW-yIhEbmQ.png" alt=""/></figure>



<h1 class="wp-block-heading" id="db95">Unsaved Storage Changes</h1>



<p class="wp-block-paragraph" id="6d05">Smart Contracts will use different pieces of&nbsp;<strong>storage data</strong>&nbsp;to successfully implement its features: configuration details, privileged addresses, bookkeeping, anything!</p>



<p class="wp-block-paragraph" id="00af">Some functions will just require reading this data and others will modify it… but&nbsp;<strong>sometimes mistakes happen</strong>. Code paths may be complex, last-minute changes may not be as careful as they should or&nbsp;<em>you just forgot</em>.</p>



<pre class="wp-block-code"><code>pub fn update_name(<br>deps: DepsMut,<br>info: MessageInfo,<br>name: Option&lt;String&gt;,<br>) -&gt; Result&lt;Response, ContractError&gt; {<br>ADMIN.assert_admin(deps.as_ref(), &amp;info.sender)?;<br><br>let mut config = CONFIG.load(deps.storage)?;<br><br>if let Some(name) = name {<br>config.name = name;<br>}<br><br>// I feel like I am missing something...<br><br>Ok(Response::new()<br>.add_attribute("action", "update_name")<br>.add_attribute("name", config.name))<br>}</code></pre>



<p class="wp-block-paragraph" id="3345">An&nbsp;<strong>Unsaved Storage Change</strong>&nbsp;issue happens when a function loads a piece of storage, modifies its data, and then never saves it. The concept is quite easy, however, the impact will heavily depend on each case. Let’s take the following issues as an example:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph" id="8e8b"><strong>[CRITICAL]&nbsp;</strong><a href="https://github.com/oak-security/audit-reports/blob/master/Comdex/2022-10-28%20Audit%20Report%20-%20Comdex%20Locking%20and%20Vesting%20Contracts%20v1.0.pdf" rel="noreferrer noopener" target="_blank">Report 1, finding #2 “LOCKINGADDRESS is never populated which will block rebasing functionality”</a></p>
</blockquote>



<p class="wp-block-paragraph" id="3433">The addresses of users that performed a “Lock NFT” action were expected to be appended to&nbsp;<em>LOCKINGADDRESS</em>. Although the rest of the functionality was okay, the updated list of addresses was&nbsp;<strong>never saved in the storage</strong>. This turned other&nbsp;<strong>functionalities completely unusable</strong>, as users were never granted the privileges of having locked the asset.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph" id="c215"><strong>[CRITICAL]&nbsp;</strong><a href="https://github.com/oak-security/audit-reports/blob/master/Margined%20Protocol/2022-10-28%20Audit%20Report%20-%20Margined%20Protocol%20Perpetuals%20v1.0.pdf" rel="noreferrer noopener" target="_blank">Report 2, finding #1 “Bad debt state is not recorded”</a></p>
</blockquote>



<p class="wp-block-paragraph" id="1a3d">The&nbsp;<em>bad_debt</em>&nbsp;attribute of&nbsp;<em>STATE</em>&nbsp;was used to, you guessed right, keep track of the contract’s bad debt! This allowed other features to compensate for potential insolvency scenarios. Passing the state variable around as mutable resulted in an unsaved storage situation where the contract didn’t effectively account for its bad debt. This would have caused the protocol to be&nbsp;<strong>insolvent or at risk of insolvency without it being aware</strong>.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph" id="6fb7"><strong>[Minor]</strong>&nbsp;<a href="https://github.com/oak-security/audit-reports/blob/master/Prism/2022-11-04%20Audit%20Report%20-%20Prism%20Auto%20Compounding%20cAsset%20v1.0.pdf" rel="noreferrer noopener" target="_blank">Report 3, finding #2 of “State update not stored”</a></p>
</blockquote>



<p class="wp-block-paragraph" id="5dab">Loading the same piece of storage&nbsp;<strong>into multiple variables</strong>&nbsp;is error-prone and should be avoided if possible. In this case, the affected functionality updated an attribute of the copy of storage data that was never saved instead of the one that was saved back. In this particular case, the affected attribute was&nbsp;<strong>not used at all</strong>, so the impact was lowered to a minor risk.</p>



<h2 class="wp-block-heading" id="2226">Hunt the bug!</h2>



<p class="wp-block-paragraph" id="bd80">Go practice in the first challenge of&nbsp;<a href="https://github.com/oak-security/cosmwasm-security-dojo" rel="noreferrer noopener" target="_blank">Oak’s CosmWasm Security Dojo</a>&nbsp;created by Richie, and hunt this bug in a small lending contract. Peeking into the exploit too soon counts as cheating! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f61b.png" alt="😛" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<h2 class="wp-block-heading" id="f626">How to avoid this issue?</h2>



<p class="wp-block-paragraph" id="d6fc">Whenever you need to&nbsp;<strong>load information</strong>&nbsp;from the storage, double-check whether you are&nbsp;<strong>modifying this data</strong>. If the information is modified during any of the execution paths, ensure that it is&nbsp;<strong>saved back</strong>&nbsp;into the storage at the end of the function or the path.</p>



<h2 class="wp-block-heading" id="7f5d">Contact me!</h2>



<p class="wp-block-paragraph" id="46fe">If you have any questions, or comments or what to know more about Oak Security and Solidified, feel free to drop a line to&nbsp;<a href="https://t.me/jcr_auditor" rel="noreferrer noopener" target="_blank"><strong>@jcr_auditor</strong></a>&nbsp;in Telegram or email me at&nbsp;<a href="mailto:jcr@oaksecurity.io" rel="noreferrer noopener" target="_blank"><strong>jcr@oaksecurity.io</strong></a></p>



<p class="wp-block-paragraph" id="c2de"><a href="https://github.com/jcsec-security" rel="noreferrer noopener" target="_blank">Check my&nbsp;<strong>Github&nbsp;</strong>profile</a>&nbsp;for further educational content on Smart Contract security and auditing, including Solidity.</p>



<p class="wp-block-paragraph" id="f2d8"><a href="https://t.me/jcr_auditor" rel="noreferrer noopener" target="_blank"><strong>Telegram</strong></a><strong>&nbsp;|&nbsp;</strong><a href="http://jcr@oaksecurity.io/" rel="noreferrer noopener" target="_blank"><strong>Email</strong></a><strong>&nbsp;|&nbsp;</strong><a href="https://twitter.com/jcsec_audits" rel="noreferrer noopener" target="_blank"><strong>Twitter</strong></a><strong>&nbsp;|&nbsp;</strong><a href="https://github.com/jcsec-security" rel="noreferrer noopener" target="_blank"><strong>Github</strong></a><strong>&nbsp;|&nbsp;</strong><a href="https://www.linkedin.com/in/jcramirezv/" rel="noreferrer noopener" target="_blank"><strong>LinkedIn</strong></a></p>



<p class="wp-block-paragraph" id="a15a">D<strong>isclaimer!</strong>&nbsp;although most of the reports I will link are of audits I took part in, I will also include others.&nbsp;<strong>I do not claim ownership of any kind of the external resources included in these articles</strong>&nbsp;<img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p class="wp-block-paragraph"><a href="https://medium.com/@jcsec-audits?source=post_page-----cba294b27ea2--------------------------------" target="_blank" rel="noopener"></a></p>
<p>La entrada <a rel="nofollow" href="https://jcsec.io/cosmwasm-security-spotlight-1-2/">CosmWasm security spotlight #1</a> se publicó primero en <a rel="nofollow" href="https://jcsec.io">jcsec.io</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
