界: Code Quality

コードの質が低いと、予測できない動作につながります。ユーザーの視点には、それがしばしば使い勝手の悪さとなって現れます。攻撃者にとっては、予期せぬ方法でシステムにストレスを与える機会となります。

93 見つかった項目
脆弱性
Abstract
フラグ値が FLAG_MUTABLE に設定された PendingIntent が検出されています。フラグ値 FLAG_MUTABLE を使用して作成されたペンディング インテントでは、未指定の Intent フィールドにダウンストリームを設定されやすく、その結果、Intent のキャパシティが変更され、システムが攻撃にさらされやすくなります。
Explanation
PendingIntent の基盤となる Intent の変更を、作成後に許可すると、システムが攻撃にさらされやすくなります。これは主に、基盤となる Intent の全体的な機能に依存します。ほとんどの場合、PendingIntent フラグを FLAG_IMMUTABLE に設定することが、潜在的な問題を防ぐためのベスト プラクティスです。

例 1: 以下には、フラグ値 FLAG_MUTABLE を使用して作成された PendingIntent が含まれています。


...
val intent_flag_mut = Intent(Intent.ACTION_GTALK_SERVICE_DISCONNECTED, Uri.EMPTY, this, DownloadService::class.java)
val flag_mut = PendingIntent.FLAG_MUTABLE

val pi_flagmutable = PendingIntent.getService(
this,
0,
intent_flag_mut,
flag_mut
)
...
References
[1] Remediation for Implicit PendingIntent Vulnerability
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[3] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[4] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 4
[5] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[6] Standards Mapping - CIS Google Cloud Computing Platform Benchmark partial
[7] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[8] Standards Mapping - CIS Kubernetes Benchmark partial
[9] Standards Mapping - Common Weakness Enumeration CWE ID 99
[10] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001094
[11] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[12] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-5 Denial of Service Protection (P1)
[13] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-5 Denial of Service Protection
[14] Standards Mapping - OWASP Top 10 2004 A9 Application Denial of Service
[15] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.1
[16] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.3.1.1, Requirement 6.5.4
[17] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.8
[18] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.8
[19] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.8
[20] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.8
[21] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.8
[22] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[23] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP6080 CAT II
[24] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP6080 CAT II
[25] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP6080 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP6080 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP6080 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP6080 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP6080 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002400 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002400 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002400 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002400 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002400 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002400 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002400 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002400 CAT II
[38] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002400 CAT II
[39] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002400 CAT II
[40] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002400 CAT II
[41] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002400 CAT II
[42] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002400 CAT II
[43] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002400 CAT II
[44] Standards Mapping - Web Application Security Consortium Version 2.00 Denial of Service (WASC-10)
[45] Standards Mapping - Web Application Security Consortium 24 + 2 Denial of Service
desc.controlflow.java.intent_manipulation_mutable_pending_intent
Abstract
メモリは割り当てられていますが、解放されていません。
Explanation
Memory Leak には 2 つの一般的な原因があり、これらが重なっていることもあります。

- エラー条件などの例外的状況。

- プログラムのどの部分でメモリを解放するかに関して混乱が発生している。

大部分の Memory Leak は一般にソフトウェアの信頼性の問題をもたらします。しかし攻撃者が意図的に Memory Leak を引き起こせる場合、攻撃者は (プログラムをクラッシュさせて) Denial of Service 攻撃を仕掛けたり、メモリ不足により引き起こされるプログラムの予測不能な動作を利用したりすることができます [1]。

例 1: 次の C 関数では、read() のコールが予想バイト数を戻せない場合に、割り当てられているメモリのブロックが漏洩します。


char* getBlock(int fd) {
char* buf = (char*) malloc(BLOCK_SIZE);
if (!buf) {
return NULL;
}
if (read(fd, buf, BLOCK_SIZE) != BLOCK_SIZE) {
return NULL;
}
return buf;
}
References
[1] J. Whittaker and H. Thompson How to Break Software Security Addison Wesley
desc.controlflow.cpp.memory_leak
Abstract
メモリは割り当てられますが、絶対に解放されません。
Explanation
メモリ リークには、2 つの共通する、時には重複する原因があります。

