Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Any security holes?

by haj (Priest)
on Jun 26, 2022 at 15:48 UTC ( #11145087=note: print w/replies, xml ) Need Help??

in reply to Any security holes?

Oh, among other issues, there are security concerns with this code.

  • First, the handling of @pairs and $buffer seems to be a leftover from some pre-CGI variation, the %FORM hash is not used in the rest of the code.
  • Your code is just appending stuff to the drivers.html file, so this file will probably never be correct HTML - the closing elements are missing.
  • As already written by LanX: You accept anything your script gets as parameters and write it to the file. As a harmless example, let a user provide nick=<div style="display:none">. Whatever this user, and all subsequent users, add to the file, will be invisible - until another request happens to close the div element. This is called HTML injection.
  • With HTML injection, users can also inject script elements, introducing JavaScript code which is then executed in the context of the browser of whoever visits the script. This code could make use of the fact that another user is logged in in a forum site like PerlMonks, and then let that other user's browser write an article to the forum. The user doesn't even notice what the browser does.
  • If said script ends with reloading the same page again, then your users are in an endless loop and sooner or later your web server will break.

You should be aware that the URL leading to your script doesn't need to be called by a browser. A malicious user could easily use LWP::UserAgent or a similar module to feed any complicated stuff into your script.

And yes, all these things have happened a lot of times. The OWASP top ten always lists "Injection" as a prominent security risk.

As a minimum security guard you should prevent user-provided HTML from being processed by the browser by using HTML::Entities or HTML::Escape to encode unsafe characters.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11145087]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2023-03-28 05:25 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (66 votes). Check out past polls.