界: Input Validation and Representation

入力の検証や表現の問題は、メタキャラクター、代替エンコーディング、数値表現などによって引き起こされます。セキュリティの問題は、入力を信頼することに起因します。この問題に含まれるのは、「Buffer Overflow」、「Cross-Site Scripting」攻撃、「SQL Injection」などです。

Reflected File Download

Abstract
このアプリケーションは、信頼できるドメインを元にしているように見える任意のコンテンツを強制的にダウンロードさせる URL の作成を攻撃者に許可します。
Explanation
Reflected File Download (RFD) は、攻撃者が作成したフィッシング URL またはフィッシング ページにアクセスさせて、信頼できるドメインを元にしているように見える任意のコンテンツを含むファイルのダウンロードを開始するという脆弱性の 1 つです。ユーザーは対象のドメインを信頼しているため、ダウンロードしたファイルを開く可能性が高く、結果的に悪意のあるコードが実行されてしまいます。

攻撃者が RFD 攻撃を成功させるには、次の要件を満たす必要があります。
- ターゲット アプリケーションが、適切な検証またはエンコードなしでユーザー入力を反映している。これは、ペイロードを挿入するために使用されます。
- ターゲット アプリケーションが、許容的な URL を許可している。この結果、攻撃者が、ダウンロードされたファイルの名前と拡張子を操作する可能性があります。
- ターゲット アプリケーションの Content-Disposition ヘッダーの設定が間違っている。これにより、HTTP レスポンスの Content-Type ヘッダーと Content-Disposition ヘッダーまたはそのいずれかが攻撃者によって操作される可能性があるほか、ターゲット アプリケーションに、デフォルトではブラウザーにレンダリングされない Content-Type が含まれる場合があります。

たとえば、アプリケーションが Spring Web MVC ContentNegotiationManager を使用して、さまざまなレスポンス形式を動的に生成している場合、RFD 攻撃に必要な条件が整います。

ContentNegotiationManager は、リクエスト パス拡張に基づいてレスポンス形式を決定し、Java Activation Framework (JAF) を使用してクライアントが要求した形式により一致する Content-Type を探すように設定されます。また、リクエストの Accept ヘッダーで送信されるメディア タイプを介してレスポンス コンテンツ タイプを指定することをクライアントに許可します。

例 1: 次の例のアプリケーションは、パス拡張戦略と Java Activation Framework によってレスポンス コンテンツ タイプを決定するように設定されています。


<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="favorPathExtension" value="true" />
<property name="useJaf" value="true" />
</bean>
例 2: 次の例のアプリケーションは、リクエストの Accept ヘッダーによってレスポンス コンテンツ タイプを決定するように設定されています。


<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="ignoreAcceptHeader" value="false" />
</bean>


Spring 4.2.1 での ContentNegotiationManagerFactoryBean プロパティのデフォルト値は次のとおりです。

- useJaf: true
- favorPathExtension: true
- ignoreAcceptHeader: falseExample 1 の構成では、攻撃者が次のような悪意のある URL を作成することが可能です。

http://server/some/resource/endpoint/foo.bat?input=payload

