# What should a Polygon smart contract audit cover?

URL: https://shield.quillaudits.com/chains/polygon/

A Polygon smart contract audit should check how your Solidity on Polygon PoS receives data from Ethereum through state sync, what happens when a sync fails and is replayed later, and when the code treats a block as final. QuillShield audits the Solidity code of a Foundry project that targets Polygon PoS, receivers and callbacks included, and keeps reviewing pull requests against the security graph from that audit.

Last updated 3 December 2026. 5 minute read. By the QuillAudits Team.

## What is different about auditing on Polygon PoS?

Polygon PoS executes EVM transactions on Bor, its block-producing layer, while Heimdall, a proof-of-stake layer built on CometBFT, validates Bor blocks and checkpoints them to Ethereum ([Polygon PoS overview](https://docs.polygon.technology/pos/overview.md)). Most review differences sit where those layers meet your contracts.

- **Ethereum data arrives through state sync, from a fixed caller.** The [Polygon state sync docs](https://docs.polygon.technology/pos/architecture/bor/state-sync.md) say an Ethereum contract calls `syncState` on StateSender, Heimdall validators agree on the record, and Bor commits pending records at the start of the next sprint, currently 16 blocks. On Polygon, `onStateReceive` can only be called by the StateReceiver contract at `0x0000000000000000000000000000000000001001`.
- **A failed sync can come back later.** Each `onStateReceive` call gets its gas from the StateSyncGasOracle, capped at 5,000,000 with a fallback of 160,000, and the docs say to read the value rather than hard-code it. If the call runs out of gas or reverts, StateReceiver emits `StateCommitted(stateId, false)` and the record can be replayed with `replayFailedStateSyncWithData` ([same page](https://docs.polygon.technology/pos/architecture/bor/state-sync.md)). The same advice applies to FxPortal's `processMessageFromRoot`.
- **Finality comes from milestones.** With Heimdall v2, deterministic finality takes 2 to 5 seconds through a milestone mechanism, according to the [Polygon PoS overview](https://docs.polygon.technology/pos/overview.md).
- **Ethereum sees Polygon through checkpoints.** Checkpoints are Merkle roots of Bor block data that Heimdall submits to Ethereum at intervals set by a governance parameter ([same page](https://docs.polygon.technology/pos/overview.md)). Anything an Ethereum contract accepts about Polygon state is only as recent as the last checkpoint.

Put together, a receiver should check its caller, do as little as possible inside the callback, and handle each record on its own, because a record that failed can be replayed after newer ones.

**Queues state sync records from StateReceiver and applies each one independently (illustrative, not audited code)** `QueuedStateSyncReceiver.sol`

```
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

contract QueuedStateSyncReceiver {
    address public constant STATE_RECEIVER = 0x0000000000000000000000000000000000001001;

    mapping(uint256 => bytes) public pending;
    mapping(uint256 => bool) public applied;

    event Queued(uint256 indexed stateId);
    event Applied(uint256 indexed stateId);

    error NotStateReceiver(address caller);
    error NothingToApply(uint256 stateId);

    /// Runs on the gas the StateSyncGasOracle grants, so it only stores the record.
    function onStateReceive(uint256 stateId, bytes calldata data) external {
        if (msg.sender != STATE_RECEIVER) revert NotStateReceiver(msg.sender);
        pending[stateId] = data;
        emit Queued(stateId);
    }

    /// Anyone can apply a queued record, in any order.
    function applyRecord(uint256 stateId) external {
        bytes memory data = pending[stateId];
        if (data.length == 0 || applied[stateId]) revert NothingToApply(stateId);
        applied[stateId] = true;
        delete pending[stateId];
        _applyUpdate(data);
        emit Applied(stateId);
    }

    /// Each update must be complete on its own and must not assume that
    /// the record before it has been applied.
    function _applyUpdate(bytes memory /* data */) internal virtual {}
}
```

## What should a reviewer check in a Polygon PoS receiver?

- `onStateReceive` accepts calls only from `0x0000000000000000000000000000000000001001`, and `processMessageFromRoot` only from the FxPortal tunnel the contract expects.
- The callback stays within the gas the StateSyncGasOracle grants, and nothing hard-codes the 5,000,000 cap or the 160,000 fallback from the [state sync docs](https://docs.polygon.technology/pos/architecture/bor/state-sync.md).
- Someone watches for `StateCommitted(stateId, false)` events and has a plan to replay failed records with enough gas.
- Every synced record is valid on its own, because a failed record can be replayed after later ones.
- Deadlines on Polygon that depend on Ethereum data allow for a record that lands a sprint or more late.
- Logic that waits for finality relies on milestones, not a confirmation count copied from older code.
- Contracts deployed at the same address on Ethereum and Polygon bind every signature to the chain ID.

## What happened in the Midas Capital exploit on Polygon?

| Protocol | Midas Capital |
| --- | --- |
| Date | 15 January 2023 |
| Chain | Polygon |
| Loss | about $660K |
| What happened | Midas Capital, a lending protocol on Polygon, was exploited through a flash loan attack on a recently added collateral type, the WMATIC-stMATIC Curve LP token. Rekt describes read-only reentrancy as a known weakness of this kind of LP token, one that lets its virtual price be manipulated when the integration is done wrong, and the attack left a $660K hole in one of the Midas pools of Jarvis Network jFIAT assets. |
| Sources | [Rekt](https://rekt.news/midas-capital-rekt) |

The risk arrived with a new collateral listing. A price read from a Curve LP token can be taken in the middle of a pool update, so listing one needs a review of how the price is read, including a reentrancy check on the read itself. The [read-only reentrancy page](https://shield.quillaudits.com/learn/vulnerabilities/read-only-reentrancy/) covers that check.

## Which Polygon PoS apps depend on state sync?

Apps that bring tokens or data over from Ethereum use state sync directly or through FxPortal, and their Polygon contracts are only as safe as their receivers. Contracts mirrored from an Ethereum deployment carry Ethereum assumptions that the table below tests.

| Protocol type | What to check first on Polygon PoS |
| --- | --- |
| Bridged token or messaging app | The caller check on the receiver, gas inside the callback, and records that replay out of order |
| Lending or DEX using Ethereum data | How old a synced rate or root can be when the code uses it |
| Contracts mirrored from Ethereum | The chain ID in signatures, and addresses that differ between the two chains |
| Anything that settles back to Ethereum | That L1 logic waits for the checkpoint covering the Polygon state it relies on |

## Which vulnerabilities matter most on Polygon PoS?

- [Cross-chain message validation](https://shield.quillaudits.com/learn/vulnerabilities/cross-chain-message-validation/): state sync records and FxPortal messages carry Ethereum data into Polygon contracts, and each one needs its sender checked.
- [Access control](https://shield.quillaudits.com/learn/vulnerabilities/access-control/): a receiver that doesn't check for StateReceiver at `0x...1001` lets anyone forge a message from Ethereum.
- [Denial of service](https://shield.quillaudits.com/learn/vulnerabilities/denial-of-service/): a callback that needs more gas than the oracle grants fails, and its record waits until someone replays it with enough gas.
- [Signature replay](https://shield.quillaudits.com/learn/vulnerabilities/signature-replay/): when the same contracts run on Ethereum and Polygon, a signature without the chain ID works on both.
- [Read-only reentrancy](https://shield.quillaudits.com/learn/vulnerabilities/read-only-reentrancy/): Midas Capital lost about $660K on Polygon to a Curve LP token whose virtual price could be manipulated.

## How do you audit Polygon PoS contracts with QuillShield?

1. Your Polygon contracts need to sit in a Foundry project. QuillShield supports Solidity in Foundry projects today.
2. Add the code from a GitHub or GitLab.com repository, a git URL, a Foundry .zip of up to 50 MiB, a folder or a single .sol file.
3. Use the audit context to name the state sync and FxPortal receivers, the L1 contracts that send to them, and which records must apply in order.
4. Look at the quote and approve it. Nothing is charged before you see the exact price.
5. When it completes, each finding lists the exact lines, the impact, a recommended fix and the proof of concept result, after a separate reviewer agent tried to disprove it.
6. With a GitHub or GitLab.com repo, keep pull request checks on so new receivers and callbacks get reviewed against the audit's security graph.

Full audits start at $49, priced from the lines of Solidity in scope as the [pricing page](https://shield.quillaudits.com/pricing/) shows. New accounts get $50 in credit, good for up to half of an order.

QuillShield doesn't replace a manual audit, and you can [request a manual audit from QuillAudits](https://www.quillaudits.com/smart-contract-audit). The [Solidity page](https://shield.quillaudits.com/languages/solidity/) covers what QuillShield checks in the language.

**[Run a full audit](https://shield.quillaudits.com/register) of your Polygon PoS receivers and the contracts around them.**

## FAQ

### Which address calls onStateReceive on Polygon PoS?

The StateReceiver system contract at `0x0000000000000000000000000000000000001001`. The [Polygon docs](https://docs.polygon.technology/pos/architecture/bor/state-sync.md) say `onStateReceive` can only be called by it, so a receiver should reject every other caller.

### What happens if onStateReceive reverts?

StateReceiver emits `StateCommitted(stateId, false)`. The record isn't lost and can be replayed with `replayFailedStateSyncWithData`, which means it can arrive after newer records.

### How long until a Polygon PoS transaction is final?

With Heimdall v2, deterministic finality takes 2 to 5 seconds through milestones, according to the [Polygon PoS overview](https://docs.polygon.technology/pos/overview.md).

## Sources

- [State sync, Polygon docs](https://docs.polygon.technology/pos/architecture/bor/state-sync.md) · checked 3 December 2026
- [Polygon PoS overview, Polygon docs](https://docs.polygon.technology/pos/overview.md) · checked 3 December 2026
- [Midas Capital, Rekt](https://rekt.news/midas-capital-rekt) · checked 3 December 2026
