if they can get into your server and read your scripts and have any kind of write access (either to modify the scripts or to put their own on the server), you're screwed. nothing you can do.

what we usually worry about is if someone manages to maybe exploit some other script or the webserver is misconfigured and they manage to view the source code of your script. if you've got your passwords hard coded into the script, they'll see them and be able to log into your database and break stuff.

the simple solution is to put your db username/password stuff in a config file and put it outside the webserver's document root.

you could probably come up with a more complicated solution using ssh with public key authentication and port forwarding with the secret key stored in memory and not on disk that would let you set things up so that the user that the webserver runs as could log into the db without a password (and hence it doesn't have to be stored on disk) but that would probably be more trouble than its worth and potentially require that someone is there to enter the password at startup, etc.

anders pearson


In reply to Re: Protecting your DBI user/password in scripts? by thraxil
in thread Protecting your DBI user/password in scripts? by JPaul

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.