- エラー条件などの例外的状況。

- プログラムのどの部分がメモリを解放するかに関する混乱。

ほとんどのメモリ リークは、ソフトウェアの全般的な信頼性の問題を引き起こしますが、攻撃者による意図的なリソース リークが可能な場合、攻撃者は Denial of Service 攻撃を起こす (プログラムをクラッシュすることで) か、低メモリの状況の結果として起きるプログラムによるその他の想定外の振る舞いを悪用することができる可能性があります [1]。

例 1: 以下の Micro Focus COBOL プログラムは、エラーが発生した場合に、割り当て済みのメモリのブロックをリークします。


CALL "CBL_ALLOC_MEM"
USING mem-pointer
BY VALUE mem-size
BY VALUE flags
RETURNING status-code
END-CALL

IF status-code NOT = 0
DISPLAY "Error!"
GOBACK
ELSE
SET ADDRESS OF mem TO mem-pointer
END-IF

PERFORM write-data
IF ws-status-code NOT = 0
DISPLAY "Error!"
GOBACK
ELSE
DISPLAY "Success!"
END-IF

CALL "CBL_FREE_MEM"
USING BY VALUE mem-pointer
RETURNING status-code
END-CALL

GOBACK
.
References
[1] J. Whittaker and H. Thompson How to Break Software Security Addison Wesley
desc.controlflow.cobol.memory_leak
Abstract
オブジェクトはメンバー変数にメモリを割り当てており、dealloc() メソッドでメモリの解放に失敗します。
Explanation
Memory Leak には 2 つの一般的な原因があり、これらが重なっていることもあります。

- エラー条件などの例外的状況。

- プログラムのどの部分でメモリを解放するかに関して混乱が発生している。

大部分の Memory Leak は一般にソフトウェアの信頼性の問題をもたらします。しかし攻撃者が意図的に Memory Leak を引き起こせる場合、攻撃者は (プログラムをクラッシュさせて) Denial of Service 攻撃を仕掛けたり、メモリ不足により引き起こされるプログラムの予測不能な動作を利用したりすることができます [1]。

例 1: Objective-C オブジェクトは、init() メソッドでメモリを割り当てますが、deallocate() メソッドでメモリの解放に失敗するため、Memory Leak が発生します。


- (void)init
{
myVar = [NSString alloc] init];
...
}

- (void)dealloc
{
[otherVar release];
}
References
[1] J. Whittaker and H. Thompson How to Break Software Security Addison Wesley
desc.structural.objc.memory_leak
Abstract
プログラムにより割り当てられたメモリブロックのサイズが変更されます。サイズ変更が失敗すると、元のブロックがリークすることになります。
Explanation
Memory Leak には 2 つの一般的な原因があり、これらが重なっていることもあります。

- エラー条件などの例外的状況。

- プログラムのどの部分でメモリを解放するかに関して混乱が発生している。

大部分の Memory Leak は一般にソフトウェアの信頼性の問題をもたらします。しかし攻撃者が意図的に Memory Leak を引き起こせる場合、攻撃者は (プログラムをクラッシュさせて) Denial of Service 攻撃を仕掛けたり、メモリ不足により引き起こされるプログラムの予測不能な動作を利用したりすることができます [1]。

例 1:realloc() のコールが元のメモリ割り当てのサイズ変更に失敗した場合に、次の C 関数は割り当てられているメモリブロックをリークしています。


