<?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 Antonio Quental on Medium]]></title>
        <description><![CDATA[Stories by Antonio Quental on Medium]]></description>
        <link>https://medium.com/@antonio.quental?source=rss-55ed729bf0b6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EeDfOMNRsf1saCUamljY8A.png</url>
            <title>Stories by Antonio Quental on Medium</title>
            <link>https://medium.com/@antonio.quental?source=rss-55ed729bf0b6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 18:55:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@antonio.quental/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[AI is Just Another Leaky Abstraction]]></title>
            <link>https://medium.com/@antonio.quental/ai-is-just-another-leaky-abstraction-07f681cb23a9?source=rss-55ed729bf0b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/07f681cb23a9</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[ai-assisted-coding]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Antonio Quental]]></dc:creator>
            <pubDate>Tue, 30 Jun 2026 11:53:25 GMT</pubDate>
            <atom:updated>2026-06-30T11:53:25.184Z</atom:updated>
            <content:encoded><![CDATA[<p><em>AI didn’t break programming. It just added another leaky layer.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bnrrUbG4rf9tJ4AWAiMnfw.jpeg" /></figure><p>When people say AI is rewriting the rules of software, Linus Torvalds reaches for a longer memory. At his <a href="https://thenewstack.io/torvalds-ai-programming-productivity/">Open Source Summit North America keynote</a> in Minneapolis in May 2026, he made a point that should deflate a lot of the hype: when someone brags that “99% of our code is written by AI,” the same person could just as accurately say that a compiler writes 100% of their code, they just never think to say it, because the compiler stopped being remarkable decades ago.</p><p>That reframing is the whole argument. AI-assisted coding is not a rupture. It is the next abstraction layer above the machine, and we have already lived through bigger ones. Torvalds put the magnitudes bluntly: if AI gives you something like a 10x productivity bump, the compiler gave us roughly 1000x. The New Stack’s keynote coverage attributes the 10x and the 1000x directly to Torvalds, though the 1000x reads as a back-of-the-envelope estimate rather than a measured one. The point survives either way. The most consequential abstraction in the history of programming already happened, quietly, and we stopped noticing.</p><h3>The ladder we already climbed</h3><p>Every generation of programmers has handed the layer below it to a machine and moved up.</p><p>We wrote raw machine code, then let assemblers turn mnemonics into opcodes. We wrote assembly, then let compilers turn C into instructions we would never inspect by hand. We wrote C, then moved to languages that manage memory, dispatch, and types for us. At each step, the layer underneath did not disappear; it became someone else’s problem, or rather the tool’s problem. You stopped reading it because you no longer needed to.</p><p>Here is a detail that makes the parallel more concrete. As a developer, when I wrote C code, I rarely opened the binary to “read” it. To determine whether my program was correct, I did not disassemble the output or trace the registers. I wrote tests. The compiled artifact sat one layer below me, and I validated it from above, by behavior, not by inspection.</p><p>AI-assisted coding puts the generated source in much the same position, though not <em>exactly</em> the same, because, unlike object code, it lands in your repo as source you then have to maintain. The language you now choose (Python, TypeScript, Go, Rust, etc.) sits roughly where machine code used to sit relative to you: it is the layer just below the one you actually work in. You describe intent, the layer below materializes code. And the move is broadly the same as the one I made with the C compiler’s output: you validate it with tests rather than hand-verifying every line as your primary check. The difference is that here you still read enough of it to understand and own the result, and you look beneath it when the behavior demands.</p><h3>Choosing a harness is now as consequential as choosing a language</h3><p>There’s a second parallel worth drawing out. In the old world, one of the first real decisions on a project was which language to use. You picked the language that fit the problem: a systems language for a kernel, a glue language for a script, something with a strong type system where correctness mattered most. The choice shaped everything downstream.</p><p>That decision hasn’t vanished, and it hasn’t simply moved up a layer either. It has gained a new upstream peer. Today, an equally consequential early decision is which harness you work in, which agent, which toolchain, which loop of generate-test-refine you commit to. You still pick the language that fits the problem; you now also pick the harness around it. The judgment is the same: there is just one more object of choice. The skill of matching the tool to the problem was never about the language itself. It was about understanding the problem well enough to know what it demanded.</p><h3>The objection that actually matters</h3><p>A careful reader is already objecting, and the objection is good enough that any honest version of this argument has to meet it head-on: a compiler is not an LLM.</p><p>A compiler is deterministic and faithful. The same source produces the same machine code, and the translation preserves meaning. You can trust it precisely because of that. An LLM is neither. Run the same prompt twice, and you get different code; nothing guarantees that the output implements what you meant. If the defining property of an abstraction is that you can stop looking at the layer below, then AI is a strange abstraction: one that, today, demands you keep looking.</p><p>This is real, and pretending otherwise would be dishonest. But it doesn’t break the thesis. It sharpens it.</p><p>Software was never reliable because compilation was deterministic. Determinism gave us reproducibility, not correctness by itself; a compiler will faithfully translate a wrong program into a wrong binary every single time. Reliability came from elsewhere: from type systems, from static analysis, from tests, from formal methods, from code review, and from the whole apparatus of verification we built on top of it. The trustworthiness of the compiler itself was established once, globally, by a community; you don’t re-test GCC on every build.</p><p>So the honest version of the claim is: AI is a <a href="https://www.joelonsoftware.com/2002/11/11/the-law-of-leaky-abstractions/"><em>leaky abstraction</em></a>, in the sense Joel Spolsky gave the term in 2002, where the details of the layer below inevitably bleed through, and you can’t fully ignore them. Every abstraction leaks. The C compiler leaked when performance mattered, and you dropped down to inline assembly in your code. But the gap with AI is partly a matter of degree and partly a matter of kind. Of <em>degree</em>: it leaks far more, and more often, so the verification work moves to the foreground. Of <em>kind</em>: a compiler performs a deterministic, semantics-preserving transformation of your program, while an LLM performs a probabilistic reconstruction that approximates meaning but offers no such guarantee. It can silently introduce behavior you never specified. This is the difference that matters and why the claim that ‘AI is basically a compiler’ is not merely imprecise but misses what is genuinely new about large language models.</p><p>That is the real shift, and it’s worth saying plainly rather than dressing it up as “nothing changed.” What changes is not the existence of the abstraction but where your attention goes. The programmer’s job migrates toward the verification infrastructure: tests, types, the harness, and review. Because that is now the layer where trust is actually manufactured. The generation got cheap. The judgment about whether the generated thing is correct has become more valuable.</p><h3>What stays the same</h3><p>This is why the panic and the triumphalism both miss. The tools changed profoundly. What they sit on top of did not.</p><p>You still have to understand the problem before you can describe it. You still have to make choices (which language, which framework, which harness, which tradeoffs), and those choices still have consequences you own. You still have to know what “correct” means well enough to test for it, because the layer below will confidently hand you something plausible and wrong. A compiler will faithfully build the bug <em>you</em> wrote; the model can hand you a bug you never specified or asked for. Either way, the responsibility lands in the same place: you, but the model gives you a wider class of failures to catch.</p><p>Assemblers, compilers, and managed runtimes raised the level of abstraction without removing the hard parts of the work: defining intent, exercising judgment under ambiguity, and taking responsibility for correctness. AI does the same. It raises the level again, but it does not change what the difficult work is.</p><p>The tools get better. The nature of the work does not.</p><h3>Sources</h3><ul><li><a href="https://thenewstack.io/torvalds-ai-programming-productivity/">Why Linux creator Linus Torvalds gets angry hearing “99% of code is AI” — The New Stack (May 29, 2026)</a></li><li><a href="https://www.clocate.com/open-source-summit-north-america/3133/">Open Source Summit North America, 18–20 May 2026 (Minneapolis) — Clocate</a></li><li><a href="https://events.linuxfoundation.org/2026/03/26/open-source-summit-north-america-2026-schedule-showcases-next-era-of-ai-infrastructure-security-and-open-ecosystems/">Open Source Summit North America 2026 schedule — Linux Foundation Events</a></li><li><a href="https://digg.com/tech/1zl8xoem">Linus Torvalds compares generative AI to compilers — Digg</a></li><li><a href="https://www.theregister.com/2025/11/18/linus_torvalds_vibe_coding/">Linus Torvalds: Vibe coding is fine, but not for production — The Register (2025, background)</a></li><li><a href="https://www.jamesluterek.com/blog/ai-next-abstraction-layer/">From Assembly to AI: Programming Abstractions — James Luterek</a></li><li><a href="https://medium.com/@paul.bernard_80815/your-code-was-never-deterministic-992eebf1ded9">Your Code Was Never Deterministic — Paul Bernard (Medium)</a></li><li><a href="https://tomassetti.me/ai-coding-feels-like-using-an-unreliable-compiler/">AI Coding Feels Like Using an Unreliable Compiler — Strumenta</a></li><li><a href="https://arxiv.org/html/2604.05150v1">Compiled AI: Deterministic Code Generation for LLM-Based Workflow Automation — arXiv</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07f681cb23a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Evolution of Web3 Identity: From Wallet Signatures to Agent Accountability]]></title>
            <link>https://medium.com/@antonio.quental/the-evolution-of-web3-identity-from-wallet-signatures-to-agent-accountability-6175a8d14bd1?source=rss-55ed729bf0b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/6175a8d14bd1</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai-governance]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[decentralized-identity]]></category>
            <category><![CDATA[verifiable-credentials]]></category>
            <dc:creator><![CDATA[Antonio Quental]]></dc:creator>
            <pubDate>Fri, 03 Apr 2026 03:01:58 GMT</pubDate>
            <atom:updated>2026-04-03T03:01:58.301Z</atom:updated>
            <content:encoded><![CDATA[<p>Web3 identity has evolved from simple wallet-based login to more structured systems that use decentralized identifiers, verifiable credentials, and agent-specific trust layers. The core direction is clear: identity is moving from &quot;who controls this wallet?&quot; to &quot;who is this actor, what are they allowed to do, and how can we verify and monitor that in real time?”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9fzjKDsf8laEoWu01Y2Nfg.jpeg" /></figure><p>If you could prove who you are with nothing but a cryptographic signature, would that be enough?</p><p>For years, that was the answer Web3 gave. A wallet, a private key, a signed message, and you were in. No passwords, no middlemen, no centralized gatekeepers. It was elegant. It was liberating. And it was nowhere near sufficient.</p><p>Web3 identity has undergone a quiet yet dramatic transformation. What started as a simple proof of wallet control has grown into a layered system of decentralized identifiers, verifiable credentials, reputation signals, and, most recently, identity frameworks for AI agents that act on your behalf.</p><p>This shift matters because identity is no longer just about access. It is about authorization, accountability, and risk. In a system where code can move capital instantly and irreversibly, knowing <em>who</em> is acting, and under what constraints, is no longer optional.</p><p>Here is how that happened, step by step.</p><h3>1. The Wallet Was the Identity</h3><p>The first Web3 identity model was brutally simple: your wallet <em>was</em> you. If you could sign a transaction with a private key, you had access. Tools like MetaMask and Coinbase Wallet turned this into a login mechanism for decentralized applications, and it worked.</p><p>It worked because it matched the ethos. No accounts. No passwords. No platform lock-in. Just cryptographic proof that you control an address.</p><p>But simplicity came with blind spots. A wallet could prove <em>control</em>, but it couldn&#39;t say anything about <em>who</em> was behind it, what they were allowed to do, or whether they should be trusted.</p><h3>2. Signing In With Wallets</h3><p>As dApps matured, wallet login became more structured. Protocols like Sign-In with Ethereum formalized the flow: the app sends a challenge, the user signs it, and the signature serves as proof of identity. It felt familiar, close enough to traditional login for mainstream users to follow along.</p><p>This model is still widely used today, and for good reason. It is lightweight, easy to implement, and removes password friction entirely. But it inherited the same fundamental gap: it authenticates an address, not a person, a role, or a set of permissions.</p><h3>3. The Rise of DIDs (Decentralized Identifiers)</h3><p>The next leap came with DIDs: persistent, cryptographically verifiable identifiers that exist independently of any single wallet, app, or platform.</p><p>Why does this matter? Because identity should not be confined to a single ecosystem. A DID can follow you across chains, across applications, across years. It separates <em>who you are</em> from <em>the tools you happen to use</em>. For individuals, organizations, and AI agents, this portability became essential.</p><h3>4. Credentials as Claims</h3><p>If DIDs are the &quot;who,&quot; Verifiable Credentials (VCs) are the &quot;what about them.&quot; A VC is a cryptographically signed claim: <em>this person passed KYC</em>, <em>this wallet belongs to this company</em>, <em>this organization authorized this agent</em>.</p><p>The key insight behind VCs is composability. Instead of handing over your entire identity to prove one thing, you can present a single, targeted proof. Need to show you are over 18 without revealing your birthdate? A VC can do that. Need to prove your company approved an AI agent without exposing your internal org chart? Same mechanism.</p><p>This is where Web3 identity became genuinely privacy-preserving: not by hiding information, but by making disclosure selective.</p><h3>5. The Emergence of Identity Wallets</h3><p>DIDs and VCs needed a home, and identity wallets became that home. These are not the same as your crypto wallet. They are purpose-built containers for credentials, proofs, and identifiers. They support selective disclosure, manage multiple DIDs for different contexts, and let you present verifiable claims across applications.</p><p>Think of it this way: your crypto wallet holds assets; your identity wallet holds <em>who you are and what you can prove about yourself</em>. Some implementations let you maintain separate identities: one for work, one for gaming, one for DeFi, reducing the risk of cross-context tracking.</p><p><strong>A common confusion: <em>Crypto wallet </em>vs. <em>identity wallet</em></strong></p><p>These two terms sound similar, but they solve different problems.</p><p>A crypto wallet stores private keys and lets you sign transactions. It is how you hold, send, and receive assets on a blockchain. When you connect MetaMask to a dApp, you are using a crypto wallet. Its job is to manage value.</p><p>An identity wallet stores credentials, DIDs, and verifiable proofs. It is how you hold, present, and control claims about yourself. When you prove to a protocol that you passed KYC without revealing your personal data, you are using an identity wallet. Its job is to manage trust.</p><p>The overlap is real: both use cryptographic keys, both can authenticate you, and some products are starting to blend the two. But the core distinction matters. A crypto wallet answers &quot;what do you own?&quot; An identity wallet answers &quot;what can you prove about who you are?&quot;</p><h3>6. Reputation and Attestations</h3><p>Basic authentication is binary: you either control the key, or you don&#39;t. Trust is not. That is why the next layer introduced attestations and on-chain reputation.</p><p>An attestation might say that a wallet has participated in governance votes, completed a security audit, contributed to a protocol, or been vouched for by a known entity. This doesn&#39;t replace DIDs or VCs. It fills a gap they cannot: context.</p><p>Many Web3 systems need more than a pass/fail check at the door. They need to understand whether the entity on the other side has history, credibility, and skin in the game.</p><h3>7. Proof of Personhood</h3><p>Then came automation, and with it, bots and AI agents.</p><p>As AI agents became more capable, the question shifted from &quot;is this wallet authorized?&quot; to &quot;is there a human behind this at all?&quot; Systems like World ID introduced proof-of-personhood: mechanisms that let a person prove they are human, unique, and, in some cases, delegate verified humanity to an agent acting on their behalf.</p><p>In governance, airdrops, and community decisions, this distinction is no longer theoretical. A wallet cannot tell you whether the actor is one person, a bot, or a thousand coordinated accounts. Proof-of-personhood gives Web3 a way to answer that question without falling back on centralized ID systems.</p><h3>8. The Rise of Agent Identity</h3><p>This is the frontier.</p><p>AI agents are no longer hypothetical participants in Web3. They trade, they vote, they manage wallets, they execute strategies. And the identity stack was not built for them.</p><p>Agent identity is about binding a nonhuman actor to a principal, a person or organization, and defining what it is allowed to do. The framing is shifting from &quot;Know Your Customer&quot; to &quot;Know Your Agent.&quot; An agent may carry its own DID, hold its own credentials, and authenticate independently. But it still needs to be tied to someone accountable, with clear scope limits and revocation rules.</p><p>This is where DIDs, VCs, and delegated authority converge into something new.</p><h3>9. From Identity to Continuous Monitoring</h3><p>The latest evolution says that identity alone is not enough, not for agents, and arguably not for anyone operating in a system where a single approved transaction can irreversibly move assets.</p><p>The emerging model goes beyond authentication: <em>authenticate, authorize, constrain, and observe</em>. That means tracking execution in real time, logging high-risk actions, verifying that an agent stayed within its permitted scope, and flagging anomalies before damage is done.</p><p>Identity is no longer a gate you pass through once. It is becoming a continuous control layer.</p><h3>How the Layers Compare</h3><p>Each layer in the Web3 identity stack was built to address a gap left by the previous layer. The table below summarizes what each solution does, where it helps, and where it falls short. No single layer is sufficient on its own, the value is in how they compose.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2FfIFgc%2F1%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2FfIFgc%2F1%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2FfIFgc%2Fplain-s.png%3Fv%3D1&amp;type=text%2Fhtml&amp;schema=dwcdn" width="600" height="977" frameborder="0" scrolling="no"><a href="https://medium.com/media/2160cec7121428edeefa856a9d4c0e82/href">https://medium.com/media/2160cec7121428edeefa856a9d4c0e82/href</a></iframe><h3>Where This Is Going</h3><p>The trajectory is clear when you step back and look at the full arc:</p><ul><li><strong>Wallets</strong> proved control.</li><li><strong>DIDs</strong> made identity portable.</li><li><strong>VCs</strong> made claims portable.</li><li><strong>Identity wallets</strong> made them usable.</li><li><strong>Attestations</strong> added context and trust.</li><li><strong>Proof-of-personhood</strong> drew the line between humans and machines.</li><li><strong>Agent identity</strong> extended the system to nonhuman actors.</li><li><strong>Monitoring</strong> turned identity from a checkpoint into a control loop.</li></ul><p>Each layer exists because the previous one was not enough. And if the pattern holds, the next layer will address something we have not yet fully confronted: cross-chain agent identity, real-time credential revocation, or liability frameworks for autonomous systems acting across jurisdictions.</p><p>Imagine an AI trading agent operating on behalf of a DAO treasury. It needs to prove not just that it controls a wallet, but that it has been authorized to execute trades within defined limits, by a specific governance process, and that its actions can be audited in real time.</p><p>Web3 identity started with a private key. It is becoming a full trust architecture. And we are still early.</p><p>The open question is no longer just identity, but responsibility.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6175a8d14bd1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Authentication Evolved: Lessons for an Agentic Future]]></title>
            <link>https://medium.com/@antonio.quental/how-authentication-evolved-lessons-for-an-agentic-future-8f912705568a?source=rss-55ed729bf0b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f912705568a</guid>
            <category><![CDATA[sso]]></category>
            <category><![CDATA[openid-connect]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[oauth2]]></category>
            <dc:creator><![CDATA[Antonio Quental]]></dc:creator>
            <pubDate>Sat, 28 Mar 2026 16:48:00 GMT</pubDate>
            <atom:updated>2026-03-29T12:41:22.189Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="agentic authentication" src="https://cdn-images-1.medium.com/max/1024/1*ZCsg8eU8nbtuaQjZ6GFEog.jpeg" /></figure><h3>A Developer&#39;s Journey Through 9 Authentication Methods</h3><p>If you&#39;ve ever stared at an authentication spec wondering whether you need OAuth, JWTs, or &quot;just an API key,&quot; you&#39;re not alone. Authentication is one of those topics that seems simple until you actually have to implement it.</p><p>The truth is: there&#39;s no single &quot;best&quot; method. Each approach evolved to solve specific problems, and understanding <em>why</em> they exist helps you choose the right one for your system.</p><p>But here&#39;s what&#39;s been on my mind lately: all of these methods were designed for <em>humans</em>. What happens when the actor isn&#39;t a person, but an autonomous AI agent?</p><p>Let&#39;s walk through the evolution of API authentication, from the simplest (and most vulnerable) methods to the modern standards powering today&#39;s apps. Along the way, we&#39;ll build the foundation for a harder question: how do we authenticate agents in a world where they act on our behalf?</p><h3>1. Basic Authentication: The Simplest Method</h3><p><strong>How it works:</strong> Your username and password are concatenated, Base64-encoded, and sent with every request in the Authorization header.</p><pre>Username: gandalf<br>Password: YouShallNotPass!<br>Combined String: gandalf:YouShallNotPass!<br>Base64 Encoded String: Z2FuZGFsZjpZb3VTaGFsbE5vdFBhc3Mh<br>Header:<br><br>Authorization: Basic Z2FuZGFsZjpZb3VTaGFsbE5vdFBhc3Mh</pre><p><strong>The good:</strong> Dead simple to implement. No tokens, no sessions, no state.</p><p><strong>The bad:</strong> Your password travels (😮) with <em>every single request</em>. Base64 isn&#39;t encryption, it&#39;s just encoding. Anyone intercepting traffic sees your credentials in plain text.</p><p><strong>Use it when:</strong> You&#39;re building internal tools behind a firewall, and HTTPS is mandatory. Otherwise, don&#39;t.</p><p><strong>Security:</strong> 🔴 Low (without HTTPS, it&#39;s basically <em>no security</em>)</p><p><strong>Reference:</strong> <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Authorization">Authorization header (MDN)</a></p><h3>2. Digest Authentication: A Step Up</h3><p><strong>How it works:</strong> Instead of sending your password directly, the server sends a &quot;challenge&quot; (a nonce). Your client hashes the password with this challenge and sends the hash back. The password never travels over the wire.</p><p><strong>The good:</strong> More secure than Basic: no plain-text passwords in transit.</p><p><strong>The bad:</strong> Rarely supported by modern frameworks and largely abandoned by the industry.</p><p><strong>Use it when:</strong> You&#39;re maintaining legacy enterprise systems that already use it. Otherwise, skip it: token-based authentication is easier to scale.</p><p><strong>Security:</strong> 🟡 Medium</p><h3>3. Session Authentication: The Web&#39;s Workhorse</h3><p><strong>How it works:</strong> User logs in once. The server creates a session, stores it (usually in a database or memory), and sends back a session ID as a cookie. The browser automatically includes this cookie in subsequent requests.</p><p><strong>The good:</strong> Works seamlessly with traditional server-rendered apps. Easy session management, deleting the session revokes access instantly.</p><p><strong>The bad:</strong> <em>Stateful</em>, your server must remember every active session. This becomes a nightmare when you scale to multiple servers (sticky sessions, shared session stores, etc.).</p><p><strong>Use it when:</strong> Building monolithic web apps with server-side rendering. Think traditional web apps with cookies.</p><p><strong>Security:</strong> 🟢 Medium-High (with secure, HTTP-only cookies)</p><h3>4. API Keys: Simple Machine-to-Machine Auth</h3><p><strong>How it works:</strong> You generate a unique secret key for an application (not a user). The key is sent in the header or as a query parameter with each request.</p><pre>curl -X GET &quot;https://qkapi.example.com/data&quot; \<br>     -H &quot;X-API-Key: qk_api_abcd1234WXYZ&quot; \<br>     -H &quot;Content-Type: application/json&quot;</pre><p><strong>The good:</strong> Perfect for service-to-service communication. No user context needed. Easy to rotate and manage.</p><p><strong>The bad:</strong> Keys identify <em>applications</em>, not users. If someone leaks your key (e.g., your public GitHub repo), they have full access until you revoke it.</p><p><strong>Use it when:</strong> Building public APIs for third-party integrations, server-to-server communication, or client-side rate limiting.</p><p><strong>Security:</strong> 🟡 Medium (depends entirely on how well you protect the key)</p><h3>5. Bearer Tokens: The Stateless Revolution</h3><p><strong>How it works:</strong> After authentication, the server issues an opaque token. The client sends this token in the Authorization header for all requests. Bearer means: whoever holds the token is allowed to use it.</p><pre>curl -X GET &quot;https://qkapi.example.com&quot; \<br>     -H &quot;Authorization: Bearer eyJhxGcioiJiUzI1NiIs...&quot;</pre><p><strong>The good:</strong> Stateless. The server doesn&#39;t need to store sessions, it just needs to validate the token. This is important for microservices and horizontal scaling.</p><p><strong>The bad:</strong> If someone steals your token, they <em>are</em> you. No built-in expiration or claims mechanism (that&#39;s where JWTs come in).</p><p><strong>Use it when:</strong> Building APIs for mobile apps, SPAs, or microservices where statelessness matters.</p><p><strong>Security:</strong> 🟢 Medium</p><h3>6. JSON Web Tokens (JWT): Self-Contained Identity</h3><p><strong>How it works:</strong> A JWT is a signed, self-contained token with three parts: the <em>header</em>, the <em>payload</em> (claims), and the <em>signature</em>. The payload can include a user ID, roles, and an expiration time.</p><pre>header:<br>{<br>    &quot;alg&quot;: &quot;HS256&quot;,<br>    &quot;typ&quot;: &quot;JWT&quot;<br>} -&gt; eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9<br>payload:<br>{<br>    &quot;userId&quot;: 123,<br>    &quot;role&quot;: &quot;admin&quot;,<br>    &quot;exp&quot;: 1672531199<br>} -&gt; eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNzA4MzQ1MTIzLCJleHAiOjE3MDgzNTUxMjN9<br>signature:<br>HMACSHA256(<br>    base64UrlEncode(header) + &quot;.&quot; + base64UrlEncode(payload), &lt;secret key&gt;<br>) -&gt; SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c<br><br>Header.Payload.Signature<br>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.<br>eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNzA4MzQ1MTIzLCJleHAiOjE3MDgzNTUxMjN9.<br>SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c</pre><p><strong>The good:</strong> Verification without a database lookup. Any service with the secret/public key can validate the token. Perfect for distributed systems.</p><p><strong>The bad:</strong> Can&#39;t revoke a JWT once issued (unless you implement a blocklist, which neutralizes the &quot;stateless&quot; benefit). Tokens can get large. If your secret key leaks, every token is compromised.</p><p><strong>Use it when:</strong> Building distributed systems, SPAs, mobile apps, or anywhere you need stateless, scalable authentication. Use two tokens: access tokens (short-lived, usually hours) and refresh tokens (long-lived, used to request new access tokens).</p><p><strong>Security:</strong> 🟢 High (when short-lived, properly signed, or using long-lived tokens to request short-lived access tokens)</p><p><strong>Reference:</strong> <a href="https://www.geeksforgeeks.org/web-tech/json-web-token-jwt/">GeeksForGeeks JWT</a></p><h3>7. OAuth 2.0: Delegated Authorization</h3><p><strong>How it works:</strong> OAuth 2.0 is an <em>authorization</em> framework (not authentication). It lets users grant third-party apps limited access to their resources <em>without sharing their password</em>.</p><p>You&#39;ve used this: &quot;Sign in with Google/Apple/X/Facebook(providers)&quot; → Provider asks if you want to grant the app access → The app gets a token to access your Provider data.</p><p><strong>The good:</strong> Users never share passwords with third-party apps. Fine-grained scopes (e.g., &quot;read-only access to your photos&quot;). Industry standard with multiple grant types for different scenarios.</p><p><strong>The bad:</strong> Complex to implement correctly. OAuth is about <em>authorization</em> (what you can access), not <em>authentication</em> (who you are).</p><p><strong>Use it when:</strong> Building apps that need to access user data from other services, or providing third-party access to your own API.</p><p><strong>Security:</strong> 🟢 High</p><h3>8. OpenID Connect (OIDC): Identity on Top of OAuth</h3><p><strong>How it works:</strong> OIDC is an identity layer built on OAuth 2.0. It adds a JWT that contains information about the authenticated user.</p><p>OAuth answers: &quot;Is this app allowed to access this resource?&quot; OIDC answers: &quot;Who is this user?&quot;</p><p><strong>The good:</strong> Standardized user identity. Works with major identity providers (Google, Microsoft, Okta). Combines authorization <em>and</em> authentication cleanly.</p><p><strong>The bad:</strong> Requires understanding OAuth 2.0 first. More moving parts to secure.</p><p><strong>Use it when:</strong> You need to know <em>who</em> the user is, not just grant access. Think &quot;Login with Google/Apple/X/Facebook&quot; that actually returns user profile info.</p><p><strong>Security:</strong> 🟢🟢 Very High</p><h3>9. Single Sign-On (SSO): One Login to Rule Them All</h3><p><strong>How it works:</strong> User logs in once to a central Identity Provider (IdP), then accesses multiple apps without re-authenticating. Built on OIDC or SAML under the hood.</p><p><strong>The good:</strong> Amazing user experience. Centralized identity management. Easier onboarding/offboarding in enterprises.</p><p><strong>The bad:</strong> Single point of failure — if the IdP is compromised, all connected apps are at risk. Requires proper IdP configuration and security.</p><p><strong>Use it when:</strong> Building enterprise applications or SaaS platforms where users need access to multiple apps.</p><p><strong>Security:</strong> 🟢🟢 Very High (with a properly secured IdP)</p><h3>So, Which One Should You Use?</h3><p>I&#39;ve seen teams overcomplicate this. Here&#39;s a quick gut-check:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2F87ZzK%2F1%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2F87ZzK%2F1%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2F87ZzK%2Fplain-s.png%3Fv%3D1&amp;type=text%2Fhtml&amp;schema=dwcdn" width="600" height="315" frameborder="0" scrolling="no"><a href="https://medium.com/media/75f594f7a2e79310d8ec9df84e7c10bb/href">https://medium.com/media/75f594f7a2e79310d8ec9df84e7c10bb/href</a></iframe><p>🎯 = Keep it simple — don&#39;t overthink it</p><p>🔐 = Time to bring out the big guns</p><p>The rule of thumb: use the <em>least complex</em> method that solves your problem. Complexity isn&#39;t security, it&#39;s surface area.</p><h3>Comparison Table</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fdatawrapper.dwcdn.net%2FI23YW%2F3%2F&amp;display_name=Datawrapper&amp;url=https%3A%2F%2Fdatawrapper.dwcdn.net%2FI23YW%2F3%2F&amp;image=https%3A%2F%2Fdatawrapper.dwcdn.net%2FI23YW%2Fplain-s.png%3Fv%3D3&amp;type=text%2Fhtml&amp;schema=dwcdn" width="600" height="574" frameborder="0" scrolling="no"><a href="https://medium.com/media/a92cd8ba39c33eef4a954553fc9aad3f/href">https://medium.com/media/a92cd8ba39c33eef4a954553fc9aad3f/href</a></iframe><h3>Final Thoughts</h3><p>Authentication isn&#39;t a &quot;set it and forget it&quot; decision. As your system evolves from a monolith to a distributed system, from an internal tool to a public API, from user-centric to agentic, your auth strategy should evolve too. Systems are organic.</p><p>The key is understanding the trade-offs:</p><ul><li><strong>Simplicity vs. Security</strong> (Basic Auth vs. OAuth)</li><li><strong>Stateful vs. Stateless</strong> (Sessions vs. JWT)</li><li><strong>Authorization vs. Authentication</strong> (OAuth vs. OIDC)</li></ul><p>Pick the method that matches your current needs, but design your system to evolve. You&#39;ll probably need to upgrade later.</p><p>But here&#39;s what keeps me up at night: every method I&#39;ve covered assumes a <em>human</em> is being authenticated. What happens when the actor is an autonomous AI agent operating in a permissionless Web3 environment?</p><p>No central authority. No passwords. No human in the loop. Just an agent acting on your behalf, and somehow, you need to trust it <em>and</em> control it.</p><p>This is the problem I&#39;ve been researching. And in my next post, I&#39;ll propose a framework for <strong>agent authentication in Web3</strong> that combines decentralized identity, verifiable credentials, and delegated authority.</p><p>Follow along if you&#39;re curious. And drop your thoughts in the comments — I&#39;d love to hear how you&#39;re thinking about this.</p><p><em>This post is part of a study on how to authenticate agents in a permissionless context. Keep tuned in for more.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f912705568a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DeFi’s Weak Links: Top 10 Solidity Vulnerabilities and How to Stop Them]]></title>
            <link>https://medium.com/@antonio.quental/defis-weak-links-top-10-solidity-vulnerabilities-and-how-to-stop-them-62deea1d1d20?source=rss-55ed729bf0b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/62deea1d1d20</guid>
            <category><![CDATA[solidity-development]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ethereum-blockchain]]></category>
            <category><![CDATA[defi]]></category>
            <category><![CDATA[auditing]]></category>
            <dc:creator><![CDATA[Antonio Quental]]></dc:creator>
            <pubDate>Fri, 18 Apr 2025 19:57:14 GMT</pubDate>
            <atom:updated>2025-04-18T20:44:00.439Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0T8vVbmxjbYWmbztE1hb3Q.jpeg" /></figure><h3>The Power and Perils of Solidity</h3><p>Solidity is a high-level programming language designed for writing smart contracts on the Ethereum blockchain. It enables developers to create self-executing agreements that automate transactions and enforce rules without intermediaries. By powering Ethereum’s programmable blockchain, Solidity has been instrumental in the rise of Decentralized Finance (DeFi) and other ecosystems, unlocking innovative financial applications like lending platforms, decentralized exchanges, and yield farming protocols. Today, DeFi manages billions in assets, transforming traditional finance. However, Solidity’s complexity and Ethereum’s immutable nature make smart contracts prime targets for exploits. Vulnerabilities can lead to catastrophic losses, as seen in high-profile hacks. Understanding and mitigating these security flaws is critical to ensuring the safety and trustworthiness of DeFi and other Ethereum-based applications.</p><h3>DeFi and Its Transformation of Finance</h3><p>Decentralized Finance (DeFi) is a blockchain-based ecosystem of financial applications built primarily on Ethereum, leveraging smart contracts to automate and decentralize services like lending, Borrowing, trading, and yield farming. Unlike traditional finance, which relies on centralized institutions such as banks and brokers, DeFi operates on a trustless, permissionless network where transactions are performed by code, not intermediaries. This enables permissionless global access, transparency, and lower costs, with DeFi protocols managing billions in assets. For example, platforms like Uniswap facilitate decentralized trading, while Aave offers lending without credit checks. However, DeFi’s reliance on Solidity smart contracts introduces significant security risks, as flaws can lead to devastating exploits. Understanding these vulnerabilities is crucial for securing DeFi’s future.</p><h3>DeFi vs. Traditional Finance</h3><ul><li><strong>Centralization</strong>: Traditional finance depends on centralized entities (banks, regulators) for trust and oversight. At the same time, DeFi uses decentralized blockchain networks and smart contracts.</li><li><strong>Access</strong>: DeFi is open to anyone with an internet connection and a crypto wallet, unlike traditional finance, which often requires identification, credit checks, or geographic proximity.</li><li><strong>Intermediaries</strong>: DeFi eliminates middlemen, reducing fees and delays, whereas traditional finance involves brokers, clearinghouses, and other intermediaries.</li><li><strong>Transparency</strong>: DeFi transactions are recorded on a public blockchain, ensuring auditable transparency, while traditional finance often operates opaquely.</li><li><strong>Security Risks</strong>: DeFi’s smart contracts are immutable and vulnerable to coding errors, risking funds to hacks. Traditional finance faces risks like fraud but benefits from regulatory protections and reversibility.</li></ul><h3>What You Can Do with DeFi</h3><p>DeFi on Ethereum is powered by Solidity Smart Contracts, which are programs that run on the blockchain and handle everything automatically. These contracts enable a wide range of financial activities, including:</p><ul><li><strong>Lending &amp; Borrowing: </strong>platforms like <strong>Aave</strong> and <strong>Compound</strong> let you deposit your crypto to earn interest. You can also borrow other tokens using your crypto as collateral — no need for a credit check or a bank.</li><li><strong>Trading: </strong>decentralized exchanges like <strong>Uniswap</strong> or <strong>SushiSwap</strong> allow you to swap one crypto token for another directly from your wallet — there is no sign-up, approval process, or middleman.</li><li><strong>Stablecoins: DAI</strong> is a popular Ethereum-based stablecoin designed to stay close to 1 USD. It’s created and maintained by smart contracts — not a central bank or traditional institution.</li><li><strong>Yield Farming &amp; Liquidity Pools: </strong>you can earn rewards by providing your crypto to DeFi protocols, which you can use to facilitate trades or loans. Think of it as renting your digital assets — a DeFi protocol, not a financial institution rewards you.</li><li><strong>Staking &amp; Governance: </strong>Some DeFi platforms allow you to stake tokens and participate in governance, voting on decisions that shape the protocol’s future, similar to being a shareholder in a company.</li></ul><h3>Security First: Embracing the Mindset of a Security Auditor</h3><p>Decentralized Finance (DeFi) has revolutionized financial systems, enabling trustless, transparent, and accessible services through Ethereum’s smart contracts. However, the billions of dollars locked in DeFi protocols make them prime targets for attackers exploiting vulnerabilities in Solidity code. High-profile incidents underscore the catastrophic consequences of overlooked flaws. As a Solidity programmer, adopting a security auditor’s mindset is not just a skill; <em>it’s a necessity</em>.</p><p>The last mile in Smart Contract development should involve proactive risk identification, scrutinizing code for weaknesses, and prioritizing secure design over functionality. Professional Solidity developers should cultivate this vigilance to safeguard DeFi’s promise and protect users from devastating losses. The following section explores common Solidity vulnerabilities, equipping you with the knowledge to code with security in mind.</p><h3>Most Common Vulnerabilities in Solidity Smart Contracts</h3><p>The most common vulnerabilities in Solidity smart contracts, based on the Decentralized Application Security Project (DASP) and the OWASP Smart Contract Top 10 (2025) are among the most critical and frequently exploited, as evidenced by significant financial losses in 2024 (e.g., $1.42 billion¹ across 149 incidents, per OWASP). This report outlines the most common vulnerabilities in Solidity smart contracts, based on insights from <a href="https://dasp.co/">DASP</a>, <a href="https://owasp.org/www-project-smart-contract-top-10/">OWASP Smart Contract Top 10 (2025)</a>, and <a href="https://github.com/smartbugs/smartbugs-curated">SmartBugs Curated</a>.</p><h3>1. Access Control Vulnerabilities</h3><p>Access control vulnerabilities occur when a smart contract fails to enforce proper permission checks, allowing unauthorized users to access or modify critical functions or data. This includes missing <em>onlyOwner</em> modifiers or flawed role-based access control (RBAC).</p><h4>Cause</h4><ul><li>Improper implementation of access modifiers (e.g., <em>public</em> instead of <em>private</em> or <em>internal</em>).</li><li>Missing or incorrect validation of <em>msg.sender</em> for sensitive functions.</li><li>Exposed initialization functions that allow attackers to gain administrative privileges.</li></ul><h4>Consequences</h4><ul><li><strong>Financial Loss</strong>: Unauthorized access can lead to fund theft or contract manipulation, with $953.2M in losses in 2024.</li><li><strong>Contract Takeover</strong>: Attackers may gain control of the contract, as seen in the 88mph Function Initialization Bug.</li><li><strong>Loss of Trust</strong>: Breaches erode user confidence in the protocol.</li></ul><h4>Mitigation</h4><ul><li>Use OpenZeppelin’s <em>Ownable</em> or <em>AccessControl</em> for robust access control.</li></ul><pre>import &quot;@openzeppelin/contracts/access/Ownable.sol&quot;;<br>contract Secure is Ownable {<br>    function sensitiveFunction() public onlyOwner {<br>        // Restricted to owner<br>    }<br>}</pre><ul><li>Explicitly check <em>msg.sender</em> for sensitive operations.</li><li>Avoid public initialization functions; use constructors or <em>initializer</em> modifiers.</li><li>Conduct thorough audits to verify access control logic.</li></ul><h3>2. Price Oracle Manipulation</h3><p>Price oracle manipulation occurs when attackers exploit vulnerabilities in external data feeds (Oracles) used by smart contracts, often through flash loans or low-liquidity pools, to distort asset prices.</p><h4>Cause</h4><ul><li>Reliance on single or low-liquidity DEX pools (e.g., Uniswap) for price data.</li><li>Lack of validation or aggregation of oracle data.</li><li>Susceptibility to flash loan attacks that temporarily skew prices.</li></ul><h4>Consequences</h4><ul><li><strong>Financial Loss</strong>: Manipulated prices can lead to excessive loans or drained pools, with $8.8M in losses in 2024.</li><li><strong>Protocol Instability</strong>: Incorrect prices disrupt lending or trading protocols.</li><li><strong>Systemic Risk</strong>: Affects other contracts relying on the same oracle.</li></ul><h4>Mitigation</h4><ul><li>Use trusted oracles like Chainlink for aggregated, secure price feeds.</li></ul><pre>import &quot;@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol&quot;;<br>contract Secure {<br>    AggregatorV3Interface priceFeed;<br>    constructor(address _priceFeed) {<br>        priceFeed = AggregatorV3Interface(_priceFeed);<br>    }<br>    function getPrice() public view returns (uint) {<br>        (, int price, , , ) = priceFeed.latestRoundData();<br>        return uint(price);<br>    }<br>}</pre><ul><li>Implement Time-Weighted Average Price (TWAP) to mitigate short-term manipulations.</li><li>Validate pool liquidity before trusting price data.</li><li>Use circuit breakers to limit actions during extreme price changes.</li></ul><h3>3. Logic Errors</h3><p>Logic errors (or business logic flaws) occur when a contract’s logic does not execute as intended, leading to exploitable behaviors such as incorrect reward distributions or faulty lending protocols.</p><h4>Cause</h4><ul><li>Flawed assumptions in business logic (e.g., incorrect fee calculations).</li><li>Missing edge case handling in complex workflows.</li><li>Inadequate testing of contract behavior under extreme conditions.</li></ul><h4>Consequences</h4><ul><li><strong>Financial Loss</strong>: Exploits led to $63.8M in losses in 2024.</li><li><strong>Incorrect Behavior</strong>: Protocols may mint excessive tokens or miscalculate fees.</li><li><strong>User Harm</strong>: Users may receive unfair rewards or lose funds.</li></ul><h4>Mitigation</h4><ul><li>Write comprehensive unit and integration tests to cover edge cases.</li><li>Use formal verification tools like Certora to prove logic correctness.</li><li>Implement clear documentation and invariants for contract behavior.</li><li>Engage auditors to review business logic for flaws.</li></ul><h3>4. Lack of Input Validation</h3><p>Lack of input validation allows attackers to inject malicious data, causing integer overflows, reentrancy, or unintended function execution due to unverified user inputs.</p><h4>Cause</h4><ul><li>Failure to sanitize or validate user-provided inputs (e.g., amounts, addresses).</li><li>Assumptions that inputs are benign or within safe ranges.</li><li>Missing checks for zero values or invalid addresses.</li></ul><h4>Consequences</h4><ul><li><strong>Exploitation</strong>: Leads to overflows, reentrancy, or state corruption, with $14.6M in losses in 2024.</li><li><strong>Contract Malfunction</strong>: Invalid inputs disrupt intended functionality.</li><li><strong>Security Breaches</strong>: Attackers exploit unchecked inputs to bypass restrictions.</li></ul><h4>Mitigation</h4><ul><li>Validate all inputs rigorously.</li></ul><pre>function transfer(address to, uint amount) public {<br>    require(to != address(0), &quot;Invalid address&quot;);<br>    require(amount &gt; 0 &amp;&amp; amount &lt;= balances[msg.sender], &quot;Invalid amount&quot;);<br>    balances[msg.sender] -= amount;<br>    balances[to] += amount;<br>}</pre><ul><li>Use <em>SafeMath</em> or Solidity ≥ 0.8.0 for arithmetic safety.</li><li>Implement address validation libraries (e.g., OpenZeppelin’s Address).</li><li>Use static analysis tools like Slither to detect missing validations.</li></ul><h3>5. Reentrancy Attacks</h3><p>Reentrancy attacks occur when a contract calls an external contract before updating its state, allowing the external contract to recursively call back and exploit unupdated state.</p><h4>Cause</h4><ul><li>External calls (e.g., call, transfer) before state updates.</li><li>Lack of reentrancy protection mechanisms.</li><li>Improper use of the Checks-Effects-Interactions pattern.</li></ul><h4>Consequences</h4><ul><li><strong>Financial Loss</strong>: Drained funds, as in the 2016 DAO hack ($70M) and $35.7M in 2024 losses.</li><li><strong>Broken Logic</strong>: Repeated state changes disrupt contract integrity.</li><li><strong>Protocol Downtime</strong>: Contracts may need to be paused or redeployed.</li></ul><h4>Mitigation</h4><ul><li>Follow the Checks-Effects-Interactions pattern.</li></ul><pre>function withdraw() public {<br>    uint amount = balances[msg.sender];<br>    require(amount &gt; 0, &quot;No balance&quot;);<br>    balances[msg.sender] = 0; // Update state first<br>    (bool sent, ) = msg.sender.call{value: amount}(&quot;&quot;);<br>    require(sent, &quot;Transfer failed&quot;);<br>}</pre><ul><li>Use OpenZeppelin’s <em>ReentrancyGuard</em>.</li></ul><pre>import &quot;@openzeppelin/contracts/security/ReentrancyGuard.sol&quot;;<br>contract Secure is ReentrancyGuard {<br>    function withdraw() public nonReentrant {<br>        uint amount = balances[msg.sender];<br>        require(amount &gt; 0, &quot;No balance&quot;);<br>        balances[msg.sender] = 0;<br>        (bool sent, ) = msg.sender.call{value: amount}(&quot;&quot;);<br>        require(sent, &quot;Transfer failed&quot;);<br>    }<br>}</pre><ul><li>Minimize external calls and validate their outcomes.</li><li>Use tools like Slither to detect reentrancy risks.</li></ul><h3>6. Unchecked External Calls</h3><p>Unchecked external calls occur when a contract fails to verify the success of low-level calls (call, delegatecall, send), leading to incorrect assumptions about transaction outcomes.</p><h4>Cause</h4><ul><li>Not checking the boolean return value of call or send.</li><li>Assuming external calls always succeed.</li><li>Improper handling of external contract failures.</li></ul><h4>Consequences</h4><ul><li><strong>Inconsistent State</strong>: Contracts proceed with incorrect assumptions, risking integrity.</li><li><strong>Exploitation</strong>: Attackers exploit failed calls to manipulate contract logic.</li><li><strong>Financial Loss</strong>: Incorrect fund transfers or state changes lead to losses.</li></ul><h4>Mitigation</h4><ul><li>Always check return values of low-level calls.</li></ul><pre>function transfer(address to, uint amount) public {<br>    (bool success, ) = to.call{value: amount}(&quot;&quot;);<br>    require(success, &quot;Transfer failed&quot;);<br>}</pre><ul><li>Use OpenZeppelin’s <em>Address</em> library for safe calls.</li><li>Prefer high-level <em>transfer</em> for Ether sends when reentrancy is not a concern.</li><li>Test external call failure scenarios.</li></ul><h3>7. Flash Loan Attacks</h3><p>Flash loan attacks exploit the ability to borrow large amounts of funds without collateral in a single transaction, often used to manipulate markets, prices, or governance mechanisms.</p><h4>Cause</h4><ul><li>Protocols allowing large, uncollateralized loans in a single transaction.</li><li>Poorly designed economic incentives vulnerable to manipulation.</li><li>Lack of checks for transaction atomicity or price stability.</li></ul><h4>Consequences</h4><ul><li><strong>Financial Loss</strong>: Drained liquidity pools, with $33.8M in losses in 2024.</li><li><strong>Market Manipulation</strong>: Distorted prices or governance outcomes.</li><li><strong>Protocol Disruption</strong>: Temporary or permanent loss of funds.</li></ul><h4>Mitigation</h4><ul><li>Implement slippage protection and price impact limits.</li></ul><pre>function swap(uint amount) public {<br>    uint expectedOutput = getExpectedOutput(amount);<br>    uint actualOutput = performSwap(amount);<br>    require(actualOutput &gt;= expectedOutput * 95 / 100, &quot;Excessive slippage&quot;);<br>}</pre><ul><li>Use TWAP or Chainlink oracles to prevent price manipulation.</li><li>Restrict flash loan usage or add delays for critical actions.</li><li>Audit economic models for flash loan vulnerabilities.</li></ul><h3>8. Integer Overflow and Underflow</h3><p>Integer overflow/underflow occurs when arithmetic operations exceed the limits of fixed-size integers, causing unexpected wrapping behavior. This is mitigated by default in Solidity ≥ 0.8.0.</p><h4>Cause</h4><ul><li>Using Solidity &lt; 0.8.0 without SafeMath or manual checks.</li><li>Unvalidated user inputs in arithmetic operations.</li><li>Incorrect assumptions about integer ranges.</li></ul><h4>Consequences</h4><ul><li><strong>Token Theft</strong>: Manipulated balances, as in the 2018 BeautyChain hack.</li><li><strong>Financial Loss</strong>: Incorrect calculations lead to fund losses.</li><li><strong>Contract Malfunction</strong>: Broken logic due to unexpected values.</li></ul><h4>Mitigation</h4><ul><li>Use Solidity ≥ 0.8.0 for built-in overflow checks.</li></ul><pre>pragma solidity ^0.8.0;<br>function transfer(address to, uint amount) public {<br>    require(balances[msg.sender] &gt;= amount, &quot;Insufficient balance&quot;);<br>    balances[msg.sender] -= amount; // Checked by default<br>    balances[to] += amount;<br>}</pre><ul><li>For older versions, use OpenZeppelin’s <em>SafeMath</em>.</li></ul><pre>import &quot;@openzeppelin/contracts/utils/math/SafeMath.sol&quot;;<br>contract Secure {<br>    using SafeMath for uint256;<br>    function transfer(address to, uint256 amount) public {<br>        balances[msg.sender] = balances[msg.sender].sub(amount);<br>        balances[to] = balances[to].add(amount);<br>    }<br>}</pre><ul><li>Validate inputs to prevent extreme values.</li><li>Use static analysis tools like Mythril.</li></ul><h3>9. Timestamp Dependence</h3><p>Timestamp dependence occurs when a contract relies on block.timestamp for critical logic, which miners can manipulate within a small window, affecting outcomes like auctions or random number generation.</p><h4>Cause</h4><ul><li>Using block.timestamp for time-sensitive logic (e.g., deadlines, randomness).</li><li>Lack of alternative time sources or validation.</li><li>Misunderstanding miner influence over timestamps.</li></ul><h4>Consequences</h4><ul><li><strong>Manipulation</strong>: Miners can adjust timestamps to win auctions or games.</li><li><strong>Financial Loss</strong>: Incorrect outcomes lead to unfair fund distributions.</li><li><strong>Unreliable Logic</strong>: Time-based functions behave unpredictably.</li></ul><h4>Mitigation</h4><ul><li>Avoid <em>block.timestamp</em> for critical logic.</li></ul><pre>function isSaleFinished() public view returns (bool) {<br>    return block.number &gt;= END_BLOCK; // Use block number instead<br>}</pre><ul><li>Use trusted external time sources or Chainlink VRF for randomness.</li><li>Implement time buffers to reduce manipulation windows.</li><li>Test timestamp-dependent logic for miner influence.</li></ul><h3>10. Unchecked Use of tx.origin</h3><p>Using tx.origin for authentication allows phishing attacks, as it returns the original transaction sender, which may be manipulated by malicious contracts.</p><h4>Cause</h4><ul><li>Using tx.origin instead of msg.sender for access control.</li><li>Lack of awareness of phishing attack vectors.</li><li>Incorrect assumptions about transaction origin.</li></ul><h4>Consequences</h4><ul><li><strong>Unauthorized Access</strong>: Attackers trick users into calling malicious contracts, bypassing authentication.</li><li><strong>Financial Loss</strong>: Funds or assets stolen via phishing.</li><li><strong>Security Breaches</strong>: Compromised contract logic.</li></ul><h4>Mitigation</h4><ul><li>Use <em>msg.sender</em> for authentication.</li></ul><pre>function withdraw() public {<br>    require(msg.sender == owner, &quot;Unauthorized&quot;);<br>    (bool sent, ) = msg.sender.call{value: address(this).balance}(&quot;&quot;);<br>    require(sent, &quot;Transfer failed&quot;);<br>}</pre><ul><li>Educate users about phishing risks.</li><li>Audit contracts for <em>tx.origin</em> usage with tools like Slither.</li><li>Implement multi-factor authentication where possible.</li></ul><h3>Conclusion</h3><p>The vulnerabilities outlined in this report, drawn from OWASP, DASP, and SmartBugs Curated, represent only part of the most critical risks in Solidity smart contracts, contributing to significant financial losses. These issues stem from improper coding practices, insufficient input validation, and reliance on insecure external data. For DeFi protocols, security is a make-or-break feature — vulnerabilities can lead to catastrophic losses and erode user trust, rendering even the most innovative platforms unsustainable. Prioritizing security over optimizations like gas usage is essential, as robust protection ensures protocol integrity and user confidence.</p><p>To mitigate these risks, developers must adopt secure coding patterns, such as the checks-effects-interactions model, and leverage vetted libraries like OpenZeppelin for access control and SafeMath for arithmetic safety (or upgrade to Solidity ≥ 0.8.0 for built-in overflow checks). Using trusted oracles like Chainlink prevents price manipulation, while regular audits with tools like Slither, Mythril, and SolidityScan are critical for identifying vulnerabilities. Community-vetted standards, such as those from the Ethereum Foundation, further enhance contract reliability.</p><p>Focusing on security is paramount for several reasons:</p><ol><li><strong>Preventing Financial Catastrophes</strong>: High-profile exploits, like the $600M Poly Network hack in 2021, demonstrate that a single vulnerability can drain entire protocols, underscoring the need for rigorous security practices (<a href="https://consensys.io/diligence/blog/2021/08/poly-network-hack-analysis/">Consensys Diligence</a>).</li><li><strong>Maintaining Ecosystem Trust</strong>: Security breaches in one protocol can trigger broader market distrust, as seen in the 2016 DAO hack, which led to a $150M loss and a hard fork of Ethereum, highlighting the systemic impact of vulnerabilities (<a href="https://blog.ethereum.org/2016/06/17/critical-update-re-dao-vulnerability">Ethereum Blog</a>).</li><li><strong>Regulatory Scrutiny</strong>: As governments increase oversight of DeFi, secure contracts reduce the risk of regulatory penalties and ensure compliance with emerging standards, as noted in Chainalysis’s 2024 Crypto Crime Report (<a href="https://www.chainalysis.com/blog/2024-crypto-crime-report-hacking-losses">Chainalysis</a>).</li></ol><p>By prioritizing security through robust access controls, trusted oracles, and comprehensive audits, developers can build resilient smart contracts that safeguard funds and maintain trust in permissionless decentralized ecosystems. Security remains at the forefront of smart contract development.</p><p>[1] $1.42 billion in total 2024 losses</p><pre>| Vulnerability              | 2024 Losses (USD) |<br>|----------------------------|-------------------|<br>| Access Control            | $953.2M          |<br>| Price Oracle Manipulation | $8.8M            |<br>| Logic Errors              | $63.8M           |<br>| Lack of Input Validation  | $14.6M           |<br>| Reentrancy                | $35.7M           |<br>| Flash Loan Attacks        | $33.8M           |<br>| Others/Unspecified        | $310.1M          |<br>| **Total**                 | **$1.42B**       |<br>Source: OWASP Smart Contract Top 10 (2025)</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62deea1d1d20" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fast Transactions, Low Fees: Bitcoin’s Layer 2 and Sidechains]]></title>
            <link>https://medium.com/@antonio.quental/fast-transactions-low-fees-bitcoins-layer-2-a3ca0f1d2315?source=rss-55ed729bf0b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/a3ca0f1d2315</guid>
            <category><![CDATA[bitcoin]]></category>
            <category><![CDATA[layer-2]]></category>
            <category><![CDATA[scalability]]></category>
            <category><![CDATA[lightning-network]]></category>
            <category><![CDATA[liquid-network]]></category>
            <dc:creator><![CDATA[Antonio Quental]]></dc:creator>
            <pubDate>Mon, 27 May 2024 22:46:33 GMT</pubDate>
            <atom:updated>2024-05-29T13:57:02.297Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>The Foundation</strong></h3><p>Bitcoin is a peer-to-peer electronic cash system that does not rely on trust¹.</p><blockquote>A purely peer-to-peer version of electronic cash would allow online payments to be sent directly from one party to another without going through a financial institution — <a href="https://bitcoin.org/bitcoin.pdf">Bitcoin whitepaper</a></blockquote><p>It avoids double spending in a permissionless public blockchain while removing the need for a trusted intermediary. Its main focus is security and decentralization¹. Its concepts work very well to enhance the resiliency of the blockchain but affect its usability. They are very efficient mechanisms to protect the blockchain from attacks and give the right incentives for its governance, but they are not optimal for certain usages, specifically micropayments².</p><p>Adding new functionalities requires the community to discuss and test them thoroughly; Bitcoin evolves slowly, which is good. However, some features hinder its adoption by commerce and the masses. An example is the network fees; they work well to keep the blockchain secure and quickly change to modulate variations in transaction peaks. They prevent spam messages and help support network security by keeping mining profitable while incentivizing more miners to join, thus increasing decentralization. These unpredictable fluctuations are natural on Web3 but not on Web2³.</p><h3>Layer 2 and Sidechains</h3><p>Bitcoin is a Layer 1 permissionless public ledger where everyone can see every transaction. This makes it super secure, but adding transactions can be slow because everything needs to be carefully checked. This makes transactions on Bitcoin expensive and time-consuming³.</p><p><em>Layer 2</em> is like a smaller notebook you keep for everyday spending. It tracks small payments between you and a group of people. You can quickly write down who owes who what without needing everyone else (including the blockchain) to see it immediately. Then, you can settle up with your group and record the final amount in the Bitcoin blockchain.</p><p>Bitcoin is the main vault for your valuables. It is super secure but a bit slow to access (as it should be). Layer 2 is your wallet for everyday spending. It is quick and convenient, but you eventually need to deposit or withdraw from the main vault.</p><figure><img alt="Bitcoin Layer 2" src="https://cdn-images-1.medium.com/max/1024/1*Nt0i-oc_CBKJUqPV9XFXrg.jpeg" /></figure><p><em>Sidechains</em> are another method for scaling Bitcoin transactions using the “modular thesis.” This approach breaks down transaction processing into separate modules, each handled by independent systems. While conceptually sound, the current implementations fall short:</p><ul><li><strong>Rollups:</strong> designed to leverage Bitcoin for data availability, are not being used in production [as of the first quarter of 2024].</li><li><strong>Validiums</strong> and <strong>Optimiums: </strong>offer better performance but compromise security and rely on different blockchains, not Bitcoin.</li><li><strong>Other blockchains</strong>: existing projects are not built on Bitcoin but other blockchains (like Ethereum) or custom sidechains.</li><li><strong>Performance focus</strong>: running separate blockchains and using alternative data availability solutions (which may hinder security).</li></ul><p>The modular approach holds promise, but current implementations deviate from the core idea and may introduce new security concerns.</p><p>Layer 2 and Sidechains brings for Bitcoin:</p><ul><li><strong>Faster transactions:</strong> can be used for everyday purchases, making them quicker and cheaper and reducing the friction associated with commerce usage.</li><li><strong>Security relies on Bitcoin:</strong> the final tally still goes into the blockchain, so your money remains secure by Layer 1 itself (the majority of them).</li><li><strong>New functionalities</strong>: new features can be added to Layer 2 and sidechains, leaving the Bitcoin Blockchain (L1) evolving at its own pace. <em>Rapid innovation</em> and <em>cheap experimentation</em> are important to the evolution of any technology.</li></ul><p>Layer 2 helps Bitcoin function more smoothly in daily (Web2³) life, like having a smaller wallet for everyday purchases that you can carry around instead of a bank vault for larger sums and stores of value.</p><h3>Incomplete List of Layer 2 and Sidechains</h3><p>This section is a live list of Layer 2 blockchains over Bitcoin. This technology has been evolving and booming recently, and I may have missed some new or interesting technology. Please let me know in this case; I&#39;ll gladly learn and write about it. Below is the incomplete list of Layer 2 blockchains and Sidechains with a one-liner extracted from their websites.</p><ol><li><strong>Lightning⁵</strong>: a decentralized system for instant, high-volume micropayments that remove the risk of delegating custody of funds to their parties.</li><li><strong>Liquid⁶</strong>: a solution enabling the fast, confidential settlement and issuance of digital assets, such as stablecoins, security tokens, and other financial instruments, on top of Blockchain.</li><li><strong>Stacks⁷</strong>: allows builders to leverage the Bitcoin properties and create new use cases.</li><li><strong>Rootstock⁸</strong>: EVM-compatible smart contracts platform designed for a freer, fairer, and more decentralized world.</li><li><strong>Merlin Chain⁹</strong>: Unleashing Bitcoin’s Potential with Native L1 Assets, Users and Protocols.</li><li><strong>Dovi¹⁰</strong>: EVM-compatible smart contract platform designed to enhance scalability, reduce fees, and foster a more secure and decentralized financial ecosystem.</li><li><strong>Nervos¹¹</strong>: Built on RISC-V and secured by Proof-of-Work, CKB (Common Knowledge Base) is the most flexible and interoperable blockchain. It serves as the ultimate foundation of Nervos, a modular blockchain network built from the ground up to ensure outstanding security, decentralization, flexibility, and interoperability.</li><li><strong>SatoshiVM¹²</strong>: a decentralized Bitcoin ZK Rollup Layer 2 compatible with the EVM ecosystem and uses native BTC as gas. Introduces the EVM ecosystem to BTC, granting the Bitcoin ecosystem the capability to issue assets and build applications.</li><li><strong>BitVM¹³</strong>: enables a free market of second layers, potentially scaling Bitcoin to billions of users.</li><li><strong>Citrea¹⁴:</strong> is the first rollup that enhances the capabilities of Bitcoin block space with zero-knowledge technology, making it possible to build everything on Bitcoin.</li><li><strong>Alpen Labs¹⁵: </strong>Build on the most resilient foundation and anchor your application to the most secure man-made structure ever built.</li></ol><h3><strong>Benefits and Trade-offs</strong></h3><p>Layer 2 solutions offer exciting possibilities but also trade-offs. They offer the advantages of scalability, faster transactions, and lower fees while also offering potential drawbacks like increased complexity and potential security considerations for certain implementations. However, one of the main collateral advantages is the benefit of creating a sandbox where new technologies can be tested, aggregated, and experimented with without compromising the Bitcoin Blockchain.</p><p><strong>Benefits:</strong></p><ul><li><strong>Faster Transactions</strong>: lets you make small payments quickly (in seconds) and efficiently.</li><li><strong>Lower Fees</strong>: significantly reduces fees, making it more practical for everyday purchases and micropayments, boosting adoption.</li><li><strong>More Uses</strong>: it opens new doors for Bitcoin, allows the creation of new apps, and uses new technologies (privacy, interoperability, Dapps, etc.).</li><li><strong>Not a Replacement:</strong> it doesn’t replace Bitcoin; it works alongside it. For important transactions, you’ll still need the main Bitcoin network.</li></ul><p><strong>Drawbacks:</strong></p><ul><li><strong>Added Complexity:</strong> solutions can be more technical to understand than using Bitcoin directly.</li><li><strong>Security Reliance:</strong> while it might have security features, it ultimately relies on Bitcoin’s security for final settlements.</li><li><strong>Potential for Bugs:</strong> new features and functionalities introduced by Layer 2 and Sidechain solutions can harbor undiscovered bugs that could be exploited.</li><li><strong>Potential Security Risks¹⁶</strong>: using multi-signature bridges makes solutions susceptible to theft. Some solutions centralize entities for transaction processing, sequencing, and data verification. There is a potential for misuse. Many projects downplay the security risks and mislead users by comparing their solutions to more secure modular designs used in other ecosystems.</li><li><strong>Marketing buzz</strong>: some modular Bitcoin sidechains are transparent about their centralized nature, which is acceptable for users who understand the risks. However, my criticism lies with the ones that are deceptive about it and are not transparent enough to fully disclose this aspect of their system.</li></ul><p>In summary, Layer 2 and Sidechain are great ways to make Bitcoin more user-friendly for everyday transactions. They’re faster, cheaper, and open up new possibilities. However, they’re a bit more complex and don&#39;t always rely on Bitcoin’s security for ultimate peace of mind.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5B5DSjQxC8AaxtAJ8Zh-3Q.png" /></figure><p>Stay tuned for more! In the next posts, I&#39;ll explore details about each of them.</p><p>[1] The Blockchain Trilemma refers to the trade-off between 3 critical aspects of blockchain technology: <em>Security</em>, <em>Scalability</em>, and <em>Decentralization</em>. Bitcoin runs on a blockchain that prioritizes <em>Decentralization</em> and <em>Security</em>, which poses <em>Scalability</em> challenges.</p><p>[2] Micropayments are small financial transactions, usually worth less than a few dollars. They are often used for digital goods and services, such as articles, videos, games, and small physical goods, and can be a convenient and cost-effective way to pay for them. They can also be used when conventional payment methods, like credit cards or Layer 1 transactions, are impractical due to high processing fees.</p><p>[3] I use <em>Web2</em> as a reference for commerce based on <em>fiat</em> (from the Latin for “let it be done,” the word <em>fiat</em> is a binding edict issued by a person in command. It can gain an almost Biblical aura of authority), where you need to trust third parties (banks, governments, and others) to participate.</p><p>[4] This is by design. Transactions must be hard to mine (PoW) but easy to verify. When there is a peak in blockchain use, its fees (auction for block space) quickly adapt (increase) to modulate it. This prevents spam transactions that would lead to a Denial of Service attack. In layman&#39;s words, you must invest in its infrastructure to try to break it (if it is counterintuitive, you got the idea).</p><p>[5] Lightning Network: <a href="https://lightning.network/">https://lightning.network/</a></p><p><a href="https://lightning.network/">Lightning Network</a></p><p>[6] The Liquid Network: <a href="https://liquid.net/">https://liquid.net/</a></p><p><a href="https://liquid.net/">Liquid Network: Purpose-Built for Asset Issuance</a></p><p>[7] Stacks: <a href="https://www.stacks.co/">https://www.stacks.co/</a></p><p><a href="https://www.stacks.co/">Stacks - The Leading Bitcoin L2 for Smart Contracts, Apps, DeFi</a></p><p>[8] Rootstock: <a href="https://rootstock.io/">https://rootstock.io/</a></p><p><a href="https://rootstock.io/">Bitcoin Smart Contracts - Build on Bitcoin | Roostock (RSK)</a></p><p>[9] Merlin Chain: <a href="https://merlinchain.io/">https://merlinchain.io/</a></p><p><a href="https://merlinchain.io/">Merlin Chain</a></p><p>[10] Dovi: <a href="https://dovil2.com/">https://dovil2.com/</a></p><p><a href="https://dovil2.com/">DOVI</a></p><p>[11] Nervos: <a href="https://www.nervos.org/">https://www.nervos.org/</a></p><p><a href="https://www.nervos.org/">Nervos Network</a></p><p>[12] SatoshiVM: <a href="https://www.satoshivm.io/">https://www.satoshivm.io/</a></p><p><a href="https://x.com/SatoshiVM">x.com</a></p><p>[13] Citrea: <a href="https://citrea.xyz/">https://citrea.xyz/</a></p><p><a href="https://citrea.xyz/">Citrea</a></p><p>[14] BitVM: <a href="https://bitvm.org/">https://bitvm.org/</a></p><p><a href="https://bitvm.org/">BitVM - Smarter Bitcoin Contracts</a></p><p>[15] AplenLabs: <a href="https://www.alpenlabs.io/">https://www.alpenlabs.io/</a></p><p><a href="https://www.alpenlabs.io/">Alpen Labs - Universal Rails For Money With ZK + Bitcoin</a></p><p>[16] The new wave of Bitcoin L2s are sidechains, <a href="https://bitcoinmagazine.com/technical/bitcoin-layer2-sidechains">https://bitcoinmagazine.com/technical/bitcoin-layer2-sidechains</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a3ca0f1d2315" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>