ISO/IEC TS 17961:2013 情報技術—プログラミング言語、その環境、およびシステムソフトウェアインターフェイス—Cの安全なコーディングルール | ページ 6

※一部、英文及び仏文を自動翻訳した日本語訳を使用しています。

4 用語と定義

この文書の目的上、ISO/IEC 9899:2011, ISO/IEC 2382-1:1993 および以下に記載されている用語と定義が適用されます。他の用語は、斜体で示されているwhere 定義されています。この文書で定義されていない数学記号は、ISO 80000-2:2009 に従って解釈されます。

4.1

アナライザ

ソフトウェア プログラムのコーディングの欠陥を診断するメカニズム

注記 1: アナライザーには、静的分析ツール、コンパイラー・スイート内のツール、または他のコンテキスト内のツールが含まれる場合があります。

4.2

データフロー分析

コード内の除外されないパスに沿った値の制約の追跡

注記 1:追跡は、関数呼び出しの境界で何が起こるかについてさまざまな仮定を立ててプロシージャ内で実行できます。またはプロシージャ間でここで, 値は引数として関数呼び出しに (直接的または間接的に) 流入し、引数として流出するかによって追跡されます。値を返すか、引数を介して間接的に返します。

注記 2: データ・フロー分析では、ヒープに流入またはヒープから流出する値を追跡したり、グローバル変数を考慮したりしない場合があります。この仕様が値のフローに言及する場合、重要な点は変数または式との対比です。これは、特定の変数または式が異なるパスに沿って異なる値を保持する可能性があり、また、特定の値が複数の変数または式によって保持される可能性があるためです。パス。

4.3

エクスプロイト

セキュリティの脆弱性を利用して、明示的または暗黙的なセキュリティ ポリシーに違反する手法

4.4

帯域内エラーインジケーター

ライブラリ関数のエラー時の戻り値。そのライブラリ関数の呼び出しが成功しても返されない値。

4.5

切り取られた価値

注 1:破損した値は、符号または大きさのいずれかがプログラマの予期したものと異なる可能性があるため、汚染された値と同じくらい危険である可能性があります。

4.6

非永続シグナルハンドラー

シグナルの発生後にそのシグナルの後続の発生をキャッチするためにプログラムがシグナル ハンドラーを再度登録することを必要とする実装上で実行されるシグナル ハンドラー

4.7

帯域外エラーインジケーター

エラーステータスのみを示すために使用されるライブラリ関数の戻り値

4.8

ドメイン外の値

特定の演算子または関数のドメインにない値のセットの 1 つ

4.9

制限されたシンク

ドメインがその型で記述されるドメインのサブセットであるオペランドと引数

注 1:汚染された値が制限されたシンクに値として供給された場合、未定義または予期しない動作が発生する可能性があります。

注記 2:汚染された値が制限されたシンクに供給された場合、診断が必要です。

注記 3:異なる制限付きシンクは、同じ値に対して異なる有効性制約を課す可能性があります。特定の値は、1 つの制限されたシンクに関しては汚染される可能性がありますが、別の制限されたシンクに関してはサニタイズされます (その結果、汚染されなくなります)

注記 4:特定の制限されたシンクおよび汚染された値をサニタイズするための要件は、汚染分析を扱う特定の規則に記載されています (5.8, 5.14, 5.24, 5.30, 5.39, および 5.46 を参照)

4.10

消毒する

テストまたは置換によって、汚染された値またはその他の値が、それが流入する可能性のある 1 つまたは複数の制限されたシンクによって課せられる制約に準拠していることを保証する

注 1:値が適合しない場合は、その値の使用を避けるためにパスが変更されるか、適合することがわかっている別の値が置き換えられます。

例:

strlen関数に引数として渡す前に、バッファの末尾に null 文字を追加します。

4.11

セキュリティ上の欠陥

潜在的なセキュリティリスクを引き起こす欠陥

4.12

セキュリティポリシー

機密性の高い重要なシステム リソースを保護するために、システムまたは組織がセキュリティ サービスを提供する方法を指定または規制する一連のルールと実践

4.13

静的解析

