Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986

Tags:

tomcat

java.lang.IllegalArgumentException: 
Invalid character found in the request target. 
The valid characters are defined in RFC 7230 and RFC 3986

This exception is caused by passing Chinese words in Get URLs. How can I resolve this issue in tomcat ?

We don't want to reduce the Tomcat version and ask our customer to encode the parameters.

Is there a way to fix this issue by changing configurations in tomcat ?

like image 244
Raw Avatar asked Feb 07 '18 03:02

Raw


People also ask

What are the valid characters for illegalargumentexception?

The valid characters are defined in RFC 7230 and RFC 3986 #12652 java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986 @fendo8888 That's not enough information to go on.

What are the valid and invalid characters?

The valid characters are defined in RFC 7230 and RFC 3986 #635 Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986 #635

What is illegalargumentexception in Java?

java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986 Since the location had characters which are not recognized. I.e. "C:///" etc, the error was thrown.

What does invalid character found in the request target mean?

The error message says "Invalid character found in the request target". This means the HTTP client sent a request for a resource that had an invalid characters in it. The server can not parse the request because the request did not adhere to the HTTP protocol specifications. This is a client problem.


1 Answers

There is no way to fix this in Tomcat. The requests are not specification compliant so Tomcat will not permit them. There is a long history of security issues around different components in a system reacting differently to such URLs. Usually in the form of header and/or request injection. As a result, Tomcat's URL parsing has been tightened up and it is extremely unlikely it will be relaxed.

httpd is heading in the same direction for the same reasons.

The best long term option is to point out to the clients that the requests they are sending are not specification compliant and that they need to fix them (by using appropriate %nn encoding). On the Tomcat side, make sure Tomcat is using UTF-8. That is the default on newer versions. You might need to explicitly set it on older releases.

like image 105
Mark Thomas Avatar answered Sep 22 '22 13:09

Mark Thomas