char* getBlocks(int fd) {
int amt;
int request = BLOCK_SIZE;
char* buf = (char*) malloc(BLOCK_SIZE + 1);
if (!buf) {
goto ERR;
}
amt = read(fd, buf, request);
while ((amt % BLOCK_SIZE) != 0) {
if (amt < request) {
goto ERR;
}
request = request + BLOCK_SIZE;
buf = realloc(buf, request);
if (!buf) {
goto ERR;
}
amt = read(fd, buf, request);
}

return buf;

ERR:
if (buf) {
free(buf);
}
return NULL;
}
References
[1] J. Whittaker and H. Thompson How to Break Software Security Addison Wesley
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 2
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[6] Standards Mapping - Common Weakness Enumeration CWE ID 401
[7] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001094
[8] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[9] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C Guidelines 2012 Rule 21.3
[10] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C++ Guidelines 2008 Rule 18-4-1
[11] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-5 Denial of Service Protection (P1)
[12] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-5 Denial of Service Protection
[13] Standards Mapping - OWASP Top 10 2004 A9 Application Denial of Service
[14] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-STORAGE-2
[15] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.9
[16] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP6080 CAT II
[17] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP6080 CAT II
[18] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP6080 CAT II
[19] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP6080 CAT II
[20] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP6080 CAT II
[21] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP6080 CAT II
[22] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP6080 CAT II
[23] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002400 CAT II
[24] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002400 CAT II
[25] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002400 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002400 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002400 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002400 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002400 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002400 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002400 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002400 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002400 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002400 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002400 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002400 CAT II
[37] Standards Mapping - Web Application Security Consortium Version 2.00 Denial of Service (WASC-10)
[38] Standards Mapping - Web Application Security Consortium 24 + 2 Denial of Service
desc.controlflow.cpp.memory_leak_reallocation
Abstract
プログラムは、割り当て済みメモリのブロックをサイズ変更します。サイズ変更に失敗した場合は、元のブロックがリークされます。
Explanation
メモリ リークには、2 つの共通する、時には重複する原因があります。

- エラー条件などの例外的状況。

- プログラムのどの部分がメモリを解放するかに関する混乱。

ほとんどのメモリ リークは、ソフトウェアの全般的な信頼性の問題を引き起こしますが、攻撃者による意図的なリソース リークが可能な場合、攻撃者は Denial of Service 攻撃を起こす (プログラムをクラッシュすることで) か、低メモリの状況の結果として起きるプログラムによるその他の想定外の振る舞いを悪用することができる可能性があります [1]。

例 1: 以下の Micro Focus COBOL プログラムは、realloc() の呼び出しが元の割り当てのサイズ変更に失敗した場合に、割り当て済みメモリのブロックをリークします。


CALL "malloc" USING
BY VALUE mem-size
RETURNING mem-pointer
END-CALL

ADD 1000 TO mem-size

CALL "realloc" USING
BY VALUE mem-pointer
BY VALUE mem-size
RETURNING mem-pointer
END-CALL

IF mem-pointer <> null
CALL "free" USING
BY VALUE mem-pointer
END-CALL
END-IF
References
[1] J. Whittaker and H. Thompson How to Break Software Security Addison Wesley
[2] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[3] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5
[4] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 2
[5] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[6] Standards Mapping - Common Weakness Enumeration CWE ID 401
[7] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001094
[8] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[9] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C Guidelines 2012 Rule 21.3
[10] Standards Mapping - Motor Industry Software Reliability Association (MISRA) C++ Guidelines 2008 Rule 18-4-1
[11] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-5 Denial of Service Protection (P1)
[12] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-5 Denial of Service Protection
[13] Standards Mapping - OWASP Top 10 2004 A9 Application Denial of Service
[14] Standards Mapping - OWASP Mobile Application Security Verification Standard 2.0 MASVS-STORAGE-2
[15] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.9
[16] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP6080 CAT II
[17] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP6080 CAT II
[18] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP6080 CAT II
[19] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP6080 CAT II
[20] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP6080 CAT II
[21] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP6080 CAT II
[22] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP6080 CAT II
[23] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002400 CAT II
[24] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002400 CAT II
[25] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002400 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002400 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002400 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002400 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002400 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002400 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002400 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002400 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002400 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002400 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002400 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002400 CAT II
[37] Standards Mapping - Web Application Security Consortium Version 2.00 Denial of Service (WASC-10)
[38] Standards Mapping - Web Application Security Consortium 24 + 2 Denial of Service
desc.controlflow.cobol.memory_leak_reallocation
Abstract
プログラムは潜在的に NULL ポインタを間接参照できるため、NullException を引き起こします。
Explanation
NULL ポインタエラーは通常、プログラマの想定が破られた結果として発生します。

