Closed elgodolfredo closed 4 years ago
@elgodolfredo Thanks for the PR, I appreciate your enthusiasm. A few comments from me might help you give some feedback to your college about the task:
I'm going to write this in BOLD ALL CAPS because it's so important... NEVER EVER OPEN PUBLIC PRS FOR WHAT YOU THINK MAY BE SECURITY ISSUES. NOT EVER. ALWAYS CONTACT DEVELOPERS PRIVATELY. This is (obviously) because revealing a security issue lets everyone know that it's there.
Okay, now that's out of the way, let me explain why the use of extract()
here isn't the security concern that you think it is...
extract()
on untrusted data" (which is presumably why you wrote the PR) you'll also have noticed these lines which come before extract()
that ensure that we trust the source of the data.$_POST
.$_POST
data, the contents of the array is sanitised - because it is saved in the database.Now, you could argue that extract()
makes it difficult to find the origin of the variable - but that's a separate stylistic issue. Indeed, this is why WordPress ditched its usage of extract()
- not because it's a security concern but because variables appear "magically". For reference, here's the relevant ticket:
https://core.trac.wordpress.org/ticket/22400
Right, that said, I agree that extract()
is not elegant but if I were to replace the existing code, I'd write something along the lines of:
$results = [];
$vars = [ 'one', 'two', 'three' ];
foreach( $vars AS $var ) {
$results[$var] = empty( $_POST[$var] ) ? $_POST[$var] : '';
}
Or something like that.
I'm going to close this PR because I don't want the commit or merge history to contain the phrase "Security bug fixed" which might unnecessarily worry the users of this code.
Hello. I was looking for repositories that have security bugs for an assignment that I have to do on my college. This one in particular uses "extract()" and it's not recommended. In this page its explained in detail https://www.php.net/manual/en/function.extract.php
Can u please give a look to my commit and if its possible merge? I'll appreciate it a lot! :)
Thanks!