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 7061927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:31:59+00:00 2026-05-28T04:31:59+00:00

I was checking my script for vulnerabilities and was shocked the way i used

  • 0

I was checking my script for vulnerabilities and was shocked the way i used to do in the past which is extremely insecure:

foreach ($_GET as $key => $value){
    $$key = $value;
}

or shorter

extract( $_GET );

I altered with firebug some POST/GET variables to match a name i used in my script. they can be overwritten if the name would be guessed correctly.

So i thought i had to do it individually naming like this:
$allowed_vars =

$allowed_vars = array("time","hotfile","netload","megaupload","user","pfda","xyz","sara","amount_needed");
    foreach ($_GET as $key => $value)
        {
             if (in_array($key,$allowed_vars))
                {
                    $$key = $value;
                }
        }

This way saves some time than naming them individually.

What kind of automation have to be used for this?

  • 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-05-28T04:31:59+00:00Added an answer on May 28, 2026 at 4:31 am

    I don’t use any automatism of the kind.
    I see no point in assigning request variables to global variables automatically.
    If it’s one or two variables, I could deal with them manually.
    If there are more, I’d rather keep them as array members for the convenient handling.

    Yet I am using some sort of whitelisting approach similar to yours.
    but not to create global variables out of POST data but to add that data into SQL query.

    Like in this simple helper function to produce SET statement:

    function dbSet($fields) {
      $set='';
      foreach ($fields as $field) {
        if (isset($_POST[$field])) {
          $set.="`$field`='".mysql_real_escape_string($_POST[$field])."', ";
        }
      }
      return substr($set, 0, -2); 
    }
    
    $id     = intval($_POST['id']);
    $fields = explode(" ","name surname lastname address zip fax phone");
    $query  = "UPDATE $table SET ".dbSet($fields)." stamp=NOW() WHERE id=$id";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building a testing script which is checking the performance of a set
Does anyone know of a way of checking within PHP if the script is
I made little jquery script for checking if input box value bigger than 5
I am using syntax checking to see whether my Perl script is being used
Basically I want to run a script checking for the existence of a certain
Im using the Google pagerank checking script found here: http://www.off-soft.net/en/develop/php/prcheck.html I've noticed however that
On a unix machine, how can I write a shell script for checking if
I have a python script that'll be checking a queue and performing an action
I have written a small bash script called isinFile.sh for checking if the first
Currently I have a perl script that runs forever on my server, checking a

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.