Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8479475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:02:09+00:00 2026-06-10T19:02:09+00:00

I’m usually pretty resourceful about finding information on my own, but when it comes

  • 0

I’m usually pretty resourceful about finding information on my own, but when it comes to this subject, it’s really daunting the sheer amount of stuff there is out there. I’m getting a bit of information overload.

I’ve found dozens of articles on individual security topics, but I can’t get a sense of the bigger picture and how it all comes together in practice.

I need to see a bird’s-eye roadmap. Take this hypothetical example:

A Simple Hypothetical "Comments" Section:

  • Sign up: create a password/username combo that is to be stored safely in a MySQL table.

  • Log in.

  • Leave a comment.

What would be a "security roadmap" to follow on this most basic case?

It doesn’t help that every tutorial and PHP book on the planet uses the MySQL extensions, which, if I understand correctly, is a bad idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:02:11+00:00Added an answer on June 10, 2026 at 7:02 pm

    A. In general…

    1. I’m assuming here that the programmer is not also the server administrator, and that the server admin more or less knows how to configure LAMP correctly and securely by default.

      Of course, if necessary, a programmer can override most PHP settings in a custom php.ini file located in the web root.

    2. Use an MVC framework.

      I use CakePHP. The framework itself goes a long way to ensure fundamentally sound and secure coding practices.

    B. Incoming data…

    1. Sanitize and validate all data contained in $_GET, $_POST, $_COOKIE, and $_REQUEST before programmatically manipulating the data.

    2. SQL Injection

      Definition: Code injection technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed.

      Prevention: Parameterised queries using a library such as mysqli or PDO. See the OWASP SQL Injection cheat sheet (string escaping functions like mysql_real_escape_string are not recommended)

    3. Cross Site Scripting (XSS)

      Definition: Security vulnerability typically found in web applications that allows code injection by malicious web users into the web pages viewed by other users. Examples of such code include client-side scripts (i.e., JavaScript).

      Prevention: Context-dependent output escaping and encoding. See the OWASP XSS prevention cheat sheet.

    C. Browser requests…

    1. Cross Site Request Forgery (CSRF)

      Definition: Type of malicious exploit of a website whereby unauthorized commands are transmitted from a user that the website trusts. Unlike cross-site scripting (XSS), which exploits the trust a user has for a particular site, CSRF exploits the trust that a site has in a user’s browser.

      Prevention: Generate a unique “token”, typically when a browser session starts. Pass the token in all POST and GET requests. Following the POST/GET action, check for the existence of the token in the session and then confirm the token sent by POST/GET is identical to the token stored in the session. (An MVC framework like CakePHP makes this relatively easy to implement uniformly throughout your application.)

    D. Sessions…

    1. Destroy session data when killing a session

      After a session is complete (”logout”), destroy its data and don’t just clear the cookie (a malicious user could otherwise just re-instate the cookie and use the session again). Unset all indexes in $_SESSION by assigning it to an empty array.

    2. Store sessions as files above the web root or in a database

      The default path for saving sessions on the server can be hijacked — especially in a shared hosting environment.

    E. Passwords…

    1. Enforce the selection of strong passwords

      • Require numbers, symbols, upper and lowercase letters in passwords

      • Password length should be around 12 to 14 characters

    2. Hash and Salt all passwords

      Do not use sha1(), md5() or hash() to hash passwords. They’re not designed for this. You will want to use a function like bcrypt or PBDFK2. There’s some really good suggestions on this question. Your salt value should be completely random, and stored in the database (it’s not really a secret). An additional secret value (generally called “pepper”) can be stored in your application and prepended to passwords before using bcrypt, but it’s not clear how much security this really adds.

    F. In a custom php.ini located in web root…

    1. Disable register_globals

      Prevention: register_globals = Off

    2. Disable magic quotes

      Prevention: magic_quotes_gpc = Off

    3. Disable error reporting

      Prevention: display_errors = Off

    4. Enable error logging and save log file to a directory above web root

      Prevention:

      log_errors = On; 
      ignore_repeated_errors = On; 
      html_errors = Off; 
      error_log = /path/above/webroot/logs/php_error_log
      
    5. Store session data inside a directory above web root

      Prevention: session.save_path = /path/above/webroot/sessions

    G. In a .htaccess file located in web root…

    1. Disable directory listings site-wide

      Prevention: Options -Indexes

    H. Valuable/Sensitive files…

    1. Prevent unauthorized access/downloads by storing such files above the web root

      This includes site administration/members-only sections and site/database configuration files!!

    2. Use an intermediary script to serve the files inline or as an attachment

    3. Keep your scripts(WordPress, PHPMyAdmin, etc.) updated.

    4. Only allow access to PHPMyAdmin when you are using it. This prevents people from being able to use zero-day exploits on your install.

    I. Uploaded files…

    1. Validate file name stored in $_FILES before using it for any kind of data manipulation

    2. Be aware that the provided mime type can be spoofed or otherwise wrong

    3. Move all user-uploaded files to a directory above web root!!!

    4. Don’t execute/serve uploaded files with include()

    5. Try to not serve files with content types of “application/octet-stream,” “application/unknown,” or “plain/text”

    J. Misc…

    1. All “utility” files/programs in the web root created and used by the developer during the development of a site/application, that are not intended or required to be accessed by future site users, or otherwise pose some kind of security risk, should be removed when the site goes live.

      For example, this includes a phpinfo.php file (a files that prints the results of phpinfo()), database utility scripts, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.