can list() in while loop, while printing things to a screen, somehow affect the values in an array?

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Re: can list() in while loop, while printing things to a screen, somehow affect the values in an array?

    lawrence wrote:
    <snip>
    > stamp.) (The host I'm on is running PHP 4.06, which I why I can't use
    > $_COOKIE).
    > $choiceMade = $_GET["choiceMade"];
    > if ($choiceMade) {
    > reset($HTTP_COOKIE_VARS);

    I'm not going to spend all my time analyzing this, as you obviously have
    multiple other functions and objects not shown, BUT, I will point this out -
    if you're having wierd problems with choiceMade, it's probably because of
    this above. You say that the server is PHP 4.0.6, then $choiceMade =
    $_GET['choiceMade'] is not going to work... $choiceMade will not get the
    value you want (unless you are actually manually constructing $_GET
    somewhere...). Give it a shot with $choiceMade =
    $HTTP_GET_VARS['choiceMade']; and see if that solves anything.

    // Ian Fette
    // Proponent comp.lang.php


    Agelmar Guest

  2. Similar Questions and Discussions

    1. loop through array to build a new array
      If I combine the following 2 functions (accesses by clicking a checkbox), as result the new array does not contains all items that matches the...
    2. cannot loop the array
      I have 2 questions regarding arrays: 1) we need to define the size of the array, there is no dynamic array concept? i.e. the following define the...
    3. Insert Loop values into DB Problem
      :confused; How do I call the loop when inserting the values into my DB? I am getting an error message. Here is the Insert Statement: ...
    4. Populating an array with a list of values
      I have performed a cfhttp request, the results of which are in a variable called FoundString. Found String consists of a list of website links, I...
    5. array data matches but array created in loop doesn't work
      I have the exact same data in two arrays, but only the array created like so will work: $spaw_imglibs = array( array( 'value' =>...
  3. #2

    Default Re: can list() in while loop, while printing things to a screen, somehow affect the values in an array?

    On Sat, 12 Jul 2003 19:21:32 GMT, "Jason" <jsumner1@cfl.rr.com> wrote:
    >Try choiceMade() and not $choiceMade(). "$" is for variables.
    He's doing a variable function call.

    (Which is sheer lunacy from a form variable, but valid syntax nonetheless).

    --
    Andy Hassall (andy@andyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage analysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  4. #3

    Default Re: can list() in while loop, while printing things to a screen, somehow affect the values in an array?

    Andy Hassall <andy@andyh.co.uk> wrote in message news:<iao0hvo5334e94v10bks47dte5s8ofrqej@4ax.com>. ..
    > On Sat, 12 Jul 2003 19:21:32 GMT, "Jason" <jsumner1@cfl.rr.com> wrote:
    >
    > >Try choiceMade() and not $choiceMade(). "$" is for variables.
    >
    > He's doing a variable function call.
    >
    > (Which is sheer lunacy from a form variable, but valid syntax nonetheless).
    Sheer lunacy from a security standpoint I assume. Which is why every
    one of my functions starts with:

    global $users;
    $users->checkPermission();


    Which makes sure the person has the authority to do what their trying
    to do.
    lawrence Guest

  5. #4

    Default Re: can list() in while loop, while printing things to a screen, somehow affect the values in an array?

    On 13 Jul 2003 06:35:31 -0700, [email]lkrubner@geocities.com[/email] (lawrence) wrote:
    >Andy Hassall <andy@andyh.co.uk> wrote in message news:<iao0hvo5334e94v10bks47dte5s8ofrqej@4ax.com>. ..
    >> On Sat, 12 Jul 2003 19:21:32 GMT, "Jason" <jsumner1@cfl.rr.com> wrote:
    >>
    >> >Try choiceMade() and not $choiceMade(). "$" is for variables.
    >>
    >> He's doing a variable function call.
    >>
    >> (Which is sheer lunacy from a form variable, but valid syntax nonetheless).
    >
    >Sheer lunacy from a security standpoint I assume.
    Yep.
    >Which is why every one of my functions starts with:
    >
    >global $users;
    >$users->checkPermission();
    >
    >Which makes sure the person has the authority to do what their trying
    >to do.
    But in the code you posted you're not checking the value of $choiceMade,
    you're going straight from input to executing it as a function.

    If in the real code you're checking $choiceMade is one of a set of functions
    that the user is allowed to execute, then fine.

    --
    Andy Hassall (andy@andyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage analysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  6. #5

    Default Re: can list() in while loop, while printing things to a screen, somehow affect the values in an array?

    Andy Hassall <andy@andyh.co.uk> wrote in message
    > But in the code you posted you're not checking the value of $choiceMade,
    > you're going straight from input to executing it as a function.
    >
    > If in the real code you're checking $choiceMade is one of a set of functions
    > that the user is allowed to execute, then fine.
    Thanks for the feedback. Believe me, this is an issue I've sweated
    over. I'm paranoid someone will find a way in through this hole.

    I think the answer to your question, if I read it correctly, is no, I
    don't test the value of $choiceMade against a list of functions the
    user can execute. Not before the function executes. I do so as the
    funtion executes. The second line of every function is
    $users->check(), to see if the user has permission to do that
    function.

    Suppose you go to monkeyclaus right now and type in an url like this:

    [url]http://www.monkeyclaus.org/mcIncludes/mcControlPanel.php?choiceMade=printDeleteWeblogFor m[/url]

    You are, with this url, attempting to hack into the site and execute
    the function printDeleteWeblogsForm();

    Before your code can execute the password and username are checked and
    the login screen is printed, followed by die();

    I admit, if you go here:

    [url]http://www.monkeyclaus.org/index.php?choiceMade=printDeleteWeblogForm[/url]

    You get an error message that I can't understand, and anything that I
    can't understand regarding the security of the site makes me sweat.

    My attitude is that this software is beta. That is how it is marked
    and that is what I tell everyone - "The software is beta, I'm still
    testing the security, don't be suprised if the site gets hacked."

    For a year and half this software was for just one person, and then
    the security was iron tight. Just last month I added a user system,
    which has added a great deal of complexity, and also the possibilities
    of security holes. I hope to find them all by the end of the summer.
    When I feel pretty confident, and my friends have gone over the site
    and tried to hack it and found no way in, then I'll stop calling it
    "beta".




    This is the function for deleting weblogs. Normally it would print a
    list of all weblogs and ask which you wanted to delete:


    function printDeleteWeblogForm($pageId=0) {
    // 06-18-03 - today I've introduced the function deleteForm in the
    forms class which comes close to providing a universal delete form
    // for any of the entries in mcContentBlocks.
    global $users, $forms;
    $users->check();
    $forms->deleteForm("weblogs");
    }
    lawrence Guest

  7. #6

    Default Re: can list() in while loop, while printing things to a screen, somehow affect the values in an array?

    On 13 Jul 2003 11:52:28 -0700, [email]lkrubner@geocities.com[/email] (lawrence) wrote:
    >Andy Hassall <andy@andyh.co.uk> wrote in message
    >> But in the code you posted you're not checking the value of $choiceMade,
    >> you're going straight from input to executing it as a function.
    >>
    >> If in the real code you're checking $choiceMade is one of a set of functions
    >> that the user is allowed to execute, then fine.
    >
    >Thanks for the feedback. Believe me, this is an issue I've sweated
    >over. I'm paranoid someone will find a way in through this hole.
    >
    >I think the answer to your question, if I read it correctly, is no, I
    >don't test the value of $choiceMade against a list of functions the
    >user can execute. Not before the function executes. I do so as the
    >funtion executes. The second line of every function is
    >$users->check(), to see if the user has permission to do that
    >function.
    OK, I see.

    However, my point is - what if choiceMade is used to execute a function that
    you haven't written, and so you haven't put this security check in? Then it's
    too late, the function is already running...
    >Suppose you go to monkeyclaus right now and type in an url like this:
    >
    >[url]http://www.monkeyclaus.org/mcIncludes/mcControlPanel.php?choiceMade=printDeleteWeblogFor m[/url]
    >
    >You are, with this url, attempting to hack into the site and execute
    >the function printDeleteWeblogsForm();
    >
    >Before your code can execute the password and username are checked and
    >the login screen is printed, followed by die();
    I can't off the top of my head think of a PHP function that takes no
    parameters that could cause serious mischief. There may be one though, or maybe
    another of your functions that you were never expecting to be called, and so
    doesn't have the security check.

    Consider if you ever added parameter support to your system; e.g.
    'choiceMade=function&arg1=whatever' would call function("whatever"). At that
    point you enter a whole world of pain, because you could call:

    choiceMade=eval&arg1=<whatever PHP code you like>

    If you limit choiceMade to only those functions that you have written and you
    have added the security check to, then you avoid such problems.

    Could be as simple as a global array containing all the functions, and then
    use array_exists to check that $choiceMade is one of those designated
    'OK-to-call' functions.

    --
    Andy Hassall (andy@andyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage analysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  8. #7

    Default Re: can list() in while loop, while printing things to a screen, somehow affect the values in an array?

    Andy Hassall <andy@andyh.co.uk> wrote in message
    > I can't off the top of my head think of a PHP function that takes no
    > parameters that could cause serious mischief. There may be one though, or maybe
    > another of your functions that you were never expecting to be called, and so
    > doesn't have the security check.
    >
    > Consider if you ever added parameter support to your system; e.g.
    > 'choiceMade=function&arg1=whatever' would call function("whatever"). At that
    > point you enter a whole world of pain, because you could call:
    >
    > choiceMade=eval&arg1=<whatever PHP code you like>
    >
    > If you limit choiceMade to only those functions that you have written and you
    > have added the security check to, then you avoid such problems.
    >
    > Could be as simple as a global array containing all the functions, and then
    > use array_exists to check that $choiceMade is one of those designated
    > 'OK-to-call' functions.


    You're right, I will implement an array listing all functions that can
    be called. Thanks very much for thinking it through, you've been a
    huge help.
    lawrence Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139