{"eip":1706,"title":"Disable SSTORE with gasleft lower than call stipend","description":"The proposal that had been accepted changes security properties of a large portion of an existing contract code base that may be infeasible to update and validate. This proposal will make the old assumptions hold even after a network upgrade.","authors":["Alex Forshtat \u003calex@tabookey.com\u003e","Yoav Weiss \u003cyoav@tabookey.com\u003e"],"status":"Withdrawn","type":"Standards Track","category":"Core","created":"2019-01-15","requires":[1283],"discussionsTo":"https://github.com/alex-forshtat-tbk/EIPs/issues/1","repo":"EIPs","label":"EIP-1706","officialUrl":"https://eips.ethereum.org/EIPS/eip-1706","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1706.md","url":"https://eips.huatuo.xyz/eip-1706/","tldr":{"en":"Proposed making SSTORE fail when 2300 gas or less remains, so cheaper storage writes could not break the reentrancy protection old contracts got from the transfer/send stipend; the idea was folded into EIP-2200.","ja":"残りガスが 2300 以下のとき SSTORE を失敗させることを提案し、より安いストレージ書き込みが、古いコントラクトが transfer/send のスタイペンドから得ていたリエントランシー保護を壊さないようにした。このアイデアは EIP-2200 に取り込まれた。","ko":"남은 가스가 2300 이하일 때 SSTORE가 실패하도록 제안해, 더 저렴해진 스토리지 쓰기가 오래된 컨트랙트가 transfer/send 스타이펀드에서 얻던 재진입 보호를 깨지 않게 했다. 이 아이디어는 EIP-2200에 흡수되었다.","zh":"提议在剩余 gas 不超过 2300 时让 SSTORE 失败，使更便宜的存储写入不会破坏旧合约从 transfer/send 补贴中获得的重入保护；这一想法被并入 EIP-2200。"},"tags":["gas","sstore","security","reentrancy","core"],"explainers":{"en":{"lang":"en","tldr":"Proposed making SSTORE fail when 2300 gas or less remains, so cheaper storage writes could not break the reentrancy protection old contracts got from the transfer/send stipend; the idea was folded into EIP-2200.","tags":["gas","sstore","security","reentrancy","core"],"related":[1283,2200,1716,1013],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-1706/","markdown":"## What problem does it solve?\n\nWhen a Solidity contract uses `transfer` or `send` to pay ETH, the recipient receives only a **2300 gas stipend**. Many contracts relied on this, implicitly: with 2300 gas a malicious recipient could not write to storage, because `SSTORE` always cost at least 5000 gas. That made reentrancy through `transfer` effectively harmless.\n\n[EIP-1283](/eip-1283/) (net gas metering) made repeated writes to the same storage slot within a transaction much cheaper, as low as a few hundred gas. Shortly before the Constantinople upgrade, security researchers showed this let a recipient modify state within the 2300 stipend, opening a new reentrancy attack on existing contracts. Constantinople was postponed, and EIP-1283 was removed in the Petersburg fork ([EIP-1716](/eip-1716/)).\n\nEIP-1706 proposed a way to keep cheap storage writes *and* the old safety assumption.\n\n## How it works\n\nOne extra rule in the `SSTORE` gas calculation:\n\n- If `gasleft` is **less than or equal to 2300** when `SSTORE` executes, the current call frame fails with an out-of-gas exception.\n\nSince a stipend-only call starts with exactly 2300 gas, any `SSTORE` it attempts fails, regardless of how cheap the write would otherwise be. Contracts that rely on the stipend stay safe, and normal calls with more gas are unaffected.\n\nBecause `SSTORE` had never been possible with less than 5000 gas, the authors argued nothing on mainnet would break.\n\n## Sample code\n\nThe rule as pseudocode, inserted before any other `SSTORE` gas accounting:\n\n```python\nCALL_STIPEND = 2300\n\ndef sstore(evm, key, value):\n    if evm.gas_left \u003c= CALL_STIPEND:\n        raise OutOfGas(\"SSTORE with gas left \u003c= stipend\")\n    # ... normal net-metered SSTORE cost and refund logic follows\n```\n\nWhy it matters for this pattern:\n\n```solidity\n// Many contracts assumed `to` cannot change state during this call\npayable(to).transfer(amount); // forwards only 2300 gas\n```\n\n## Things to know\n\n- Status is **Withdrawn**. The authors preferred [EIP-2200](/eip-2200/), which re-introduced net gas metering and includes the same \"fail if gasleft ≤ 2300\" sentinel. EIP-2200 shipped in Istanbul.\n- The episode is the main reason the 2300 stipend is still treated as a protocol-level invariant for `SSTORE`.\n- Do not rely on the stipend as a security mechanism in new code. Gas costs can change, and modern guidance is to use `call` with explicit reentrancy guards instead of `transfer`/`send`.\n"},"ja":{"lang":"ja","tldr":"残りガスが 2300 以下のとき SSTORE を失敗させることを提案し、より安いストレージ書き込みが、古いコントラクトが transfer/send のスタイペンドから得ていたリエントランシー保護を壊さないようにした。このアイデアは EIP-2200 に取り込まれた。","tags":["gas","sstore","security","reentrancy","core"],"related":[1283,2200,1716,1013],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-1706/","markdown":"## 何を解決するのか\n\nSolidity のコントラクトが `transfer` や `send` で ETH を支払うと、受け取り側には **2300 ガスのスタイペンド**しか渡されません。多くのコントラクトは、これに暗黙のうちに依存していました。2300 ガスでは悪意のある受信者はストレージに書き込めません。`SSTORE` は常に 5000 ガス以上かかったからです。そのおかげで、`transfer` 経由のリエントランシーは事実上無害でした。\n\n[EIP-1283](/eip-1283/)（ネットガス計量）は、同一トランザクション内で同じストレージスロットに繰り返し書き込むコストを、数百ガス程度にまで大きく下げました。Constantinople アップグレードの直前、セキュリティ研究者は、これにより受信者が 2300 のスタイペンドの範囲内で状態を変更でき、既存のコントラクトに対する新しいリエントランシー攻撃が可能になることを示しました。Constantinople は延期され、EIP-1283 は Petersburg フォーク（[EIP-1716](/eip-1716/)）で取り除かれました。\n\nEIP-1706 は、安いストレージ書き込み*と*従来の安全性の前提を両立させる方法を提案しました。\n\n## 仕組み\n\n`SSTORE` のガス計算に追加するルールは 1 つです。\n\n- `SSTORE` の実行時に `gasleft` が **2300 以下**であれば、現在のコールフレームはガス切れ例外で失敗する。\n\nスタイペンドだけの呼び出しはちょうど 2300 ガスで始まるため、書き込みが本来どれだけ安くても、そこで試みられる `SSTORE` はすべて失敗します。スタイペンドに依存するコントラクトは安全なままで、より多くのガスを持つ通常の呼び出しは影響を受けません。\n\n`SSTORE` はこれまで 5000 ガス未満では実行できなかったため、メインネット上で壊れるものはないと著者らは主張しました。\n\n## サンプルコード\n\nルールを擬似コードで示します。他の `SSTORE` のガス計算より前に挿入されます。\n\n```python\nCALL_STIPEND = 2300\n\ndef sstore(evm, key, value):\n    if evm.gas_left \u003c= CALL_STIPEND:\n        raise OutOfGas(\"SSTORE with gas left \u003c= stipend\")\n    # ... normal net-metered SSTORE cost and refund logic follows\n```\n\nこのパターンにとってなぜ重要か:\n\n```solidity\n// Many contracts assumed `to` cannot change state during this call\npayable(to).transfer(amount); // forwards only 2300 gas\n```\n\n## 知っておくべきこと\n\n- ステータスは **Withdrawn** です。著者らは、ネットガス計量を再導入し、同じ「gasleft ≤ 2300 なら失敗」という番兵を含む [EIP-2200](/eip-2200/) を選びました。EIP-2200 は Istanbul で出荷されました。\n- この出来事が、2300 のスタイペンドが `SSTORE` に関するプロトコルレベルの不変条件として今も扱われている主な理由です。\n- 新しいコードでは、スタイペンドをセキュリティ機構として当てにしないでください。ガスコストは変わり得ますし、現在の指針では `transfer`/`send` ではなく、明示的なリエントランシーガードを付けた `call` を使います。\n"},"ko":{"lang":"ko","tldr":"남은 가스가 2300 이하일 때 SSTORE가 실패하도록 제안해, 더 저렴해진 스토리지 쓰기가 오래된 컨트랙트가 transfer/send 스타이펀드에서 얻던 재진입 보호를 깨지 않게 했다. 이 아이디어는 EIP-2200에 흡수되었다.","tags":["gas","sstore","security","reentrancy","core"],"related":[1283,2200,1716,1013],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-1706/","markdown":"## 어떤 문제를 해결하나요?\n\nSolidity 컨트랙트가 `transfer`나 `send`로 ETH를 지불하면 수신자는 **2300 가스 스타이펀드(stipend)** 만 받습니다. 많은 컨트랙트가 이에 암묵적으로 의존했습니다. 2300 가스로는 악의적인 수신자가 스토리지에 쓸 수 없었는데, `SSTORE`는 항상 최소 5000 가스가 들었기 때문입니다. 덕분에 `transfer`를 통한 재진입은 사실상 무해했습니다.\n\n[EIP-1283](/eip-1283/)(순 가스 계량)은 한 트랜잭션 안에서 같은 스토리지 슬롯에 반복해서 쓰는 비용을 몇백 가스 수준까지 크게 낮췄습니다. Constantinople 업그레이드 직전, 보안 연구자들은 이로 인해 수신자가 2300 스타이펀드 안에서 상태를 수정할 수 있고, 기존 컨트랙트에 대한 새로운 재진입 공격이 가능해진다는 것을 보였습니다. Constantinople은 연기되었고, EIP-1283은 Petersburg 포크([EIP-1716](/eip-1716/))에서 제거되었습니다.\n\nEIP-1706은 저렴한 스토리지 쓰기*와* 기존의 안전 가정을 모두 유지하는 방법을 제안했습니다.\n\n## 어떻게 동작하나요?\n\n`SSTORE` 가스 계산에 규칙 하나를 추가합니다.\n\n- `SSTORE`가 실행될 때 `gasleft`가 **2300 이하**이면 현재 호출 프레임은 out-of-gas 예외로 실패합니다.\n\n스타이펀드만 있는 호출은 정확히 2300 가스로 시작하므로, 쓰기가 원래 아무리 저렴하더라도 그 호출이 시도하는 모든 `SSTORE`는 실패합니다. 스타이펀드에 의존하는 컨트랙트는 안전하게 유지되고, 더 많은 가스를 가진 일반 호출은 영향을 받지 않습니다.\n\n`SSTORE`는 5000 가스 미만으로는 실행된 적이 없으므로, 메인넷에서 깨지는 것은 없을 것이라고 작성자들은 주장했습니다.\n\n## 샘플 코드\n\n다른 `SSTORE` 가스 계산보다 앞에 삽입되는 이 규칙의 의사 코드:\n\n```python\nCALL_STIPEND = 2300\n\ndef sstore(evm, key, value):\n    if evm.gas_left \u003c= CALL_STIPEND:\n        raise OutOfGas(\"SSTORE with gas left \u003c= stipend\")\n    # ... normal net-metered SSTORE cost and refund logic follows\n```\n\n이 패턴에서 이것이 중요한 이유:\n\n```solidity\n// Many contracts assumed `to` cannot change state during this call\npayable(to).transfer(amount); // forwards only 2300 gas\n```\n\n## 알아둘 점\n\n- 상태는 **Withdrawn**입니다. 작성자들은 순 가스 계량을 다시 도입하고 같은 \"gasleft ≤ 2300이면 실패\"라는 센티널을 포함하는 [EIP-2200](/eip-2200/)을 선호했습니다. EIP-2200은 Istanbul에서 출시되었습니다.\n- 이 사건이 2300 스타이펀드가 지금도 `SSTORE`에 대한 프로토콜 수준의 불변 조건으로 취급되는 주된 이유입니다.\n- 새 코드에서는 스타이펀드를 보안 장치로 의존하지 마세요. 가스 비용은 바뀔 수 있으며, 현대의 지침은 `transfer`/`send` 대신 명시적인 재진입 가드와 함께 `call`을 쓰는 것입니다.\n"},"zh":{"lang":"zh","tldr":"提议在剩余 gas 不超过 2300 时让 SSTORE 失败，使更便宜的存储写入不会破坏旧合约从 transfer/send 补贴中获得的重入保护；这一想法被并入 EIP-2200。","tags":["gas","sstore","security","reentrancy","core"],"related":[1283,2200,1716,1013],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-1706/","markdown":"## 它解决什么问题？\n\n当 Solidity 合约用 `transfer` 或 `send` 支付 ETH 时，接收方只会收到 **2300 gas 的补贴（stipend）**。许多合约隐式地依赖这一点：只有 2300 gas，恶意接收方无法写入存储，因为 `SSTORE` 的开销始终至少为 5000 gas。这使得通过 `transfer` 发起的重入实际上是无害的。\n\n[EIP-1283](/eip-1283/)（净 gas 计量）让同一笔交易中对同一存储槽的重复写入变得便宜得多，低至几百 gas。在 Constantinople 升级前不久，安全研究人员证明，这会让接收方能在 2300 的补贴内修改状态，从而对现有合约开辟新的重入攻击。Constantinople 因此被推迟，EIP-1283 在 Petersburg 分叉中被移除（[EIP-1716](/eip-1716/)）。\n\nEIP-1706 提出了一种既保留便宜的存储写入、*又*保留旧有安全假设的办法。\n\n## 它如何运作\n\n在 `SSTORE` 的 gas 计算中增加一条规则：\n\n- 如果执行 `SSTORE` 时 `gasleft` **小于或等于 2300**，当前调用帧会以 out-of-gas 异常失败。\n\n由于只靠补贴的调用恰好以 2300 gas 开始，它尝试的任何 `SSTORE` 都会失败，无论这次写入原本有多便宜。依赖补贴的合约保持安全，而带有更多 gas 的普通调用不受影响。\n\n由于 `SSTORE` 此前从来不可能在少于 5000 gas 的情况下执行，作者认为主网上不会有东西被破坏。\n\n## 示例代码\n\n这条规则的伪代码，插入在任何其他 `SSTORE` gas 计费之前：\n\n```python\nCALL_STIPEND = 2300\n\ndef sstore(evm, key, value):\n    if evm.gas_left \u003c= CALL_STIPEND:\n        raise OutOfGas(\"SSTORE with gas left \u003c= stipend\")\n    # ... normal net-metered SSTORE cost and refund logic follows\n```\n\n它对这种模式为何重要：\n\n```solidity\n// Many contracts assumed `to` cannot change state during this call\npayable(to).transfer(amount); // forwards only 2300 gas\n```\n\n## 需要注意\n\n- 状态是 **Withdrawn**。作者们更倾向于 [EIP-2200](/eip-2200/)，它重新引入了净 gas 计量，并包含同样的\"gasleft ≤ 2300 则失败\"哨兵。EIP-2200 在 Istanbul 中上线。\n- 这段插曲是 2300 补贴至今仍被视为 `SSTORE` 协议级不变量的主要原因。\n- 不要在新代码中把补贴当作安全机制。gas 成本可能变化，现代的指导意见是使用带有显式重入保护的 `call`，而不是 `transfer`/`send`。\n"}}}