NULL ポインタの問題点の大半は一般にソフトウェアの信頼性の問題をもたらします。しかし、攻撃者が意図的に NULL ポインタ間接参照を引き起こせる場合、その結果生じた例外を利用してセキュリティ ロジックを回避したり、アプリケーションにデバッグ情報を開示させてそれ以降の攻撃に役立てたりすることができます。

例 1: 次のコードでは、プログラマは、システムに常に「cmd」という名前の定義されたプロパティがあると前提しています。攻撃者がプログラムの環境を制御して「cmd」を未定義にできる場合、プログラムが Trim() メソッドのコールを試みると NULL ポインタ例外が発生します。


string cmd = null;
...
cmd = Environment.GetEnvironmentVariable("cmd");
cmd = cmd.Trim();
desc.controlflow.dotnet.null_dereference
Abstract
プログラムでは潜在的に NULL ポインタを間接参照する可能性があり、これがセグメンテーション違反の原因になります。
Explanation
NULL ポインタの例外は通常、プログラマの想定が破られた結果として発生します。この問題には、少なくとも次の 3 種類があります。間接参照後チェック、チェック後間接参照、格納後間接参照です。間接参照後チェックのエラーが発生するのは、プログラムで、ポインタが null であるかを確認する前に、null の可能性があるポインタを間接参照する場合です。チェック後間接参照のエラーが発生するのは、プログラムが null に対して明示的チェックを実行したにも関わらず、null であることが判明しているポインタを間接参照した場合です。この種のエラーの多くは、タイプミスかプログラマの不注意が原因です。格納後間接参照のエラーは、プログラムが明示的にポインタを null に設定し、後でそのポインタを間接参照した場合に発生します。このエラーは通常、変数の宣言時にプログラマがその変数を null に初期化したことが原因で発生します。

NULL ポインタの問題点の大半は一般にソフトウェアの信頼性の問題につながります。しかし、攻撃者が意図的に NULL ポインタ間接参照を引き起こせる場合、その結果生じた例外を利用してセキュリティ ロジックをバイパスすることで Denial of Service 攻撃を実装したり、アプリケーションにデバッグ情報を開示させてそれ以降の攻撃に役立てたりすることができます。

例 1: 次のコードでは、プログラマは変数 ptrNULL ではないと仮定してします。この仮定は、プログラマがポインタを間接参照したときに明らかになります。その後プログラマが ptrNULL を比較したときに、この仮定は成り立たなくなります。ptrif ステートメントでチェックされたときに NULL であるとすれば、間接参照されたときにも NULL である可能性があり、これがセグメンテーション違反の原因となる場合があります。


ptr->field = val;
...
if (ptr != NULL) {
...
}
例 2: 次のコードでは、プログラマは変数 ptrNULL であることを確認してから、続いてそれを誤って間接参照しています。ptrif ステートメントでチェックされたときに NULL になっていると、null Dereference が発生し、これがセグメンテーション違反の原因となります。


if (ptr == null) {
ptr->field = val;
...
}
例 3: 次のコードでは、プログラマが文字列 '\0' (実際は 0) または NULL を忘れたため、NULL ポインタを間接参照し、セグメンテーション違反を引き起こしています。


if (ptr == '\0') {
*ptr = val;
...
}
例 4: 次のコードでは、プログラマは明示的に変数 ptrNULL に設定しています。続いて、オブジェクトの null 値をチェックする前に ptr を間接参照しています。


