輸入驗證和表示法問題是由中繼字元、替代編碼和數值表示法引起的。信任輸入會導致安全問題。問題包括:「Buffer Overflows」、「Cross-Site Scripting」攻擊、「SQL Injection」及其他許多問題。
Content-Disposition
表頭設定錯誤,從而讓攻擊者可控制 HTTP 回應中的 Content-Type
和/或 Content-Disposition
表頭,或者目標應用程式所包含的 Content-Type
預設並非在瀏覽器中轉譯。ContentNegotiationManager
來動態產生不同的回應格式,則滿足使 RFD 攻擊成為可能所需的條件。ContentNegotiationManager
設定為根據要求路徑副檔名來決定回應格式,並使用 Java Activation Framework (JAF) 尋找更為符合用戶端所要求之格式的 Content-Type
。它還允許用戶端透過在要求的 Accept
表頭中傳送的媒體類型來指定回應內容類型。範例 2:在以下範例中,應用程式設定為允許要求的
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="favorPathExtension" value="true" />
<property name="useJaf" value="true" />
</bean>
Accept
表頭來決定回應的內容類型:
<bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="ignoreAcceptHeader" value="false" />
</bean>
ContentNegotiationManagerFactoryBean
屬性預設值如下:useJaf
:true
favorPathExtension
:true
ignoreAcceptHeader
:false
Example 1
中所顯示的配置可讓攻擊者製作惡意 URL,如:ContentNegotiationManager
使用 Java Activation Framework (如果在類別路徑中找到 activation.jar) 嘗試解析指定副檔名的媒體類型,並相應設定回應的 ContentType
表頭。此範例中的副檔名為「.bat」,從而產生 application/x-msdownload
的 Content-Type
表頭 (儘管確切的 Content-Type
可能依據伺服器 OS 和 JAF 組態而有所不同)。因此,一旦受害者造訪此惡意 URL,他/她的機器便會自動開始下載包含攻擊者控制內容的「.bat」檔案。如果隨後執行此檔案,受害者機器便會執行攻擊者承載所指定的任意指令。
...
PageReference ref = ApexPages.currentPage();
Map<String,String> params = ref.getParameters();
HttpRequest req = new HttpRequest();
req.setEndpoint(params.get('url'));
HTTPResponse res = new Http().send(req);
http
或 https
的通訊協定,例如:
string url = Request.Form["url"];
HttpClient client = new HttpClient();
HttpResponseMessage response = await client.GetAsync(url);
http
或 https
的通訊協定,例如:
char *url = maliciousInput();
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url);
CURLcode res = curl_easy_perform(curl);
http
或 https
的通訊協定,例如:
...
final server = await HttpServer.bind('localhost', 18081);
server.listen((request) async {
final headers = request.headers;
final url = headers.value('url');
final client = IOClient();
final response = await client.get(Uri.parse(url!));
...
}
http
或 https
的通訊協定,例如:
url := request.Form.Get("url")
res, err =: http.Get(url)
...
http
或 https
的通訊協定,例如:
String url = request.getParameter("url");
CloseableHttpClient httpclient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(url);
CloseableHttpResponse response1 = httpclient.execute(httpGet);
http
或 https
的通訊協定,例如:
var http = require('http');
var url = require('url');
function listener(request, response){
var request_url = url.parse(request.url, true)['query']['url'];
http.request(request_url)
...
}
...
http.createServer(listener).listen(8080);
...
http
或 https
的通訊協定,例如:
val url: String = request.getParameter("url")
val httpclient: CloseableHttpClient = HttpClients.createDefault()
val httpGet = HttpGet(url)
val response1: CloseableHttpResponse = httpclient.execute(httpGet)
http
或 https
的通訊協定,例如:
$url = $_GET['url'];
$c = curl_init();
curl_setopt($c, CURLOPT_POST, 0);
curl_setopt($c,CURLOPT_URL,$url);
$response=curl_exec($c);
curl_close($c);
http
或 https
的通訊協定,例如:
url = request.GET['url']
handle = urllib.urlopen(url)
http
或 https
的通訊協定,例如:
url = req['url']
Net::HTTP.get(url)
http
或 https
的通訊協定,例如:
def getFile(url: String) = Action { request =>
...
val url = request.body.asText.getOrElse("http://google.com")
ws.url(url).get().map { response =>
Ok(s"Request sent to $url")
}
...
}
http
或 https
的通訊協定,例如: