{"eip":1470,"title":"Smart Contract Weakness Classification (SWC)","description":"This EIP proposes a classification scheme for security weaknesses in Ethereum smart contracts.","authors":["Gerhard Wagner (@thec00n)"],"status":"Stagnant","type":"Informational","created":"2018-09-18","discussionsTo":"https://github.com/ethereum/EIPs/issues/1469","repo":"EIPs","label":"EIP-1470","officialUrl":"https://eips.ethereum.org/EIPS/eip-1470","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1470.md","url":"https://eips.huatuo.xyz/eip-1470/","tldr":{"en":"Proposed the Smart Contract Weakness Classification (SWC), a CWE-style catalogue of numbered smart-contract bug types such as SWC-101 for integer overflow.","ja":"Smart Contract Weakness Classification（SWC）を提案した。整数オーバーフローを SWC-101 とするなど、スマートコントラクトのバグ種別に番号を付けた CWE 形式のカタログ。","ko":"스마트 컨트랙트 약점 분류(SWC)를 제안했다. 정수 오버플로를 SWC-101로 부르는 식으로, 스마트 컨트랙트 버그 유형에 번호를 붙인 CWE 방식의 목록이다.","zh":"提出了智能合约弱点分类（SWC），一个仿照 CWE 的、为智能合约漏洞类型编号的目录，例如用 SWC-101 表示整数溢出。"},"tags":["security","audit","classification","informational"],"explainers":{"en":{"lang":"en","tldr":"Proposed the Smart Contract Weakness Classification (SWC), a CWE-style catalogue of numbered smart-contract bug types such as SWC-101 for integer overflow.","tags":["security","audit","classification","informational"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-1470/","markdown":"## What problem does it solve?\n\nAudit reports, security tools and academic papers each used their own names for the same smart-contract bugs. Comparing findings, triaging tool output or training analysers was slow, even for experts, because there was no shared vocabulary.\n\nMainstream software security solved this with the **Common Weakness Enumeration (CWE)**, a numbered list of weakness types. CWE has nothing specific to smart contracts, so EIP-1470 proposes a smart-contract-specific layer on top of it: the **SWC** (Smart Contract Weakness Classification).\n\n## How it works\n\nKey terms in the spec:\n\n- **Weakness:** an error that, under the right conditions, can lead to a vulnerability.\n- **Variant:** a specific, smart-contract-level weakness. Each gets an **SWC ID**, e.g. `SWC-101` for *Integer Overflow and Underflow*.\n- **Relationship:** each SWC links to its closest parent in CWE. SWC-101, for example, links to CWE-682 *Incorrect Calculation*.\n- **Test case:** a small or real-world contract showing the weakness.\n\nEach SWC entry is a Markdown document with a title naming the root cause, its CWE relationship, a description of impact, remediation advice and references.\n\nEach test case has three parts: the source (Solidity, Vyper…), the compiled artefact in a machine-readable format, and a YAML/JSON configuration stating which SWC IDs appear and how many times. Tool authors can run their analyser over the test cases and compare against the expected results.\n\n## Sample code\n\nA test-case configuration following the schema in the spec (illustrative values):\n\n```yaml\ndescription: Token contract with an unchecked addition in transfer()\nissues:\n  - id: \"SWC-101\"\n    count: 1\n    locations:\n      - bytecode_offsets:\n          \"0x6060...\": [412]\n        line_numbers:\n          token.sol: [27]\n```\n\nThe kind of contract such a case would describe (pre-0.8 Solidity, where arithmetic did not revert on overflow):\n\n```solidity\npragma solidity ^0.4.24;\n\ncontract Token {\n    mapping(address =\u003e uint256) public balanceOf;\n\n    function transfer(address to, uint256 value) public {\n        require(balanceOf[msg.sender] - value \u003e= 0); // always true for uint\n        balanceOf[msg.sender] -= value;              // can underflow (SWC-101)\n        balanceOf[to] += value;\n    }\n}\n```\n\n## Things to know\n\n- **Status: Stagnant.** It is an Informational EIP; the classification itself was maintained outside the EIP process, in a public SWC registry repository referenced by the spec.\n- The registry is a vocabulary, not a checklist of everything that can go wrong. Many later bug classes (oracle manipulation, economic attacks, cross-chain issues) are not well covered by it.\n- SWC IDs are still seen in audit reports and tool output, so it helps to recognise them; check whether the registry you are reading is still maintained before relying on it.\n- Some entries describe issues that newer compilers mitigate, such as SWC-101 after Solidity 0.8 made checked arithmetic the default.\n"},"ja":{"lang":"ja","tldr":"Smart Contract Weakness Classification（SWC）を提案した。整数オーバーフローを SWC-101 とするなど、スマートコントラクトのバグ種別に番号を付けた CWE 形式のカタログ。","tags":["security","audit","classification","informational"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-1470/","markdown":"## 何を解決するのか\n\n監査レポート、セキュリティツール、学術論文は、同じスマートコントラクトのバグにそれぞれ独自の名前を使っていました。共通の語彙がなかったため、専門家でも、結果の比較、ツール出力のトリアージ、アナライザーの学習が遅くなっていました。\n\n主流のソフトウェアセキュリティでは、この問題を**共通脆弱性タイプ一覧（CWE、Common Weakness Enumeration）**という、弱点の種類に番号を付けたリストで解決しました。CWE にはスマートコントラクトに特化したものがないため、EIP-1470 はその上にスマートコントラクト専用の層、**SWC**（Smart Contract Weakness Classification）を提案します。\n\n## 仕組み\n\n仕様の主な用語は次のとおりです。\n\n- **Weakness（弱点）:** 適切な条件下で脆弱性につながりうるエラー。\n- **Variant（バリアント）:** スマートコントラクトレベルの具体的な弱点。それぞれに **SWC ID** が付きます。たとえば *Integer Overflow and Underflow* の `SWC-101` です。\n- **Relationship（関係）:** 各 SWC は CWE の最も近い親にリンクします。たとえば SWC-101 は CWE-682 *Incorrect Calculation* にリンクします。\n- **Test case（テストケース）:** その弱点を示す、小さなコントラクトまたは実際のコントラクト。\n\n各 SWC エントリは Markdown ドキュメントで、根本原因を示すタイトル、CWE との関係、影響の説明、対策の助言、参考文献から成ります。\n\n各テストケースは 3 つの部分から成ります。ソース（Solidity、Vyper など）、機械可読形式のコンパイル済み成果物、そしてどの SWC ID が何回現れるかを示す YAML/JSON の設定です。ツールの作者は、テストケースに対して自分のアナライザーを実行し、期待される結果と比較できます。\n\n## サンプルコード\n\n仕様のスキーマに従ったテストケースの設定です（値は説明用）。\n\n```yaml\ndescription: Token contract with an unchecked addition in transfer()\nissues:\n  - id: \"SWC-101\"\n    count: 1\n    locations:\n      - bytecode_offsets:\n          \"0x6060...\": [412]\n        line_numbers:\n          token.sol: [27]\n```\n\nこのようなテストケースが記述するコントラクトの例です（0.8 より前の Solidity。算術演算はオーバーフローしても revert しませんでした）。\n\n```solidity\npragma solidity ^0.4.24;\n\ncontract Token {\n    mapping(address =\u003e uint256) public balanceOf;\n\n    function transfer(address to, uint256 value) public {\n        require(balanceOf[msg.sender] - value \u003e= 0); // always true for uint\n        balanceOf[msg.sender] -= value;              // can underflow (SWC-101)\n        balanceOf[to] += value;\n    }\n}\n```\n\n## 知っておくべきこと\n\n- **ステータス: Stagnant。** これは Informational な EIP です。分類そのものは EIP のプロセスの外で、仕様が参照する公開の SWC レジストリのリポジトリで維持されていました。\n- このレジストリは語彙であり、起こりうるあらゆる問題のチェックリストではありません。その後に現れた多くのバグの類型（オラクル操作、経済的攻撃、クロスチェーンの問題）は十分にカバーされていません。\n- SWC ID は今も監査レポートやツールの出力に登場するため、見分けられると役に立ちます。頼る前に、参照しているレジストリが今も保守されているかを確認してください。\n- 一部のエントリは、新しいコンパイラが緩和している問題を扱っています。たとえば SWC-101 は、Solidity 0.8 で検査付き算術がデフォルトになった後が該当します。\n"},"ko":{"lang":"ko","tldr":"스마트 컨트랙트 약점 분류(SWC)를 제안했다. 정수 오버플로를 SWC-101로 부르는 식으로, 스마트 컨트랙트 버그 유형에 번호를 붙인 CWE 방식의 목록이다.","tags":["security","audit","classification","informational"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-1470/","markdown":"## 어떤 문제를 해결하나요?\n\n감사 보고서, 보안 도구, 학술 논문은 같은 스마트 컨트랙트 버그에 각자 다른 이름을 썼습니다. 공통 어휘가 없어서 전문가에게도 결과를 비교하고, 도구 출력을 분류하고, 분석기를 학습시키는 일이 더뎠습니다.\n\n주류 소프트웨어 보안은 이 문제를 약점 유형에 번호를 붙인 목록인 **공통 약점 목록(CWE, Common Weakness Enumeration)**으로 해결했습니다. CWE에는 스마트 컨트랙트에 특화된 내용이 없으므로, EIP-1470은 그 위에 스마트 컨트랙트 전용 계층인 **SWC**(Smart Contract Weakness Classification)를 제안합니다.\n\n## 어떻게 동작하나요?\n\n명세의 주요 용어는 다음과 같습니다.\n\n- **Weakness(약점):** 적절한 조건에서 취약점으로 이어질 수 있는 오류.\n- **Variant(변형):** 구체적인 스마트 컨트랙트 수준의 약점. 각각 **SWC ID**를 받습니다. 예를 들어 *Integer Overflow and Underflow*는 `SWC-101`입니다.\n- **Relationship(관계):** 각 SWC는 CWE에서 가장 가까운 부모에 연결됩니다. 예를 들어 SWC-101은 CWE-682 *Incorrect Calculation*에 연결됩니다.\n- **Test case(테스트 케이스):** 그 약점을 보여 주는 작은 컨트랙트 또는 실제 컨트랙트.\n\n각 SWC 항목은 근본 원인을 나타내는 제목, CWE와의 관계, 영향 설명, 대응 방안, 참고 자료를 담은 Markdown 문서입니다.\n\n각 테스트 케이스는 세 부분으로 이루어집니다. 소스(Solidity, Vyper 등), 기계가 읽을 수 있는 형식의 컴파일 산출물, 그리고 어떤 SWC ID가 몇 번 나타나는지를 밝힌 YAML/JSON 설정입니다. 도구 제작자는 테스트 케이스에 자신의 분석기를 실행해 기대 결과와 비교할 수 있습니다.\n\n## 샘플 코드\n\n명세의 스키마를 따른 테스트 케이스 설정입니다(값은 설명용).\n\n```yaml\ndescription: Token contract with an unchecked addition in transfer()\nissues:\n  - id: \"SWC-101\"\n    count: 1\n    locations:\n      - bytecode_offsets:\n          \"0x6060...\": [412]\n        line_numbers:\n          token.sol: [27]\n```\n\n이런 케이스가 설명하는 컨트랙트의 예입니다(0.8 이전의 Solidity로, 산술 연산이 오버플로되어도 revert되지 않았습니다).\n\n```solidity\npragma solidity ^0.4.24;\n\ncontract Token {\n    mapping(address =\u003e uint256) public balanceOf;\n\n    function transfer(address to, uint256 value) public {\n        require(balanceOf[msg.sender] - value \u003e= 0); // always true for uint\n        balanceOf[msg.sender] -= value;              // can underflow (SWC-101)\n        balanceOf[to] += value;\n    }\n}\n```\n\n## 알아둘 점\n\n- **상태: Stagnant.** Informational EIP입니다. 분류 자체는 EIP 절차 밖에서, 명세가 참조하는 공개 SWC 레지스트리 저장소에서 관리되었습니다.\n- 이 레지스트리는 어휘집이지, 잘못될 수 있는 모든 것의 체크리스트가 아닙니다. 이후에 등장한 많은 버그 유형(오라클 조작, 경제적 공격, 크로스체인 문제)은 잘 다루지 못합니다.\n- SWC ID는 지금도 감사 보고서와 도구 출력에서 보이므로 알아보는 것이 도움이 됩니다. 의존하기 전에 읽고 있는 레지스트리가 아직 관리되고 있는지 확인하세요.\n- 일부 항목은 새 컴파일러가 완화한 문제를 설명합니다. 예를 들어 Solidity 0.8이 검사된 산술을 기본값으로 만든 이후의 SWC-101이 그렇습니다.\n"},"zh":{"lang":"zh","tldr":"提出了智能合约弱点分类（SWC），一个仿照 CWE 的、为智能合约漏洞类型编号的目录，例如用 SWC-101 表示整数溢出。","tags":["security","audit","classification","informational"],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-1470/","markdown":"## 它解决什么问题？\n\n审计报告、安全工具和学术论文对同一类智能合约漏洞各自使用不同的名称。由于没有共同的词汇，即使是专家，比较发现结果、分拣工具输出或训练分析器也很慢。\n\n主流软件安全用**通用弱点枚举（CWE，Common Weakness Enumeration）**解决了这个问题，它是一份给弱点类型编号的列表。CWE 中没有专门针对智能合约的内容，因此 EIP-1470 在其之上提出一个面向智能合约的层：**SWC**（Smart Contract Weakness Classification，智能合约弱点分类）。\n\n## 它如何运作\n\n规范中的关键术语：\n\n- **Weakness（弱点）：** 在适当条件下可能导致漏洞的错误。\n- **Variant（变体）：** 一个具体的、智能合约层面的弱点。每个都有一个 **SWC ID**，例如 *Integer Overflow and Underflow* 的 `SWC-101`。\n- **Relationship（关系）：** 每个 SWC 都链接到它在 CWE 中最近的父项。例如，SWC-101 链接到 CWE-682 *Incorrect Calculation*。\n- **Test case（测试用例）：** 展示该弱点的小型合约或真实世界的合约。\n\n每个 SWC 条目是一份 Markdown 文档，包含指明根本原因的标题、与 CWE 的关系、影响说明、修复建议和参考资料。\n\n每个测试用例有三个部分：源代码（Solidity、Vyper 等）、机器可读格式的编译产物，以及一份 YAML/JSON 配置，说明出现了哪些 SWC ID 以及出现次数。工具作者可以在测试用例上运行自己的分析器，并与预期结果比较。\n\n## 示例代码\n\n遵循规范中模式的测试用例配置（数值仅作示意）：\n\n```yaml\ndescription: Token contract with an unchecked addition in transfer()\nissues:\n  - id: \"SWC-101\"\n    count: 1\n    locations:\n      - bytecode_offsets:\n          \"0x6060...\": [412]\n        line_numbers:\n          token.sol: [27]\n```\n\n此类用例所描述的合约示例（0.8 之前的 Solidity，当时算术运算溢出不会回滚）：\n\n```solidity\npragma solidity ^0.4.24;\n\ncontract Token {\n    mapping(address =\u003e uint256) public balanceOf;\n\n    function transfer(address to, uint256 value) public {\n        require(balanceOf[msg.sender] - value \u003e= 0); // always true for uint\n        balanceOf[msg.sender] -= value;              // can underflow (SWC-101)\n        balanceOf[to] += value;\n    }\n}\n```\n\n## 需要注意\n\n- **状态：Stagnant。** 这是一份 Informational EIP；分类本身在 EIP 流程之外维护，位于规范所引用的公开 SWC 注册表仓库中。\n- 该注册表是一份词汇表，而不是涵盖所有可能出问题之处的检查清单。后来出现的许多漏洞类别（预言机操纵、经济攻击、跨链问题）都没有被很好地覆盖。\n- SWC ID 仍然出现在审计报告和工具输出中，所以认识它们会有帮助；依赖之前，请确认你所读的注册表是否仍有人维护。\n- 部分条目描述的问题已被新编译器缓解，例如 Solidity 0.8 把检查算术设为默认之后的 SWC-101。\n"}}}