*ptr = NULL;
...
ptr->field = val;
...
}
desc.controlflow.cpp.null_dereference
Abstract
プログラムは潜在的に NULL ポインタを間接参照できるため、NullPointerException を引き起こします。
Explanation
NULL ポインタエラーは通常、プログラマの想定が破られた結果として発生します。

NULL ポインタの問題点の大半は一般にソフトウェアの信頼性の問題をもたらします。しかし、攻撃者が意図的に NULL ポインタ間接参照を引き起こせる場合、その結果生じた例外を利用してセキュリティ ロジックを回避したり、アプリケーションにデバッグ情報を開示させてそれ以降の攻撃に役立てたりすることができます。

例: 次のコードでは、プログラマは、システムに常に「cmd」という名前の定義されたプロパティがあると前提しています。攻撃者がプログラムの環境を制御して「cmd」を未定義にできる場合、プログラムが trim() メソッドのコールを試みると NULL ポインタ例外が発生します。


String val = null;
...
cmd = System.getProperty("cmd");
if (cmd)
val = util.translateCommand(cmd);
...
cmd = val.trim();
desc.controlflow.java.null_dereference
Abstract
廃止予定あるいは廃止済みの関数が使用されていることは、無視されているコードがあることを示している場合があります。
Explanation
一般に、プログラミング言語の進化に伴い、以下の理由でメソッドが廃止されることがあります。

- 言語の進歩
- 操作の効率的で安全な実行方法に関する
理解の向上
- 特定の操作について定めた規則の変更

ある言語から削除されたステートメントは通常、より優れていると思われる別の方法で同じタスクを実行する新しい関数に置き換えられます。

特に、SAP ABAP は、ABAP Objects (ABAP のオブジェクト指向の拡張機能) を含み、Unicode 互換環境で動作するように発展したものです。その結果、クラスまたは Unicode プログラムでより厳密な構文が強制されます。古いリリースとの互換性のためだけに廃止済みのコンストラクトを現在でも使用でき、クラス外または Unicode 以外のプログラムでのみ使用できます。廃止済みのすべての言語要素のために代替コンストラクトがあり、プログラムの効率と読みやすさが向上します。廃止済みの構文内の暗黙的であいまいな多数のタイプ/長さ/メモリ仕様を、より正確で明示的な方法で新しい構文に指定する必要があります。プログラムをわかりやく、より堅牢で保守しやすくするために、新しい構文を採用することをお勧めします。


すべての関数がセキュリティリスクを招くという理由で廃止されたり、置き換えられたりするわけではありません。しかし多くの場合、廃止された関数があることは、その周辺のコードが無視されており、メンテナンスされていない状態であることを示します。ソフトウェアセキュリティは長い間、優先事項どころか検討事項ですらありませんでした。廃止予定または廃止済みの関数がプログラムで使用されていると、その周辺にセキュリティ上の問題がある可能性が浮上します。
desc.semantic.abap.obsolete
Abstract
廃止予定あるいは廃止済みの関数が使用されていることは、無視されているコードがあることを示している場合があります。
Explanation
プログラミング言語の進化に伴い、以下の理由で関数が廃止されることがあります。

- 言語の進歩
- 操作の効率的で安全な実行方法に関する
理解の向上
- 特定の操作について定めた規則の変更


ある言語から削除された関数は通常、より優れていると思われる別の方法で同じタスクを実行する新しい関数に置き換えられます。
例: 次のコードは、データベースへのユーザーの接続許可方法を規制する、新しい SqlClientPermission オブジェクトを構成します。この例のプログラムは、ユーザーがパスワードを空欄にして接続できるかどうかを制御するコンストラクタに false を 2 番目のパラメーターとして渡しています。このパスワードに False を渡すと、空欄のパスワードは許容されなくなります。


...
SCP = new SqlClientPermission(pstate, false);
...