コードを実行せずに評価するプロセス

注記 1:[ 1] を参照。 3.

4.14

汚染されたソース

信頼できないデータの外部ソース

注記 1: 汚染されたソースには以下が含まれます。
  • main関数へのパラメータ、
  • localeconvfgetcgetcgetcharfgetwcgetwc 、およびgetwcharからの戻り値、および
  • getenvfscanfvfscanfvscanffgetsfreadfwscanfvfwscanfvwscanfwscanf 、およびfgetwsによって生成される文字列。

4.15

汚染された価値

サニタイズされていない汚染されたソースに由来する価値

4.16

目標の実装

C プログラミング言語の実装。その環境制限と実装定義の動作は、プログラムの分析中にアナライザーによって想定されます。

4.17

UB

未定義の動作

4.18

予期せぬ動作

プログラマーにとって予期しない、または予期しない可能性がある、明確に定義された動作。間違ったプログラミングの前提条件

4.19

符号なし整数のラッピング

結果の型で表現できる最大値より 1 大きい数値を法として結果が減算される、符号なしオペランドを含む計算

4.20

信頼できないデータ

信頼境界の外側から発信されたデータ

注記 1:[ 2] を参照。

4.21

有効なポインタ

配列内の要素、または配列の最後の要素の 1 つ先を参照するポインタ

注1:​​この定義の目的上、配列の要素ではないオブジェクトへのポインタは、オブジェクトの型を要素とする長さ1の配列の最初の要素へのポインタと同じように動作します。タイプ.タイプ。 (ISO/IEC 9899:2011, 6.5.8, 段落 4 を参照。)

注記 2:この定義では、オブジェクトは特定のバイト数の配列であると考えることができます。この数値は、 size演算子によって生成されるオブジェクトのサイズです。 (ISO/IEC 9899:2011, 6.3.2.3, 段落 7 を参照。)

4.22

脆弱性

攻撃者が明示的または暗黙的なセキュリティ ポリシーに違反することを可能にする一連の条件

参考文献

