Description
The documentation for querystring.unescape()
says:
By default, the querystring.unescape() method will attempt to use the JavaScript built-in decodeURIComponent() method to decode. If that fails, a safer equivalent that does not throw on malformed URLs will be used.
Accepting invalid input usually makes software less safe, not more. Example: In hapijs/hapi#3422 data that is not URL encoded is passed to an application that should accept only url-encoded data (application/x-www-form-urlencoded
), leading to a failing test. Quote myself:
Every piece of software that takes input contains a de facto recognizer for accepting valid input and rejecting invalid input. Parser differentials – when two programs parse things differently, one accepting data and another rejecting it – silently invalidate assumptions programmers have about data safety and can lead to security issues. I think a good example of what this can result in is the Android master key vulnerability.
For more information why accepting invalid input is a bad idea, read The Seven Turrets of Babel and other LANGSEC papers.
I suggest to not catch the exception thrown in querystring.unescape()
so that Hapi can return a 400 Bad Request
.
- Version: v.6.9.1
- Platform: Linux unknown-device 4.7.0-1-amd64 deps: update openssl to 1.0.1j #1 SMP Debian 4.7.2-1 (2016-08-28) x86_64 GNU/Linux
- Subsystem: