界: API Abuse

API は、呼び出し元と呼び出し先の間のコントラクトです。最も一般的な API の不正使用の形態は、呼び出し元がこのコントラクトの終わりを守らないことによって発生します。たとえば、プログラムが chroot() を呼び出した後に chdir() を呼び出すのに失敗すると、アクティブなルート ディレクトリを安全に変更する方法を指定したコントラクトに違反することになります。ライブラリの悪用のもう 1 つの良い例は、呼び出し先が信頼できる DNS 情報を呼び出し元に返すことを期待することです。この場合、呼び出し元は、呼び出し先の API の動作 (戻り値が認証目的に使用できること) についてある種の仮定をすることで、呼び出し先の API を悪用します。また、相手側から、呼び出し元と呼び出し先のコントラクトを違反することもできます。例えば、コーダーが SecureRandom をサブクラス化し、ランダムではない値を返した場合、コントラクトに違反することになります。

ASP.NET MVC Bad Practices: Model With Optional and Required Properties

Abstract
モデルクラスには必要なプロパティと必要でないプロパティがあるため、over-posting 攻撃の影響を受けやすいと考えられます。
Explanation
必要な ([Required] 属性でマークされた) プロパティとオプションの ([Required] 属性でマークされていない) プロパティを持つモデルクラスは、攻撃者が想定以上のデータを含む要求を送信した場合に問題を引き起こす可能性があります。

ASP.NET MVC フレームワークは、リクエストパラメータをモデルのプロパティにバインドしようとします。

モデルバインドを行うパラメーターを明示的に通知せず、必要度が混在している場合、内部用のモデルプロパティがあるけれども、攻撃者による制御が可能であることを示す場合があります。

次のコードで定義されるモデルクラス例には、[Required] を含むプロパティと [Required] を含まないプロパティがあります。


public class MyModel
{
[Required]
public String UserName { get; set; }

[Required]
public String Password { get; set; }

public Boolean IsAdmin { get; set; }
}


オプションのパラメーターによってアプリケーションの挙動が変わる場合は、攻撃者はオプションのパラメーターをリクエストで送信することにより実際にその挙動を変えることができます。
References
[1] Input Validation vs. Model Validation in ASP.NET MVC
[2] BindAttribute Class
[3] RequiredAttribute Class
[4] Standards Mapping - CIS Azure Kubernetes Service Benchmark 3
[5] Standards Mapping - CIS Microsoft Azure Foundations Benchmark complete
[6] Standards Mapping - CIS Amazon Elastic Kubernetes Service Benchmark 4
[7] Standards Mapping - CIS Amazon Web Services Foundations Benchmark 3
[8] Standards Mapping - CIS Google Kubernetes Engine Benchmark integrity
[9] Standards Mapping - CIS Kubernetes Benchmark partial
[10] Standards Mapping - Common Weakness Enumeration CWE ID 345
[11] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-002422
[12] Standards Mapping - NIST Special Publication 800-53 Revision 4 SC-8 Transmission Confidentiality and Integrity (P1)
[13] Standards Mapping - NIST Special Publication 800-53 Revision 5 SC-8 Transmission Confidentiality and Integrity
[14] Standards Mapping - OWASP Top 10 2004 A1 Unvalidated Input
[15] Standards Mapping - OWASP Top 10 2007 A2 Injection Flaws
[16] Standards Mapping - OWASP Top 10 2010 A1 Injection
[17] Standards Mapping - OWASP Top 10 2013 A1 Injection
[18] Standards Mapping - OWASP Top 10 2017 A1 Injection
[19] Standards Mapping - OWASP Top 10 2021 A03 Injection
[20] Standards Mapping - OWASP API 2023 API3 Broken Object Property Level Authorization
[21] Standards Mapping - OWASP Application Security Verification Standard 4.0 3.5.3 Token-based Session Management (L2 L3), 13.2.6 RESTful Web Service Verification Requirements (L2 L3)
[22] Standards Mapping - OWASP Mobile 2014 M1 Weak Server Side Controls
[23] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.6
[24] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002470 CAT II
[25] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002470 CAT II
[26] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002470 CAT II
[27] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002470 CAT II
[28] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002470 CAT II
[29] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002470 CAT II
[30] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002470 CAT II
[31] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002470 CAT II
[32] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002470 CAT II
[33] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002470 CAT II
[34] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002470 CAT II
[35] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002470 CAT II
[36] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002470 CAT II
[37] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002470 CAT II
[38] Standards Mapping - Web Application Security Consortium Version 2.00 Improper Input Handling (WASC-20)
desc.structural.dotnet.aspnet_mvc_bad_practices_mixed_required_model