ただし、最初のパラメーターとして渡される PermissionState オブジェクトが 2 番目のパラメーターとして渡されるあらゆる値より優先されるため、コンストラクタはパスワードを空欄にしてデータベースに接続することを許容し、2 番目の引数に反する事態が発生します。空欄のパスワードを拒否するには、プログラムがコンストラクタの最初のパラメーターに PermissionState.None を渡すようにします。誤った解釈を生む危険がなく同じ情報を伝達できる単一パラメーターのバージョンに比べた場合、このような機能的なあいまいさが存在しているため、パラメーターを 2 つ取るバージョンの SqlClientPermission コンストラクタの仕様は現在の状況には適当でないものとなっています。

すべての関数がセキュリティリスクを招くという理由で廃止されたり、置き換えられたりするわけではありません。しかし多くの場合、廃止された関数があることは、その周辺のコードが無視されており、メンテナンスされていない状態であることを示します。ソフトウェアセキュリティは長い間、優先事項どころか検討事項ですらありませんでした。廃止予定または廃止済みの関数がプログラムで使用されていると、その周辺にセキュリティ上の問題がある可能性が浮上します。
desc.semantic.dotnet.obsolete
Abstract
廃止予定あるいは廃止済みの関数が使用されていることは、無視されているコードがあることを示している場合があります。
Explanation
プログラミング言語の進化に伴い、以下の理由で関数が廃止されることがあります。

- 言語の進歩
- 操作の効率的で安全な実行方法に関する理解の向上
- 特定の操作について定めた規則の変更

削除された関数は通常、より優れていると思われる別の方法で同じタスクを実行する新しい関数に置き換えられます。
例: 次のコードは、旧式の関数 getpw() を使用して平文のパスワードが、暗号化されたユーザーパスワードと一致するかどうかを検証しています。パスワードが有効であれば、関数は result を 1 に、それ以外の場合は 0 にします。


...
getpw(uid, pwdline);
for (i=0; i<3; i++){
cryptpw=strtok(pwdline, ":");
pwdline=0;
}
result = strcmp(crypt(plainpw,cryptpw), cryptpw) == 0;
...


コードが正しく動作していても、セキュリティの面から getpw() 関数が問題になることがあります。これは、2 つ目のパラメーターに渡されたバッファがオーバーフローするためです。この脆弱性のために、getpw() は、getpw() と同じルックアップを実行しても、静的に割り当てられた構造体にポインタを戻す (リスクを緩和するため) getpwuid() に置き換えられてきました。

すべての関数がセキュリティリスクを招くという理由で廃止されたり、置き換えられたりするわけではありません。しかし多くの場合、廃止された関数があることは、その周辺のコードが無視されており、メンテナンスされていない状態であることを示します。ソフトウェアセキュリティは長い間、優先事項どころか検討事項ですらありませんでした。廃止予定または廃止済みの関数がプログラムで使用されていると、その周辺にセキュリティ上の問題がある可能性が浮上します。
desc.semantic.cpp.obsolete
Abstract
廃止予定または廃止済みの関数が使用されていることは、無視されているコードまたは ColdFusion の古いバージョンが使用されていることを示しています。
Explanation
プログラミング言語の進化に伴い、以下の理由でメソッドが廃止されることがあります。

- 言語の進歩
- 操作の効率的で安全な実行方法に関する
理解の向上
- 特定の操作について定めた規則の変更

ある言語から削除されたメソッドは通常、より優れていると思われる別の方法で同じタスクを実行する新しいメソッドに置き換えられます。


すべての関数がセキュリティリスクを招くという理由で廃止されたり、置き換えられたりするわけではありません。しかし多くの場合、廃止された関数があることは、その周辺のコードが無視されており、メンテナンスされていない状態であることを示します。ソフトウェアセキュリティは長い間、優先事項どころか検討事項ですらありませんでした。廃止予定または廃止済みの関数がプログラムで使用されていると、その周辺にセキュリティ上の問題がある可能性が浮上します。
desc.semantic.cfml.obsolete
Abstract
廃止予定あるいは廃止済みの関数が使用されていることは、無視されているコードがあることを示している場合があります。
Explanation
プログラミング言語の進化に伴い、以下の理由でメソッドが廃止されることがあります。