ContentNegotiationManager は、Java Activation Framework (activity.jar がクラスパスにある場合) を使用して、指定したファイル拡張子についてメディア タイプを解決しようとし、それに合わせてレスポンスの ContentType ヘッダーを設定します。この例では、ファイル拡張子は "bat" で、Content-Type ヘッダーは application/x-msdownload です (正確な Content-Type は、サーバーの OS と JAF の設定によって異なります)。その結果、この悪意のある URL にアクセスした被害者のマシンは、攻撃者が操作したコンテンツを含む ".bat" ファイルのダウンロードを自動的に開始します。その後、このファイルが実行されると、被害者のマシンは攻撃者のペイロードで指定されたコマンドを実行します。
References
[1] Oren Hafif Reflected File Download - A New Web Attack Vector
[2] Alvaro Munoz Reflected File Download in Spring MVC
[3] Standards Mapping - Common Weakness Enumeration CWE ID 79, CWE ID 233
[4] Standards Mapping - Common Weakness Enumeration Top 25 2019 [2] CWE ID 079
[5] Standards Mapping - Common Weakness Enumeration Top 25 2020 [1] CWE ID 079
[6] Standards Mapping - Common Weakness Enumeration Top 25 2021 [2] CWE ID 079
[7] Standards Mapping - Common Weakness Enumeration Top 25 2022 [2] CWE ID 079
[8] Standards Mapping - Common Weakness Enumeration Top 25 2023 [2] CWE ID 079
[9] Standards Mapping - DISA Control Correlation Identifier Version 2 CCI-002754
[10] Standards Mapping - FIPS200 SI
[11] Standards Mapping - General Data Protection Regulation (GDPR) Indirect Access to Sensitive Data
[12] Standards Mapping - NIST Special Publication 800-53 Revision 4 SI-10 Information Input Validation (P1)
[13] Standards Mapping - NIST Special Publication 800-53 Revision 5 SI-10 Information Input Validation
[14] Standards Mapping - OWASP API 2023 API1 Broken Object Level Authorization
[15] Standards Mapping - OWASP Application Security Verification Standard 4.0 5.3.3 Output Encoding and Injection Prevention Requirements (L1 L2 L3), 5.3.6 Output Encoding and Injection Prevention Requirements (L1 L2 L3), 8.1.3 General Data Protection (L2 L3)
[16] Standards Mapping - OWASP Mobile 2014 M7 Client Side Injection
[17] Standards Mapping - OWASP Top 10 2004 A1 Unvalidated Input
[18] Standards Mapping - OWASP Top 10 2007 A2 Injection Flaws
[19] Standards Mapping - OWASP Top 10 2010 A1 Injection
[20] Standards Mapping - OWASP Top 10 2013 A1 Injection
[21] Standards Mapping - OWASP Top 10 2017 A1 Injection
[22] Standards Mapping - OWASP Top 10 2021 A03 Injection
[23] Standards Mapping - Payment Card Industry Data Security Standard Version 1.1 Requirement 6.5.4
[24] Standards Mapping - Payment Card Industry Data Security Standard Version 1.2 Requirement 6.3.1.1
[25] Standards Mapping - Payment Card Industry Data Security Standard Version 2.0 Requirement 6.5.6
[26] Standards Mapping - Payment Card Industry Data Security Standard Version 3.0 Requirement 6.5.6
[27] Standards Mapping - Payment Card Industry Data Security Standard Version 3.1 Requirement 6.5.6
[28] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2 Requirement 6.5.6
[29] Standards Mapping - Payment Card Industry Data Security Standard Version 3.2.1 Requirement 6.5.6
[30] Standards Mapping - Payment Card Industry Data Security Standard Version 4.0 Requirement 6.2.4
[31] Standards Mapping - Payment Card Industry Software Security Framework 1.0 Control Objective 4.2 - Critical Asset Protection
[32] Standards Mapping - Payment Card Industry Software Security Framework 1.1 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation
[33] Standards Mapping - Payment Card Industry Software Security Framework 1.2 Control Objective 4.2 - Critical Asset Protection, Control Objective B.3.1 - Terminal Software Attack Mitigation, Control Objective B.3.1.1 - Terminal Software Attack Mitigation, Control Objective C.3.2 - Web Software Attack Mitigation
[34] Standards Mapping - SANS Top 25 2009 Insecure Interaction - CWE ID 079
[35] Standards Mapping - SANS Top 25 2010 Insecure Interaction - CWE ID 079
[36] Standards Mapping - SANS Top 25 2011 Insecure Interaction - CWE ID 079
[37] Standards Mapping - Security Technical Implementation Guide Version 3.1 APP3510 CAT I
[38] Standards Mapping - Security Technical Implementation Guide Version 3.4 APP3510 CAT I
[39] Standards Mapping - Security Technical Implementation Guide Version 3.5 APP3510 CAT I
[40] Standards Mapping - Security Technical Implementation Guide Version 3.6 APP3510 CAT I
[41] Standards Mapping - Security Technical Implementation Guide Version 3.7 APP3510 CAT I
[42] Standards Mapping - Security Technical Implementation Guide Version 3.9 APP3510 CAT I
[43] Standards Mapping - Security Technical Implementation Guide Version 3.10 APP3510 CAT I
[44] Standards Mapping - Security Technical Implementation Guide Version 4.2 APSC-DV-002560 CAT I
[45] Standards Mapping - Security Technical Implementation Guide Version 4.3 APSC-DV-002560 CAT I
[46] Standards Mapping - Security Technical Implementation Guide Version 4.4 APSC-DV-002560 CAT I
[47] Standards Mapping - Security Technical Implementation Guide Version 4.5 APSC-DV-002560 CAT I
[48] Standards Mapping - Security Technical Implementation Guide Version 4.6 APSC-DV-002560 CAT I
[49] Standards Mapping - Security Technical Implementation Guide Version 4.7 APSC-DV-002560 CAT I
[50] Standards Mapping - Security Technical Implementation Guide Version 4.8 APSC-DV-002560 CAT I
[51] Standards Mapping - Security Technical Implementation Guide Version 4.9 APSC-DV-002560 CAT I
[52] Standards Mapping - Security Technical Implementation Guide Version 4.10 APSC-DV-002560 CAT I
[53] Standards Mapping - Security Technical Implementation Guide Version 4.11 APSC-DV-002560 CAT I
[54] Standards Mapping - Security Technical Implementation Guide Version 4.1 APSC-DV-002560 CAT I
[55] Standards Mapping - Security Technical Implementation Guide Version 5.1 APSC-DV-002560 CAT I
[56] Standards Mapping - Security Technical Implementation Guide Version 5.2 APSC-DV-002560 CAT I
[57] Standards Mapping - Security Technical Implementation Guide Version 5.3 APSC-DV-002530 CAT II, APSC-DV-002560 CAT I
[58] Standards Mapping - Web Application Security Consortium Version 2.00 Improper Input Handling (WASC-20)
desc.config.java.reflected_file_download