Skip to content

Commit

Permalink
Don't repeat query of target URI in error response (akka#2397)
Browse files Browse the repository at this point in the history
Removed raw query from error message, because including it can facilitate injection attacks such as cross-site scripting (XSS).
  • Loading branch information
cornelisdemooij authored and jrudolph committed Mar 5, 2019
1 parent ae0720d commit a478e4a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void testStringParameterExtraction() {
route
.run(HttpRequest.create().withUri("/abc?stringParam=a%b"))
.assertStatusCode(400)
.assertEntity("The request content was malformed:\nThe request's query string is invalid: stringParam=a%b");
.assertEntity("The request content was malformed:\nThe request's query string is invalid.");

route
.run(HttpRequest.create().withUri("/abc?stringParam=a=b"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ParameterDirectivesSpec extends FreeSpec with GenericRoutingSpec with Insi
parameter("amount".as[Int].?) { echoComplete }
} ~> check {
inside(rejection) {
case MalformedRequestContentRejection("The request's query string is invalid: amount=1%2", _)
case MalformedRequestContentRejection("The request's query string is invalid.", _)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ object ParameterDirectives extends ParameterDirectives {
import ctx.materializer
Try(ctx.request.uri.query()) match {
case Success(query) handleParamResult(paramName, fsou(query.get(paramName)))
case Failure(t) reject(MalformedRequestContentRejection(s"The request's query string is invalid: ${ctx.request.uri.rawQueryString.getOrElse("")}", t))
case Failure(t) reject(MalformedRequestContentRejection("The request's query string is invalid.", t))
}
}
implicit def forString(implicit fsu: FSU[String]): ParamDefAux[String, Directive1[String]] =
Expand Down

0 comments on commit a478e4a

Please sign in to comment.