Tag Info

New answers tagged


If the signature parameter is based on user input, it may be possible for a user to insert an & in it and break this functionality. I don't see how this could be exploited, however the best practice is to sanitize the value of parameters affected by user input.


The ampersand character is used to separate arguments supplied to the url when multiple argments are used. In your first example the script receives the following arguments signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxx url=http%3A%2F%google.com%2F In your second example the script receives the following arguments: signature=xxxxxxxxxxxxxxxxxxxxxxxxxxxx ...


I worked on this problem for an email scanning system, and can say that the lexical properties of URLs for maliciousness are minimal, especially with the constraints you are imposing. It's true that malicious URLs often "Look random", but that's because your experience has transformed "imgur.com/gallery/lBKRZ" into "harmless image server gallery", but ...


I would go with the second approach (HTTP_HOST is user controlled, but it doesn't matter in this case). It's the easiest to use, and it's pretty much impossible to mess up. The first and third approach are harder to use from the calling code (not a security issue, but still bad), and they can also be wrongly used by the calling code (the third one a lot ...

Top 50 recent answers are included