1Chess B.、West J.、静的分析による安全なプログラミング。アディソン・ウェスリー、ボストン、2007
2ISO/IEC 11889-1:2009, 情報技術 — トラステッド プラットフォーム モジュール — Part 1: 概要
3Seacord RC, C および C++ でのセキュア コーディング。アディソン・ウェスリー、ボストン、2013 (ニュースと正誤表については http://www.cert.org/books/secure-coding を参照)
4ISO/IEC/IEEE 9945:2009, 情報技術 - ポータブル オペレーティング システム インターフェイス (POSIX®) 基本仕様、第 7 号
5CERT C セキュア コーディング標準 https://www.securecoding.cert.org/confluence/x/HQE (2010)
6ISO/IEC TR 24772, 情報技術 — プログラミング言語 — 言語の選択と使用を通じてプログラミング言語の脆弱性を回避するためのガイダンス
7MotorIndustrySoftwareReliabilityAssociation 、MISRA-C 2004: 重要なシステムでの C 言語の使用に関するガイドライン。ミスラ、2004
8ミトレ。共通の弱点の列挙、ドラフト 9, 2008 年 4 月
9Kernighan BW, Ritchie DM, C プログラミング言語。プレンティス ホール、ニュージャージー州イングルウッド クリフ、第 2 版、1988 年
10OWASP財団3. オープン Web アプリケーション セキュリティ プロジェクト 、2011 年
11Viega J.、CLASP リファレンス ガイド、第 1.1 巻。安全なソフトウェア、2005 年
12国際標準の理論的根拠 — プログラミング言語 — C 、改訂 5.10, 2003 年 4 月
13Dowd M.、McDonald J.、Schuh J.、『The Art of Software Security Assessment: Identifying and Prevent Software Vulnerabilities』。アディソン・ウェスリー、ボストン、2006 年
14he グループとIEEE, オープン グループ基本仕様、第 6 号 (IEEE Std 1003.1)電気電子学会、ニューヨーク、2004 年
15Open BSD 、 BerkleySsoftwareDesign 、 Inc 、 マニュアル ページ 、2008 年 6 月
16Zalewski M.、 楽しみと利益のためのシグナルの配信: シグナル処理関連の脆弱性の理解、悪用、防止 、2001 年 5 月
17Hatton L.、Safer C: 高信頼性および安全性が重要なシステム用のソフトウェアの開発。マグロウヒル書籍会社、ニューヨーク、1995 年
18he Corporation の一般的な脆弱性と暴露リスト。 http://cve.mitre.org/cve/cve.html (2011)
19Spinellis D.、 「コード品質: オープンソースの視点 」。アディソン・ウェスリー、ボストン、2006 年。
20Wheeler D.、 セキュア プログラマー: コンポーネントを安全に呼び出す 、2004 年 12 月
21Summit S.、C プログラミング FAQ: よくある質問。アディソン・ウェスリー、ボストン、1995 年
22ブライアント RE, オハロラン D.、コンピューター システム: プログラマーの視点。プレンティス ホール、ニュージャージー州アッパー サドル リバー、2003 年
23ジャック B.、ベクトル書き換え攻撃。 http://cansecwest.com/slides07/Vector-Rewrite- Attack.pdf (2007 年 5 月)
24ヴァン スプランデル I.、 Unusualbugs 、2006
25Coverity Prevent ユーザー マニュアル (3.3.0)、2007 年
26電気電子学会( IEEE)、 オープン グループ基本仕様第 7 号 ( IEEE Std 1003.1:2008) IEEE, ニューヨーク、2008 年
27マイクロソフトデベロッパーネットワーク、 http://msdn.microsoft.com/en-us/ms348103 (2011)
28株式会社ネットワークアソシエイツ(NAI)。 Bugtraq: Network Associates Inc. アドバイザリー (OpenBSD)、1998 年
29Kettlewell R.、C 言語の問題点。 http://www.greenend.org.uk/rjk/2001/02/cfu.html (2002 年 2 月)
30Finlay IA, CERT アドバイザリー CA-2003-16, Microsoft RPC のバッファ オーバーフロー。 http://www.cert.org/advisories/CA-2003-16.html (2003 年 7 月)
31Microsoft セキュリティ情報 MS03-026, 「RPC インターフェイスのバッファ オーバーランによりコードが実行される可能性がある (823980)」、 2003 年 9 月
32ペシア RD, ウイルスとワーム: それらに対して何ができるでしょうか?」 2003 年 9 月 10 日
33xorl %eax, %eax CVE-2008-1517: Apple Mac OS X (XNU) の配列インデックス検証の欠落 、2009 年 6 月 9 日
34MIT, MIT krb5 セキュリティ勧告 2005-003, 2005 年
35Mead R.、脆弱性ノート VU#623332 、MIT Kerberos 5 には「krb5_recvauth()」関数に二重解放脆弱性が含まれています、2005 年
36Bレインベル。 com 、C チュートリアルに関するアドバイスと警告。 http://www.brainbell.com/tutors/c/Advice_and_Warnings_for_C/ (2011)
37Horton MR, ポータブル C ソフトウェア。プレンティス ホール、ニュージャージー州アッパー サドル リバー、1990 年
38ケーニッヒ A.、C トラップと落とし穴。アディソン・ウェスリー・プロフェッショナル、マサチューセッツ州レディング、1989 年
39ウォーレン HS, Hacker's Delightアディソン・ウェスリー、ボストン、2002
40プラム T.、C++ プログラミング。プラム ホール、カムエラ、ハワイ州、1991
41Giobbi R.、脆弱性ノート VU#551436 、 Mozilla Firefox SVG ビューアにはバッファ オーバーフローの脆弱性 2007
42Schwarz B.、Wagner Hao Chen, Morrison D.、West G.、Lin J.、Tu J. Wei.、セキュリティ違反がないか Linux ディストリビューション全体をチェックするモデル。第 21 回年次コンピュータ セキュリティ アプリケーション会議の議事録、2005 年 12 月
43ISO/IEC 9899:2011, 情報技術 — プログラミング言語 — C
44Flake H.、初期化されていないローカル変数への攻撃。」 http://www.blackhat.com/presentations/bh-europe-06/bh-eu-06-Flake.pdf (2006)
45慈悲。初期化されていないデータの悪用、 http://www.felinemenace.org/~mercy/papers/UBehavior/UBehavior.zip (2006 年 1 月)
46Banahan M.、Brady D.、Doran M.、The C Book, ANSI C 規格を特集。アディソン・ウェスリー、ボストン、1991 年
47Drepper U.、Red Hat Enterprise Linux の防御的プログラミング (および何か問題が発生した場合の対処法) http://web.sunybroome.edu/~antonakos_j/cst203/buffer/defprogramming.pdf (2009 年 4 月 8 日)
48ISO/IEC TR 24731, C ライブラリの拡張 - Part II: 動的割り当て関数
49Viega J.、Messier M.、C および C++ 用セキュア プログラミング クックブック: 暗号化、認証、ネットワーキング、入力検証などのレシピ。オライリー、カリフォルニア州セバストポル、2003 年
50国立標準技術研究所(NIST)、 SAMATE 参照データセット 、2006 年
51Griffiths A.、「藁にもすがる: スタック ポインタを移動できるとき」 http://arsouyes.org/index.php?id=248 (2006)

4 Terms and definitions

For the purposes of this document, the terms and definitions given in ISO/IEC 9899:2011, ISO/IEC 2382-1:1993 and the following apply. Other terms are defined where they appear in italic type. Mathematical symbols not defined in this document are to be interpreted according to ISO 80000-2:2009.

4.1

analyzer

mechanism that diagnoses coding flaws in software programs

Note 1 to entry: Analyzers may include static analysis tools, tools within a compiler suite, or tools in other contexts.

4.2

data flow analysis

tracking of value constraints along nonexcluded paths through the code

Note 1 to entry: Tracking can be performed intraprocedurally, with various assumptions made about what happens at function call boundaries, or interprocedurally ここで, values are tracked flowing into function calls (directly or indirectly) as arguments and flowing back out either as return values or indirectly through arguments.

Note 2 to entry: Data flow analysis may or may not track values flowing into or out of the heap or take into account global variables. When this specification refers to values flowing, the key point is contrast with variables or expressions, because a given variable or expression may hold different values along different paths, and a given value may be held by multiple variables or expressions along a path.

4.3

exploit

technique that takes advantage of a security vulnerability to violate an explicit or implicit security policy

4.4

in-band error indicator

library function return value on error that can never be returned by a successful call to that library function

4.5

mutilated value

Note 1 to entry: A mutilated value can be just as dangerous as a tainted value because it can differ either in sign or magnitude from what the programmer expects.

4.6

nonpersistent signal handler

signal handler running on an implementation that requires the program to again register the signal handler after occurrences of the signal to catch subsequent occurrences of that signal

4.7

out-of-band error indicator

library function return value used to indicate nothing but the error status

4.8

out-of-domain value

one of a set of values that is not in the domain of a particular operator or function

4.9

restricted sink

operands and arguments whose domain is a subset of the domain described by their types

Note 1 to entry: Undefined or unexpected behavior may occur if a tainted value is supplied as a value to a restricted sink.

Note 2 to entry: A diagnostic is required if a tainted value is supplied to a restricted sink.

Note 3 to entry: Different restricted sinks may impose different validity constraints for the same value; a given value can be tainted with respect to one restricted sink but sanitized (and consequently no longer tainted) with respect to a different restricted sink.

Note 4 to entry: Specific restricted sinks and requirements for sanitizing tainted values are described in specific rules dealing with taint analysis (see 5.8, 5.14, 5.24, 5.30, 5.39, and 5.46).

4.10

sanitize

assure by testing or replacement that a tainted or other value conforms to the constraints imposed by one or more restricted sinks into which it may flow

Note 1 to entry: If the value does not conform, either the path is diverted to avoid using the value or a different, known-conforming value is substituted.

EXAMPLE:

Adding a null character to the end of a buffer before passing it as an argument to the strlen function.

4.11

security flaw

defect that poses a potential security risk

4.12

security policy

set of rules and practices that specify or regulate how a system or organization provides security services to protect sensitive and critical system resources

4.13

static analysis

any process for assessing code without executing it

Note 1 to entry: See [1], p. 3.

4.14

tainted source

external source of untrusted data

Note 1 to entry: Tainted sources include
  • parameters to the main function,
  • the returned values from localeconv, fgetc, getc, getchar, fgetwc, getwc, and getwchar, and
  • the strings produced by getenv, fscanf, vfscanf, vscanf, fgets, fread, fwscanf, vfwscanf, vwscanf, wscanf, and fgetws.

4.15

tainted value

value derived from a tainted source that has not been sanitized

4.16

target implementation

implementation of the C programming language whose environmental limits and implementation-defined behavior are assumed by the analyzer during the analysis of a program

4.17

UB

undefined behavior

4.18

unexpected behavior

well-defined behavior that may be unexpected or unanticipated by the programmer; incorrect programming assumptions

4.19

unsigned integer wrapping

computation involving unsigned operands whose result is reduced modulo the number that is one greater than the largest value that can be represented by the resulting type

4.20

untrusted data

data originating from outside of a trust boundary

Note 1 to entry: See [2].

4.21

valid pointer

pointer that refers to an element within an array or one past the last element of an array

Note 1 to entry: For the purposes of this definition, a pointer to an object that is not an element of an array behaves the same as a pointer to the first element of an array of length one with the type of the object as its element type. (See ISO/IEC 9899:2011, 6.5.8, paragraph 4.)

Note 2 to entry: For the purposes of this definition, an object can be considered to be an array of a certain number of bytes; that number is the size of the object, as produced by the sizeof operator. (See ISO/IEC 9899:2011, 6.3.2.3, paragraph 7.)

4.22

vulnerability

set of conditions that allows an attacker to violate an explicit or implicit security policy

Bibliography

1Chess B., West J., Secure Programming with Static Analysis. Addison-Wesley, Boston, 2007
2ISO/IEC 11889-1:2009, Information technology — Trusted Platform Module — Part 1: Overview
3Seacord R.C., Secure Coding in C and C++. Addison-Wesley, Boston, 2013 (see http://www.cert.org/books/secure-coding for news and errata)
4ISO/IEC/IEEE 9945:2009, Information technology — Portable Operating System Interface (POSIX®) Base Specifications, Issue 7
5CERT C Secure Coding Standard https://www.securecoding.cert.org/confluence/x/HQE (2010)
6ISO/IEC TR 24772, Information technology — Programming languages — Guidance to avoiding vulnerabilities in programming languages through language selection and use
7Motor Industry Software Reliability Association, MISRA-C 2004: Guidelines for the Use of the C Language in Critical Systems. MISRA, 2004
8MITRE. Common Weakness Enumeration, Draft 9, April 2008
9Kernighan B.W., Ritchie D.M., The C Programming Language. Prentice-Hall, Englewood Cliffs, NJ, Second Edition, 1988
10OWASP Foundation3. Open Web Application Security Project , 2011
11Viega J., CLASP Reference Guide, Volume 1.1. Secure Software, 2005
12Rationale for international standard — Programming languages — C, Revision 5.10, April 2003
13Dowd M., McDonald J., Schuh J., The Art of Software Security Assessment: Identifying and Preventing Software Vulnerabilities. Addison-Wesley, Boston, 2006
14The Open Group & the IEEE, The Open Group Base Specifications, Issue 6 (IEEE Std 1003.1). Institute of Electrical and Electronics Engineers, New York, 2004
15OpenBSD, Berkley Software Design, Inc, Manual Pages , June 2008
16Zalewski M., Delivering Signals for Fun and Profit: Understanding, exploiting and preventing signal-handling related vulnerabilities , May 2001
17Hatton L., Safer C: Developing Software for High-Integrity and Safety-Critical Systems. McGraw-Hill Book Company, New York, 1995
18The MITRE Corporation, Common Vulnerabilities and Exposures List. http://cve.mitre.org/cve/cve.html (2011)
19Spinellis D., Code Quality: The Open Source Perspective . Addison-Wesley, Boston, 2006.
20Wheeler D., Secure programmer: Call components safely , December 2004
21Summit S., C Programming FAQs: Frequently Asked Questions. Addison-Wesley, Boston, 1995
22Bryant R.E., O’Halloran D., Computer Systems: A Programmer’s Perspective. Prentice Hall, Upper Saddle River, NJ, 2003
23Jack B., Vector Rewrite Attack. http://cansecwest.com/slides07/Vector-Rewrite-Attack.pdf (May 2007)
24van Sprundel I., Unusualbugs , 2006
25Coverity Prevent User’s Manual (3.3.0), 2007
26Institute of Electrical and Electronics Engineers (IEEE), The Open Group Base Specifications Issue 7 (IEEE Std 1003.1:2008). IEEE, New York, 2008
27Microsoft Developer Network, http://msdn.microsoft.com/en-us/ms348103 (2011)
28Network Associates Inc. (NAI). Bugtraq: Network Associates Inc. Advisory (OpenBSD), 1998
29Kettlewell R., C Language Gotchas. http://www.greenend.org.uk/rjk/2001/02/cfu.html (February 2002)
30Finlay I.A., CERT Advisory CA-2003-16, Buffer Overflow in Microsoft RPC. http://www.cert.org/advisories/CA-2003-16.html (July 2003)
31Microsoft Security Bulletin MS03-026, “Buffer Overrun In RPC Interface Could Allow Code Execution (823980),” September 2003
32Pethia R.D., Viruses and Worms: What Can We Do About Them?” September 10, 2003
33xorl %eax, %eax . CVE-2008-1517: Apple Mac OS X (XNU) Missing Array Index Validation , June 9, 2009
34MIT, MIT krb5 Security Advisory 2005-003 ,” 2005
35Mead R., Vulnerability Note VU#623332 , MIT Kerberos 5 contains double free vulnerability in “krb5_recvauth()” function, 2005
36Brainbell.com, Advice & Warnings for C Tutorials. http://www.brainbell.com/tutors/c/Advice_and_Warnings_for_C/ (2011)
37Horton M.R., Portable C Software. Prentice-Hall, Upper Saddle River, NJ, 1990
38Koenig A., C Traps and Pitfalls. Addison-Wesley Professional, Reading, MA, 1989
39Warren H.S., Hacker’s Delight . Addison-Wesley, Boston, 2002
40Plum T., C++ Programming. Plum Hall, Kamuela, HI, 1991
41Giobbi R., Vulnerability Note VU#551436 , Mozilla Firefox SVG viewer vulnerable to buffer overflow, 2007
42Schwarz B., Wagner Hao Chen, Morrison D., West G., Lin J., Tu J. Wei., Model Checking an Entire Linux Distribution for Security Violations.” Proceedings of the 21st Annual Computer Security Applications Conference, December 2005
43ISO/IEC 9899:2011, Information technology — Programming languages — C
44Flake H., Attacks on Uninitialized Local Variables.” http://www.blackhat.com/presentations/bh-europe-06/bh-eu-06-Flake.pdf (2006)
45Mercy. Exploiting Uninitialized Data, http://www.felinemenace.org/~mercy/papers/UBehavior/UBehavior.zip (January 2006)
46Banahan M., Brady D., Doran M., The C Book, Featuring the ANSI C Standard. Addison-Wesley, Boston, 1991
47Drepper U., Defensive Programming for Red Hat Enterprise Linux (and What To Do If Something Goes Wrong). http://web.sunybroome.edu/~antonakos_j/cst203/buffer/defprogramming.pdf (April 8, 2009)
48ISO/IEC TR 24731, Extensions to the C Library—Part II: Dynamic Allocation Functions
49Viega J., Messier M., Secure Programming Cookbook for C and C++: Recipes for Cryptography, Authentication, Networking, Input Validation & More. O’Reilly, Sebastopol, CA, 2003
50National Institute of Standards and Technology (NIST), SAMATE Reference Dataset , 2006
51Griffiths A., Clutching at Straws: When You Can Shift the Stack Pointer.” http://arsouyes.org/index.php?id=248 (2006)