# Moving from building Smart Contracts to breaking them

When you transition from a software developer to a security researcher, the first thing you realize is that writing functional code and auditing code require completely different perspectives.

As a developer, your goal is creation: *How do I make this contract do what it is supposed to do?* As a security researcher, your goal is subversion: *How do I force this contract to do what it was never intended to do?*

Stepping into competitive auditing platforms—like entering a CodeHawks "First Flight" contest—instantly forces this perspective shift. You quickly learn that securing smart contracts isn't just about running tools or memorizing checklists. It requires a fundamental shift in how you read code.

## 1\. The Limits of Automated Tools

When you start out in Web3 security, you usually begin with static analysis tools like **Slither** and **Aderyn**. These tools are excellent for scanning a codebase in seconds to find missing checks, simple typos, and known bad patterns.

However, tools are only a baseline. Running a scanner is not auditing.

Scanners look for syntax patterns, but they cannot understand the business logic of a unique project. They won't know if a math equation is slightly off in a specific lending pool, or if an access control rule doesn't fit the project's actual goals. Tools clear away the obvious mistakes so that you, the human researcher, can focus on the complex, hidden flaws.

## 2\. Leveraging AI for Auditing Efficiency

Instead of viewing AI as an independent auditor that will replace human researchers, the most efficient auditors should treat it as a powerful co-pilot. AI increases your daily output by handling the heavy lifting of code ingestion and boilerplate generation.

*   **Accelerating Code Comprehension:** When you enter a fresh audit contest with dozens of unfamiliar files, AI is highly efficient at summarizing the codebase architecture. You can use it to map inheritance graphs, trace how variables move across different internal functions, and explain complex mathematical loops in plain language.
    
*   **Drafting Proof of Concept (PoC) Tests:** Once you manually find a potential vulnerability, you have to write a script to prove the exploit works. Writing test setup boilerplates in testing frameworks like Foundry takes time. AI can generate these test setups instantly, leaving you free to focus entirely on the exploit logic.
    
*   **The Trap of Lexical Bias:** You must remain careful. Security benchmarks show that standard language models often fall into the trap of "lexical bias"—they guess if code is safe based on descriptive variable names and comments rather than the actual math and execution logic.
    

AI is excellent for sorting noise and writing baseline code tests, but it cannot double-check its own logic. The human researcher must always verify the output.

## 3\. Training Your Brain on these Big Three Attack Vectors

To find real vulnerabilities, you have to look past the surface of the code and understand how logic can be twisted. Here are three major security threats that every researcher must master:

### *Reentrancy attacks:*

Reentrancy happens when a contract sends funds to an untrusted external contract *before* it updates its own internal balance records. The attacker loops back into the original contract mid-execution, withdrawing funds over and over before the contract can record the first withdrawal.

*   **The Fix:** While developers rely on trusted libraries like **OpenZeppelin's ReentrancyGuard** to add a simple `nonReentrant` modifier to functions, a researcher must still check if the internal state changes follow the proper check-effects-interactions pattern manually.
    

### *Denial of Service (DoS): The Growing List Trap*

A DoS attack doesn't require a hacker to crash the network. Instead, a system is frozen because a developer creates an accidental bottleneck. The most classic example is using a `for` loop to scan an ever-growing list of user addresses (array).

On the blockchain, every computing step costs a small processing fee called "gas," and there is a strict limit on how much gas can be spent in a single block. If the list grows too large, running the function hits the block gas limit and fails automatically every single time. The code becomes permanently un-runnable, trapping the funds inside.

### *Flash Loan Attacks: Manipulating Market Logic*

Flash loans allow anyone to borrow millions of dollars in crypto assets with zero collateral, as long as they pay the loan back within the exact same blockchain transaction block.

Attackers use this massive pool of temporary capital to flood decentralized markets, artificially warping token prices and exploiting flawed pricing calculations in vulnerable contracts. This isn't a code bug; it is an economic logic bug.

## 4\. How to Cultivate the Researcher Mindset

To successfully cross the bridge from builder to security researcher, you have to practice looking at code through an adversarial lens. Here is how to build that pattern recognition:

*   **Read the Docs First:** Before looking at a single line of code, understand what the system is trying to achieve. If you don't know how a protocol is supposed to work, you won't spot when it fails.
    
*   **Assume Nothing is Safe:** Do not assume a function is secure just because it uses a popular framework. Track the flow of tokens and data manually from start to finish.
    
*   **Write Proof of Concepts/Code (PoCs):** When you think you've found a bug, don't just point at it. Write a test script to prove that you can actually trigger the exploit.
    

## Conclusion

The perspective shift happens when you stop looking at code as a set of rules to follow, and start looking at it as a system of boundaries to test. Tools and AI will point you in the right direction, and standard libraries will patch the obvious holes, but the ultimate security layer is always your own critical analysis. Keep breaking things!!
