2010-11-01 7 views
21

Bất cứ khi nào một URL có %2F là mã hex cho / được đăng tải để JBOSS máy chủ của tôi, tôi nhận được một lỗi:Nhận HTTP 400 lỗi nếu% 2F là một phần của URL GET trong JBOSS

HTTP 400 Bad Request error message. 

đây là URL:

http://localhost:8080/application/**abc%2Fhi**?msg=hello" 

Nếu tôi loại bỏ các %2F từ URL vào liên kết hoạt động tốt.

Điều này %2F phải là một phần của URL và không thể là thông số yêu cầu.

+0

Đây có phải là chỉ là một vấn đề với '% 2F' hoặc cũng có khác'% xx'-es? Hãy thử, ví dụ, '% 7A' hoặc một cái gì đó ... –

+0

Nhìn vào nhật ký lỗi để biết thêm chi tiết –

+0

Vấn đề chỉ với% 2F không cho% xx –

Trả lời

53

Cuối cùng đã tìm ra nguyên nhân của việc này (cả cho JBoss và Apache). Cả hai ứng dụng đều cố ý từ chối URI bằng dấu gạch chéo được mã hóa (%2F cho /%5C cho \) để ngăn chặn các lỗ hổng bảo mật có thể xảy ra.

Links:

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-0450

http://securitytracker.com/id/1018110 (Nhìn vào phần 4. Giải pháp)

Và đây là hướng dẫn họ cung cấp cho phép hành vi này trong JBoss:

Note: In response to CVE-2007-0450, JBoss AS considers encoded slashes and backslashes in URLs invalid and its usage will result in HTTP 400 error. It is possible to allow encoded slashes and backslashes by following the steps outlined below, however doing so will expose you to CVE-2007-0450 related attacks:

a) If you use the /var/lib/jbossas/bin/run.sh setup, please edit /etc/jbossas/run.conf and append

- -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true

- -Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true to the string assigned to JAVA_OPTS

b) If you use the init script setup to run multiple JBoss AS services and you wish to allow encoding by default on all services, please edit /etc/jbossas/jbossas.conf and add the line JAVA_OPTS="${JAVA_OPTS}

- -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true

- -Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true"

c) If you use the init script setup to run multiple JBoss AS services and want to allow encoding of slashes and backslashes for a particular service, please edit /etc/sysconfig/${NAME} (where NAME is the name of your service) and add the line JAVA_OPTS="${JAVA_OPTS} - -Dorg.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH=true - -Dorg.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH=true"

Đối Apache, nó đơn giản như thiết lập "AllowEncodedSlashes NoDecode" một nơi nào đó trong conf confache của bạn hoặc conf conf (không hoạt động i n .htaccess, tuy nhiên).

Apache liên kết: http://httpd.apache.org/docs/current/mod/core.html#allowencodedslashes

+0

Cảm ơn mehaase cho bạn phân tích chi tiết và giải pháp. –

+0

thx Mehaase cho lời giải thích tuyệt vời ... – swati