1

While checking for findSpecBugs warnings in my scala based application, I encountered:

HTTP Parameter Pollution warning with the message: Concatenating unvalidated user input into a URL can allow an attacker to override the value of a request parameter.

This issue is arising when I am concatenating a URL with a value fetched from the database. Any idea how can I sanitize or validate that value, or is there any other way to resolve this issue?

himanshuIIITian
  • 5,985
  • 6
  • 50
  • 70
  • 4
    Does this answer your question? [Java URL encoding of query string parameters](https://stackoverflow.com/questions/10786042/java-url-encoding-of-query-string-parameters) – Joe Jun 16 '20 at 10:57
  • 1
    Thanks @Joe, this lowered the level of warning to low, but has not removed it completely. – Mansi Babbar Jun 16 '20 at 11:25

1 Answers1

2

You should use URIBuilder and set the setParameter(<param>, <value>). Like the following:

val builder = new URIBuilder(<url>)
    builder.setParameter("pparam1", "value1").setParameter("param2", "value2")
val request = new HttpGet(builder.build())

I hope this answers your question.

himanshuIIITian
  • 5,985
  • 6
  • 50
  • 70