Live data from Hacker News

Exec($_GET

github.com

101–110 of 131 posts

Re: Exec($_GET

#101
post #55

Earlier quoted context omitted.

I think the problem here is the fact that tainted variables (user input) are used to execute shell commands. it doesn't matter if that's $_POST or $_GET, both of these are user input and therefore these are huge vulnerabilities.

I'm pretty sure GP was being sarcastic.

Whoops! My bad.. now I feel stupid :)

Re: Exec($_GET

#102
post #98
post #83

Earlier quoted context omitted.

in_array(needle, haystack) PHP with its argument ordering strikes again :)

... actually, if(!IDEMPOTENT_COMMANDS[$cmdname]) { ... would do, and, assuming dictionary lookups are optimised, is possibly faster.

actually,

   if (! isset(IDEMPOTENT_COMMANDS[$cmdname]))
otherwise you'll get an undefined index notice :)

Re: Exec($_GET

#103
post #102
post #98

Earlier quoted context omitted.

... actually, if(!IDEMPOTENT_COMMANDS[$cmdname]) { ... would do, and, assuming dictionary lookups are optimised, is possibly faster.

actually, if (! isset(IDEMPOTENT_COMMANDS[$cmdname])) otherwise you'll get an undefined index notice :)

Indeed. My PHP-fu is a bit rusty... I tested `if(NULL)...` in the REPL and since it was working, I left it at that.

Re: Exec($_GET

#106
No!

Yes:

Something like this?

This will filter user input with regular expression and save value in session memory. This will return value even when user inputted value is not imported. When is, new value is updated in session memory.

function __var($name, $pattern, $value, $default = null) {

  # change
  if ($value !== null && preg_match($pattern, $value)) {
    $_SESSION['__var'][$name] = $value;
  }

  # reset
  if ($_GET['reset'] == $name) {
    unset($_SESSION['__var'][$name]);
  }

  # deafult
  if ($_SESSION['__var'][$name] == null && $default != null) {
    $_SESSION['__var'][$name] = $default;
  }

  # return
  return $_SESSION['__var'][$name];
}

Re: Exec($_GET

#107

"We've found 99,841 code results" Someone should write a script that automatically raises an issues for each line and each project, it's probably possible, but I'm chronically lazy.

After looking at the search result i can see that most of the results have legit reasons.

Instead of half-assing the problem, please dedicate 10 minute of your life to look in, analyze & report one or two of the problems you find.

Also explain why you think this is an security issue.

You will:

  * help someone out by pointing out an issue

  * hopefully educate the person how to write better code

  * educate yourself in reading and understanding others spaghetti code

Re: Exec($_GET

#109
post #100

Earlier quoted context omitted.

I really, really, really want to post on their issue tracker, but maybe I shouldn't. There's no guarantee the person grading the project will care, either.

You should. But be factual. No point in bringing the attitude.

The repo in question is 2 years old. It may be worth getting in contact with the uni who runs that course though.

Re: Exec($_GET

#110
post #91

This needs to be quoted to return decent results: https://github.com/search?q=%22exec%28%24_GET%22&type=Code&r... Otherwise there are way too many false positives. Still, 188 results is pretty awful.

You now also excluded thousands of true positives which dont present the code exactly as queried
Post reply on HN