- 言語の進歩
- 操作の効率的で安全な実行方法に関する
理解の向上
- 特定の操作について定めた規則の変更

ある言語から削除されたメソッドは通常、より優れていると思われる別の方法で同じタスクを実行する新しいメソッドに置き換えられます。
例: 次のコードは、各 16 ビット Unicode 文字の最初の 8 ビットを指定する値とバイトの配列からストリングオブジェクトを構築します。


...
String name = new String(nameBytes, highByte);
...


この例では、nameBytes で表される文字列のエンコードにどの文字セットが使用されているかによって、コンストラクターがバイトを文字に正しく変換できない可能性があります。文字列のエンコードに使用される文字セットの進化により、このコンストラクターは非推奨となり、パラメーターの 1 つとして、変換のためにバイトをエンコードするために使用される、charset という名前のパラメーターを受け入れるコンストラクターに置き換えられました。

すべての関数がセキュリティリスクを招くという理由で廃止されたり、置き換えられたりするわけではありません。しかし多くの場合、廃止された関数があることは、その周辺のコードが無視されており、メンテナンスされていない状態であることを示します。ソフトウェアセキュリティは長い間、優先事項どころか検討事項ですらありませんでした。廃止予定または廃止済みの関数がプログラムで使用されていると、その周辺にセキュリティ上の問題がある可能性が浮上します。
References
[1] MET02-J. Do not use deprecated or obsolete classes or methods CERT
desc.semantic.java.obsolete
Abstract
廃止予定あるいは廃止済みの関数が使用されていることは、無視されているコードがあることを示している場合があります。
Explanation
プログラミング言語の進化に伴い、以下の理由でメソッドが廃止されることがあります。

- 言語の進歩
- 操作の効率的で安全な実行方法に関する
理解の向上
- 特定の操作について定めた規則の変更

ある言語から削除されたメソッドは通常、より優れていると思われる別の方法で同じタスクを実行する新しいメソッドに置き換えられます。
例: 次のコードは Digest::HMAC stdlib を使用しています。これはリリース内に誤って含まれたために、ドキュメントで明示的に使用を禁止しています。


require 'digest/hmac'

hmac = Digest::HMAC.new("foo", Digest::RMD160)
...
hmac.update(buf)
...


この例の Digest::HMAC クラスは、リリース内に誤って含まれたため、追加直後に廃止されています。実験的で適切にテストされていないコードであり、期待どおりに動作しない可能性があるため、特に HMAC の暗号化機能に関する関係を考慮すると、この使用を避けることを強くお勧めします。

すべての関数がセキュリティリスクを招くという理由で廃止されたり、置き換えられたりするわけではありません。しかし多くの場合、廃止された関数があることは、その周辺のコードが無視されており、メンテナンスされていない状態であることを示します。ソフトウェアセキュリティは長い間、優先事項どころか検討事項ですらありませんでした。廃止予定または廃止済みの関数がプログラムで使用されていると、その周辺にセキュリティ上の問題がある可能性が浮上します。
desc.structural.ruby.obsolete
Abstract
非推奨の関数が使用されています。
Explanation
スマート コントラクトは進化のペースが速いため、新しいコンパイラー バージョンでは関数や演算子が非推奨になる可能性があり、それらを使用するとコードの品質が低下したり、意図しない副作用やコンパイル エラーが発生したりする可能性があります。

例 1: 次のコードは、block.blockhash() を使用して現在のブロックのハッシュを取得します。これは、Solidity コンパイラーのバージョン 0.5.0 以降非推奨になりました。


bytes32 blockhash = block.blockhash(0);
desc.structural.solidity.swc111
Abstract
この関数は廃止済みであるため、ポインタが有効であることや、参照先メモリを使用しても安全であることは保証されません。
Explanation
関数の IsBadXXXPtr() クラスを使用すべきではない理由は多数あります。これらの関数には次のような特徴があります。
1) スレッドセーフではない。
2) 無効なメモリアドレスをプローブしたことによって引き起こされたクラッシュに関与していることが多い。
3) 例外状態の発生中に適切なエラー処理ができると勘違いされている。

例: 次のコードでは、不正なメモリ書き込みを防止するために IsBadWritePtr() が使用されています。

if (IsBadWritePtr(ptr, length))
{
[handle error]
}


多くの場合、プログラマは例外を検出しようとしてこれらの関数を使用しますが、実際には修正する問題よりも多くの問題の原因となっています。
References
[1] Raymond Chen IsBadXxxPtr should really be called CrashProgramRandomly
[2] IsBadWritePtr Function Microsoft
[3] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[4] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 2
[5] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[6] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[7] Standards Mapping - Common Weakness Enumeration CWE ID 730
[8] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-001094
[9] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-5 Denial of Service Protection (P1)
[10] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-5 Denial of Service Protection
[11] Standards Mapping - OWASP Top 10 2004 A9 Application Denial of Service
[12] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.9
[13] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP6080 CAT II
[14] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP6080 CAT II
[15] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP6080 CAT II
[16] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP6080 CAT II
[17] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP6080 CAT II
[18] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP6080 CAT II
[19] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP6080 CAT II
[20] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002400 CAT II
[21] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002400 CAT II
[22] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002400 CAT II
[23] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002400 CAT II
[24] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002400 CAT II
[25] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002400 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002400 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002400 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002400 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002400 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002400 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002400 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002400 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002400 CAT II
[34] Standards Mapping - Web Application Security Consortium Version 2.00 Denial of Service (WASC-10)
[35] Standards Mapping - Web Application Security Consortium 24 + 2 Denial of Service
desc.semantic.cpp.obsolete_inadequate_pointer_validation
Abstract
このクラスは同じ名前のフィールドとメソッドを含みます。
Explanation
同じ名前のメンバーフィールドとメソッドが存在していると混乱します。フィールドにアクセスする、またはその逆の場合に、プログラマが誤ってメソッドをコールしやすくなります。

例 1:

public class Totaller {
private int total;
public int total() {
...
}
}
References
[1] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[2] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5
[3] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[4] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[5] Standards Mapping - Common Weakness Enumeration CWE ID 398, CWE ID 710
[6] Standards Mapping - Smart Contract Weakness Classification SWC-119
desc.structural.java.poor_style_confusing_naming.member_and_method
Abstract
コントラクトが、曖昧で誤用されやすい、シャドウされた変数を使用しています。
Explanation
Solidity では、開発者は状態変数を曖昧に宣言できます。つまり、2 つの異なるコンテキストで 2 つの異なる変数を同じ名前で宣言することは可能ですが、それらを使用すると混乱や誤用につながる可能性があることを意味します。

これは、関数レベルと継承レベルの両方で発生する可能性があります。たとえば、Contract1 が var1 を宣言し、同じく var1 という名前の変数を宣言する Contract2 を継承すると、変数は曖昧となり、後でスマート コントラクトを実行する際に混同しやすくなります。

例 1: 次のコードは、継承を使用して、両方のスマート コントラクトで同じ名前の状態変数を宣言します。どれが実際のトークン セールの hardcap かを見極めるのは困難になる可能性があります。


contract Tokensale {
uint hardcap = 10000 ether;

function Tokensale() { }

function fetchCap() public constant returns(uint) {
return hardcap;
}
}

contract Presale is Tokensale {
uint hardcap = 1000 ether;

function Presale() Tokensale() { }
}
References
[1] Standards Mapping - CIS Azure Kubernetes Service Benchmark 1
[2] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 5
[3] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 1
[4] Standards Mapping - CIS Google Kubernetes Engine Benchmark normal
[5] Standards Mapping - Common Weakness Enumeration CWE ID 398, CWE ID 710
[6] Standards Mapping - Smart Contract Weakness Classification SWC-119
desc.structural.solidity.swc119